author | zautrix <zautrix> | 2004-07-07 13:35:48 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-07 13:35:48 (UTC) |
commit | 5030b0bd32b1e526f28ce0339d4b4854492393ae (patch) (unidiff) | |
tree | 0a4bfd70d51f0d9d791511ca536c463d68df8af9 | |
parent | 56721aac86c9ae5253abac8962474c8d1a7e648a (diff) | |
download | kdepimpi-5030b0bd32b1e526f28ce0339d4b4854492393ae.zip kdepimpi-5030b0bd32b1e526f28ce0339d4b4854492393ae.tar.gz kdepimpi-5030b0bd32b1e526f28ce0339d4b4854492393ae.tar.bz2 |
made plugins finding on desktop
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | microkde/kdecore/klibloader.cpp | 6 | ||||
-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 21 |
3 files changed, 24 insertions, 5 deletions
@@ -1,147 +1,147 @@ | |||
1 | ############################################################################# | 1 | ############################################################################# |
2 | # Makefile for building: kopi-desktop | 2 | # Makefile for building: kopi-desktop |
3 | # Generated by qmake (1.07a) (Qt 3.3.2) on: Wed Jul 7 13:43:59 2004 | 3 | # Generated by qmake (1.07a) (Qt 3.3.2) on: Wed Jul 7 14:00:48 2004 |
4 | # Project: kopi-desktop.pro | 4 | # Project: kopi-desktop.pro |
5 | # Template: subdirs | 5 | # Template: subdirs |
6 | # Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro | 6 | # Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro |
7 | ############################################################################# | 7 | ############################################################################# |
8 | 8 | ||
9 | MAKEFILE =Makefile | 9 | MAKEFILE =Makefile |
10 | QMAKE =qmake | 10 | QMAKE =qmake |
11 | DEL_FILE = rm -f | 11 | DEL_FILE = rm -f |
12 | CHK_DIR_EXISTS= test -d | 12 | CHK_DIR_EXISTS= test -d |
13 | MKDIR = mkdir -p | 13 | MKDIR = mkdir -p |
14 | INSTALL_FILE= | 14 | INSTALL_FILE= |
15 | INSTALL_DIR = | 15 | INSTALL_DIR = |
16 | SUBTARGETS = \ | 16 | SUBTARGETS = \ |
17 | sub-libical \ | 17 | sub-libical \ |
18 | sub-libkcal \ | 18 | sub-libkcal \ |
19 | sub-microkde \ | 19 | sub-microkde \ |
20 | sub-libkdepim \ | 20 | sub-libkdepim \ |
21 | sub-kabc \ | 21 | sub-kabc \ |
22 | sub-korganizer \ | 22 | sub-korganizer \ |
23 | sub-kaddressbook \ | 23 | sub-kaddressbook \ |
24 | sub-kabc-plugins-file \ | 24 | sub-kabc-plugins-file \ |
25 | sub-kabc-plugins-dir | 25 | sub-kabc-plugins-dir |
26 | 26 | ||
27 | first: all | 27 | first: all |
28 | 28 | ||
29 | all: Makefile $(SUBTARGETS) | 29 | all: Makefile $(SUBTARGETS) |
30 | 30 | ||
31 | libical/$(MAKEFILE): | 31 | libical/$(MAKEFILE): |
32 | @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" | 32 | @$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical" |
33 | cd libical && $(QMAKE) libical.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 33 | cd libical && $(QMAKE) libical.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
34 | sub-libical: libical/$(MAKEFILE) FORCE | 34 | sub-libical: libical/$(MAKEFILE) FORCE |
35 | cd libical && $(MAKE) -f $(MAKEFILE) | 35 | cd libical && $(MAKE) -f $(MAKEFILE) |
36 | 36 | ||
37 | libkcal/$(MAKEFILE): | 37 | libkcal/$(MAKEFILE): |
38 | @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" | 38 | @$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal" |
39 | cd libkcal && $(QMAKE) libkcal.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 39 | cd libkcal && $(QMAKE) libkcal.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
40 | sub-libkcal: libkcal/$(MAKEFILE) FORCE | 40 | sub-libkcal: libkcal/$(MAKEFILE) FORCE |
41 | cd libkcal && $(MAKE) -f $(MAKEFILE) | 41 | cd libkcal && $(MAKE) -f $(MAKEFILE) |
42 | 42 | ||
43 | microkde/$(MAKEFILE): | 43 | microkde/$(MAKEFILE): |
44 | @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" | 44 | @$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde" |
45 | cd microkde && $(QMAKE) microkde.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 45 | cd microkde && $(QMAKE) microkde.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
46 | sub-microkde: microkde/$(MAKEFILE) FORCE | 46 | sub-microkde: microkde/$(MAKEFILE) FORCE |
47 | cd microkde && $(MAKE) -f $(MAKEFILE) | 47 | cd microkde && $(MAKE) -f $(MAKEFILE) |
48 | 48 | ||
49 | libkdepim/$(MAKEFILE): | 49 | libkdepim/$(MAKEFILE): |
50 | @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim" | 50 | @$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim" |
51 | cd libkdepim && $(QMAKE) libkdepim.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 51 | cd libkdepim && $(QMAKE) libkdepim.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
52 | sub-libkdepim: libkdepim/$(MAKEFILE) FORCE | 52 | sub-libkdepim: libkdepim/$(MAKEFILE) FORCE |
53 | cd libkdepim && $(MAKE) -f $(MAKEFILE) | 53 | cd libkdepim && $(MAKE) -f $(MAKEFILE) |
54 | 54 | ||
55 | kabc/$(MAKEFILE): | 55 | kabc/$(MAKEFILE): |
56 | @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc" | 56 | @$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc" |
57 | cd kabc && $(QMAKE) kabc.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 57 | cd kabc && $(QMAKE) kabc.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
58 | sub-kabc: kabc/$(MAKEFILE) FORCE | 58 | sub-kabc: kabc/$(MAKEFILE) FORCE |
59 | cd kabc && $(MAKE) -f $(MAKEFILE) | 59 | cd kabc && $(MAKE) -f $(MAKEFILE) |
60 | 60 | ||
61 | korganizer/$(MAKEFILE): | 61 | korganizer/$(MAKEFILE): |
62 | @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer" | 62 | @$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer" |
63 | cd korganizer && $(QMAKE) korganizer.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 63 | cd korganizer && $(QMAKE) korganizer.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
64 | sub-korganizer: korganizer/$(MAKEFILE) FORCE | 64 | sub-korganizer: korganizer/$(MAKEFILE) FORCE |
65 | cd korganizer && $(MAKE) -f $(MAKEFILE) | 65 | cd korganizer && $(MAKE) -f $(MAKEFILE) |
66 | 66 | ||
67 | kaddressbook/$(MAKEFILE): | 67 | kaddressbook/$(MAKEFILE): |
68 | @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook" | 68 | @$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook" |
69 | cd kaddressbook && $(QMAKE) kaddressbook.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 69 | cd kaddressbook && $(QMAKE) kaddressbook.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
70 | sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE | 70 | sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE |
71 | cd kaddressbook && $(MAKE) -f $(MAKEFILE) | 71 | cd kaddressbook && $(MAKE) -f $(MAKEFILE) |
72 | 72 | ||
73 | kabc/plugins/file/$(MAKEFILE): | 73 | kabc/plugins/file/$(MAKEFILE): |
74 | @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file" | 74 | @$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file" |
75 | cd kabc/plugins/file && $(QMAKE) file.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 75 | cd kabc/plugins/file && $(QMAKE) file.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
76 | sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE | 76 | sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE |
77 | cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE) | 77 | cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE) |
78 | 78 | ||
79 | kabc/plugins/dir/$(MAKEFILE): | 79 | kabc/plugins/dir/$(MAKEFILE): |
80 | @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir" | 80 | @$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir" |
81 | cd kabc/plugins/dir && $(QMAKE) dir.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) | 81 | cd kabc/plugins/dir && $(QMAKE) dir.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE) |
82 | sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE | 82 | sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE |
83 | cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE) | 83 | cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE) |
84 | 84 | ||
85 | Makefile: kopi-desktop.pro /usr/local/qtgcc/mkspecs/default/qmake.conf | 85 | Makefile: kopi-desktop.pro /usr/local/qtgcc/mkspecs/default/qmake.conf |
86 | $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro | 86 | $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro |
87 | qmake: qmake_all | 87 | qmake: qmake_all |
88 | @$(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro | 88 | @$(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kopi-desktop.pro |
89 | 89 | ||
90 | all: $(SUBTARGETS) | 90 | all: $(SUBTARGETS) |
91 | qmake_all: libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) | 91 | qmake_all: libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE) |
92 | ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | 92 | ( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
93 | ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | 93 | ( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
94 | ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | 94 | ( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
95 | ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | 95 | ( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
96 | ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | 96 | ( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
97 | ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | 97 | ( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
98 | ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | 98 | ( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
99 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | 99 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
100 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true | 100 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true |
101 | clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE | 101 | clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE |
102 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true | 102 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
103 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true | 103 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
104 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true | 104 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
105 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true | 105 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
106 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true | 106 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
107 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true | 107 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
108 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true | 108 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
109 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true | 109 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
110 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true | 110 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true |
111 | uninstall_subdirs: qmake_all FORCE | 111 | uninstall_subdirs: qmake_all FORCE |
112 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | 112 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
113 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | 113 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
114 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | 114 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
115 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | 115 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
116 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | 116 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
117 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | 117 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
118 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | 118 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
119 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | 119 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
120 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true | 120 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true |
121 | install_subdirs: qmake_all FORCE | 121 | install_subdirs: qmake_all FORCE |
122 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true | 122 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true |
123 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true | 123 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true |
124 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true | 124 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true |
125 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true | 125 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true |
126 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true | 126 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true |
127 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true | 127 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true |
128 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true | 128 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true |
129 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true | 129 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true |
130 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true | 130 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true |
131 | distclean: qmake_all FORCE | 131 | distclean: qmake_all FORCE |
132 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | 132 | ( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
133 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | 133 | ( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
134 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | 134 | ( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
135 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | 135 | ( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
136 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | 136 | ( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
137 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | 137 | ( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
138 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | 138 | ( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
139 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | 139 | ( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
140 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true | 140 | ( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true |
141 | 141 | ||
142 | install: install_subdirs | 142 | install: install_subdirs |
143 | 143 | ||
144 | uninstall: uninstall_subdirs | 144 | uninstall: uninstall_subdirs |
145 | 145 | ||
146 | FORCE: | 146 | FORCE: |
147 | 147 | ||
diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp index c091e05..9eee912 100644 --- a/microkde/kdecore/klibloader.cpp +++ b/microkde/kdecore/klibloader.cpp | |||
@@ -143,506 +143,512 @@ QString KLibrary::name() const | |||
143 | } | 143 | } |
144 | 144 | ||
145 | QString KLibrary::fileName() const | 145 | QString KLibrary::fileName() const |
146 | { | 146 | { |
147 | return m_filename; | 147 | return m_filename; |
148 | } | 148 | } |
149 | 149 | ||
150 | KLibFactory* KLibrary::factory() | 150 | KLibFactory* KLibrary::factory() |
151 | { | 151 | { |
152 | if ( m_factory ) | 152 | if ( m_factory ) |
153 | return m_factory; | 153 | return m_factory; |
154 | 154 | ||
155 | QCString symname; | 155 | QCString symname; |
156 | symname.sprintf("init_%s", name().latin1() ); | 156 | symname.sprintf("init_%s", name().latin1() ); |
157 | 157 | ||
158 | void* sym = symbol( symname ); | 158 | void* sym = symbol( symname ); |
159 | if ( !sym ) | 159 | if ( !sym ) |
160 | { | 160 | { |
161 | qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); | 161 | qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); |
162 | #ifndef NDEBUG | 162 | #ifndef NDEBUG |
163 | //US qDebug("KLibrary: errorcode: %s", lt_dlerror()); | 163 | //US qDebug("KLibrary: errorcode: %s", lt_dlerror()); |
164 | #endif | 164 | #endif |
165 | kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; | 165 | kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; |
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | typedef KLibFactory* (*t_func)(); | 169 | typedef KLibFactory* (*t_func)(); |
170 | t_func func = (t_func)sym; | 170 | t_func func = (t_func)sym; |
171 | m_factory = func(); | 171 | m_factory = func(); |
172 | 172 | ||
173 | if( !m_factory ) | 173 | if( !m_factory ) |
174 | { | 174 | { |
175 | kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; | 175 | kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; |
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | connect( m_factory, SIGNAL( objectCreated( QObject * ) ), | 179 | connect( m_factory, SIGNAL( objectCreated( QObject * ) ), |
180 | this, SLOT( slotObjectCreated( QObject * ) ) ); | 180 | this, SLOT( slotObjectCreated( QObject * ) ) ); |
181 | 181 | ||
182 | return m_factory; | 182 | return m_factory; |
183 | } | 183 | } |
184 | 184 | ||
185 | void* KLibrary::symbol( const char* symname ) const | 185 | void* KLibrary::symbol( const char* symname ) const |
186 | { | 186 | { |
187 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); | 187 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); |
188 | void* sym = m_handle->resolve( symname ); | 188 | void* sym = m_handle->resolve( symname ); |
189 | if ( !sym ) | 189 | if ( !sym ) |
190 | { | 190 | { |
191 | //US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; | 191 | //US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; |
192 | return 0; | 192 | return 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | return sym; | 195 | return sym; |
196 | } | 196 | } |
197 | 197 | ||
198 | bool KLibrary::hasSymbol( const char* symname ) const | 198 | bool KLibrary::hasSymbol( const char* symname ) const |
199 | { | 199 | { |
200 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); | 200 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); |
201 | void* sym = m_handle->resolve( symname ); | 201 | void* sym = m_handle->resolve( symname ); |
202 | return (sym != 0L ); | 202 | return (sym != 0L ); |
203 | } | 203 | } |
204 | 204 | ||
205 | void KLibrary::unload() const | 205 | void KLibrary::unload() const |
206 | { | 206 | { |
207 | if (KLibLoader::s_self) | 207 | if (KLibLoader::s_self) |
208 | KLibLoader::s_self->unloadLibrary(QFile::encodeName(name())); | 208 | KLibLoader::s_self->unloadLibrary(QFile::encodeName(name())); |
209 | } | 209 | } |
210 | 210 | ||
211 | void KLibrary::slotObjectCreated( QObject *obj ) | 211 | void KLibrary::slotObjectCreated( QObject *obj ) |
212 | { | 212 | { |
213 | if ( !obj ) | 213 | if ( !obj ) |
214 | return; | 214 | return; |
215 | 215 | ||
216 | if ( m_timer && m_timer->isActive() ) | 216 | if ( m_timer && m_timer->isActive() ) |
217 | m_timer->stop(); | 217 | m_timer->stop(); |
218 | 218 | ||
219 | if ( m_objs.containsRef( obj ) ) | 219 | if ( m_objs.containsRef( obj ) ) |
220 | return; // we know this object already | 220 | return; // we know this object already |
221 | 221 | ||
222 | connect( obj, SIGNAL( destroyed() ), | 222 | connect( obj, SIGNAL( destroyed() ), |
223 | this, SLOT( slotObjectDestroyed() ) ); | 223 | this, SLOT( slotObjectDestroyed() ) ); |
224 | 224 | ||
225 | m_objs.append( obj ); | 225 | m_objs.append( obj ); |
226 | } | 226 | } |
227 | 227 | ||
228 | void KLibrary::slotObjectDestroyed() | 228 | void KLibrary::slotObjectDestroyed() |
229 | { | 229 | { |
230 | m_objs.removeRef( sender() ); | 230 | m_objs.removeRef( sender() ); |
231 | 231 | ||
232 | if ( m_objs.count() == 0 ) | 232 | if ( m_objs.count() == 0 ) |
233 | { | 233 | { |
234 | // kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!" | 234 | // kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!" |
235 | // << endl; | 235 | // << endl; |
236 | 236 | ||
237 | if ( !m_timer ) | 237 | if ( !m_timer ) |
238 | { | 238 | { |
239 | m_timer = new QTimer( this, "klibrary_shutdown_timer" ); | 239 | m_timer = new QTimer( this, "klibrary_shutdown_timer" ); |
240 | connect( m_timer, SIGNAL( timeout() ), | 240 | connect( m_timer, SIGNAL( timeout() ), |
241 | this, SLOT( slotTimeout() ) ); | 241 | this, SLOT( slotTimeout() ) ); |
242 | } | 242 | } |
243 | 243 | ||
244 | // as long as it's not stable make the timeout short, for debugging | 244 | // as long as it's not stable make the timeout short, for debugging |
245 | // pleasure (matz) | 245 | // pleasure (matz) |
246 | //m_timer->start( 1000*60, true ); | 246 | //m_timer->start( 1000*60, true ); |
247 | m_timer->start( 1000*10, true ); | 247 | m_timer->start( 1000*10, true ); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | void KLibrary::slotTimeout() | 251 | void KLibrary::slotTimeout() |
252 | { | 252 | { |
253 | if ( m_objs.count() != 0 ) | 253 | if ( m_objs.count() != 0 ) |
254 | return; | 254 | return; |
255 | 255 | ||
256 | /* Don't go through KLibLoader::unloadLibrary(), because that uses the | 256 | /* Don't go through KLibLoader::unloadLibrary(), because that uses the |
257 | ref counter, but this timeout means to unconditionally close this library | 257 | ref counter, but this timeout means to unconditionally close this library |
258 | The destroyed() signal will take care to remove us from all lists. | 258 | The destroyed() signal will take care to remove us from all lists. |
259 | */ | 259 | */ |
260 | delete this; | 260 | delete this; |
261 | } | 261 | } |
262 | 262 | ||
263 | // ------------------------------------------------- | 263 | // ------------------------------------------------- |
264 | 264 | ||
265 | /* This helper class is needed, because KLibraries can go away without | 265 | /* This helper class is needed, because KLibraries can go away without |
266 | being unloaded. So we need some info about KLibraries even after its | 266 | being unloaded. So we need some info about KLibraries even after its |
267 | death. */ | 267 | death. */ |
268 | class KLibWrapPrivate | 268 | class KLibWrapPrivate |
269 | { | 269 | { |
270 | public: | 270 | public: |
271 | //US KLibWrapPrivate(KLibrary *l, lt_dlhandle h); | 271 | //US KLibWrapPrivate(KLibrary *l, lt_dlhandle h); |
272 | KLibWrapPrivate(KLibrary *l, QLibrary* h); | 272 | KLibWrapPrivate(KLibrary *l, QLibrary* h); |
273 | 273 | ||
274 | KLibrary *lib; | 274 | KLibrary *lib; |
275 | enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; | 275 | enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; |
276 | int ref_count; | 276 | int ref_count; |
277 | //US lt_dlhandle handle; | 277 | //US lt_dlhandle handle; |
278 | QLibrary *handle; | 278 | QLibrary *handle; |
279 | QString name; | 279 | QString name; |
280 | QString filename; | 280 | QString filename; |
281 | }; | 281 | }; |
282 | 282 | ||
283 | //US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h) | 283 | //US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h) |
284 | KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h) | 284 | KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h) |
285 | : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName()) | 285 | : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName()) |
286 | { | 286 | { |
287 | unload_mode = UNKNOWN; | 287 | unload_mode = UNKNOWN; |
288 | /*US | 288 | /*US |
289 | if (lt_dlsym(handle, "__kde_do_not_unload") != 0) { | 289 | if (lt_dlsym(handle, "__kde_do_not_unload") != 0) { |
290 | // kdDebug(150) << "Will not unload " << name << endl; | 290 | // kdDebug(150) << "Will not unload " << name << endl; |
291 | unload_mode = DONT_UNLOAD; | 291 | unload_mode = DONT_UNLOAD; |
292 | } else if (lt_dlsym(handle, "__kde_do_unload") != 0) { | 292 | } else if (lt_dlsym(handle, "__kde_do_unload") != 0) { |
293 | unload_mode = UNLOAD; | 293 | unload_mode = UNLOAD; |
294 | } | 294 | } |
295 | */ | 295 | */ |
296 | //US use instead: | 296 | //US use instead: |
297 | if (h->resolve("__kde_do_not_unload") != 0) { | 297 | if (h->resolve("__kde_do_not_unload") != 0) { |
298 | // kdDebug(150) << "Will not unload " << name << endl; | 298 | // kdDebug(150) << "Will not unload " << name << endl; |
299 | unload_mode = DONT_UNLOAD; | 299 | unload_mode = DONT_UNLOAD; |
300 | } else if (h->resolve("__kde_do_unload") != 0) { | 300 | } else if (h->resolve("__kde_do_unload") != 0) { |
301 | unload_mode = UNLOAD; | 301 | unload_mode = UNLOAD; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | class KLibLoaderPrivate | 305 | class KLibLoaderPrivate |
306 | { | 306 | { |
307 | public: | 307 | public: |
308 | QPtrList<KLibWrapPrivate> loaded_stack; | 308 | QPtrList<KLibWrapPrivate> loaded_stack; |
309 | QPtrList<KLibWrapPrivate> pending_close; | 309 | QPtrList<KLibWrapPrivate> pending_close; |
310 | enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; | 310 | enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; |
311 | 311 | ||
312 | QString errorMessage; | 312 | QString errorMessage; |
313 | }; | 313 | }; |
314 | 314 | ||
315 | KLibLoader* KLibLoader::s_self = 0; | 315 | KLibLoader* KLibLoader::s_self = 0; |
316 | 316 | ||
317 | KLibLoader* KLibLoader::self() | 317 | KLibLoader* KLibLoader::self() |
318 | { | 318 | { |
319 | if ( !s_self ) | 319 | if ( !s_self ) |
320 | s_self = new KLibLoader; | 320 | s_self = new KLibLoader; |
321 | return s_self; | 321 | return s_self; |
322 | } | 322 | } |
323 | 323 | ||
324 | void KLibLoader::cleanUp() | 324 | void KLibLoader::cleanUp() |
325 | { | 325 | { |
326 | if ( !s_self ) | 326 | if ( !s_self ) |
327 | return; | 327 | return; |
328 | 328 | ||
329 | delete s_self; | 329 | delete s_self; |
330 | s_self = 0; | 330 | s_self = 0; |
331 | } | 331 | } |
332 | 332 | ||
333 | KLibLoader::KLibLoader( QObject* parent, const char* name ) | 333 | KLibLoader::KLibLoader( QObject* parent, const char* name ) |
334 | : QObject( parent, name ) | 334 | : QObject( parent, name ) |
335 | { | 335 | { |
336 | s_self = this; | 336 | s_self = this; |
337 | d = new KLibLoaderPrivate; | 337 | d = new KLibLoaderPrivate; |
338 | //US lt_dlinit(); | 338 | //US lt_dlinit(); |
339 | d->unload_mode = KLibLoaderPrivate::UNKNOWN; | 339 | d->unload_mode = KLibLoaderPrivate::UNKNOWN; |
340 | if (getenv("KDE_NOUNLOAD") != 0) | 340 | if (getenv("KDE_NOUNLOAD") != 0) |
341 | d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD; | 341 | d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD; |
342 | else if (getenv("KDE_DOUNLOAD") != 0) | 342 | else if (getenv("KDE_DOUNLOAD") != 0) |
343 | d->unload_mode = KLibLoaderPrivate::UNLOAD; | 343 | d->unload_mode = KLibLoaderPrivate::UNLOAD; |
344 | d->loaded_stack.setAutoDelete( true ); | 344 | d->loaded_stack.setAutoDelete( true ); |
345 | } | 345 | } |
346 | 346 | ||
347 | KLibLoader::~KLibLoader() | 347 | KLibLoader::~KLibLoader() |
348 | { | 348 | { |
349 | // kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; | 349 | // kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; |
350 | 350 | ||
351 | QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); | 351 | QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); |
352 | for (; it.current(); ++it ) | 352 | for (; it.current(); ++it ) |
353 | { | 353 | { |
354 | kdDebug(150) << "The KLibLoader contains the library " << it.current()->name | 354 | kdDebug(150) << "The KLibLoader contains the library " << it.current()->name |
355 | << " (" << it.current()->lib << ")" << endl; | 355 | << " (" << it.current()->lib << ")" << endl; |
356 | d->pending_close.append(it.current()); | 356 | d->pending_close.append(it.current()); |
357 | } | 357 | } |
358 | 358 | ||
359 | close_pending(0); | 359 | close_pending(0); |
360 | 360 | ||
361 | delete d; | 361 | delete d; |
362 | } | 362 | } |
363 | 363 | ||
364 | //static | 364 | //static |
365 | QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) | 365 | QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) |
366 | { | 366 | { |
367 | QCString libname( name ); | 367 | QCString libname( name ); |
368 | 368 | ||
369 | // only append ".la" if there is no extension | 369 | // only append ".la" if there is no extension |
370 | // this allows to load non-libtool libraries as well | 370 | // this allows to load non-libtool libraries as well |
371 | // (mhk, 20000228) | 371 | // (mhk, 20000228) |
372 | int pos = libname.findRev('/'); | 372 | int pos = libname.findRev('/'); |
373 | if (pos < 0) | 373 | if (pos < 0) |
374 | pos = 0; | 374 | pos = 0; |
375 | /*US | 375 | /*US |
376 | if (libname.find('.', pos) < 0) { | 376 | if (libname.find('.', pos) < 0) { |
377 | libname += ".la"; | 377 | libname += ".la"; |
378 | } | 378 | } |
379 | */ | 379 | */ |
380 | //US in the microedition we work only with shared libraries. | 380 | //US in the microedition we work only with shared libraries. |
381 | if (libname.find('.', pos) < 0) { | 381 | if (libname.find('.', pos) < 0) { |
382 | libname += ".so"; | 382 | libname += ".so"; |
383 | } | 383 | } |
384 | 384 | ||
385 | // only look up the file if it is not an absolute filename | 385 | // only look up the file if it is not an absolute filename |
386 | // (mhk, 20000228) | 386 | // (mhk, 20000228) |
387 | QString libfile; | 387 | QString libfile; |
388 | if (libname[0] == '/') | 388 | if (libname[0] == '/') |
389 | libfile = libname; | 389 | libfile = libname; |
390 | else | 390 | else |
391 | { | 391 | { |
392 | //US at this point the libname must exist as real filesname. No expansions will be made later | 392 | //US at this point the libname must exist as real filesname. No expansions will be made later |
393 | // in findResources. Because of that we prepend the lib prefix here to the name | 393 | // in findResources. Because of that we prepend the lib prefix here to the name |
394 | //US I add also the "lib" prefix. I do not how could this could have worked before without it? | 394 | //US I add also the "lib" prefix. I do not how could this could have worked before without it? |
395 | libname.insert(pos, "lib"); | 395 | libname.insert(pos, "lib"); |
396 | 396 | ||
397 | 397 | ||
398 | //US libfile = instance->dirs()->findResource( "module", libname ); | 398 | //US libfile = instance->dirs()->findResource( "module", libname ); |
399 | //qDebug("libname = %s ",libname.data() ); | ||
399 | libfile = KGlobal::dirs()->findResource( "module", libname ); | 400 | libfile = KGlobal::dirs()->findResource( "module", libname ); |
401 | //qDebug("libfile = %s ",libfile.latin1() ); | ||
402 | |||
400 | if ( libfile.isEmpty() ) | 403 | if ( libfile.isEmpty() ) |
401 | { | 404 | { |
402 | //US libfile = instance->dirs()->findResource( "lib", libname ); | 405 | //US libfile = instance->dirs()->findResource( "lib", libname ); |
403 | libfile = KGlobal::dirs()->findResource( "lib", libname ); | 406 | libfile = KGlobal::dirs()->findResource( "lib", libname ); |
407 | //qDebug("libfile2 = %s ",libfile.latin1() ); | ||
404 | #ifndef NDEBUG | 408 | #ifndef NDEBUG |
405 | if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules | 409 | if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules |
406 | kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; | 410 | kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; |
407 | #endif | 411 | #endif |
408 | } | 412 | } |
409 | if ( libfile.isEmpty() ) | 413 | if ( libfile.isEmpty() ) |
410 | { | 414 | { |
411 | #ifndef NDEBUG | 415 | #ifndef NDEBUG |
412 | kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; | 416 | kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; |
413 | self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); | 417 | self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); |
414 | 418 | ||
415 | qDebug("KLibLoader::library could not find library: %s", libname.data()); | 419 | qDebug("KLibLoader::library could not find library: %s", libname.data()); |
416 | #endif | 420 | #endif |
417 | 421 | ||
418 | } | 422 | } |
419 | else | 423 | else |
420 | self()->d->errorMessage = QString::null; | 424 | self()->d->errorMessage = QString::null; |
421 | } | 425 | } |
426 | |||
427 | //qDebug("return libfile = %s ",libfile.latin1() ); | ||
422 | return libfile; | 428 | return libfile; |
423 | } | 429 | } |
424 | 430 | ||
425 | 431 | ||
426 | KLibrary* KLibLoader::globalLibrary( const char *name ) | 432 | KLibrary* KLibLoader::globalLibrary( const char *name ) |
427 | { | 433 | { |
428 | KLibrary *tmp; | 434 | KLibrary *tmp; |
429 | /*US | 435 | /*US |
430 | int olt_dlopen_flag = lt_dlopen_flag; | 436 | int olt_dlopen_flag = lt_dlopen_flag; |
431 | 437 | ||
432 | lt_dlopen_flag |= LT_GLOBAL; | 438 | lt_dlopen_flag |= LT_GLOBAL; |
433 | kdDebug(150) << "Loading the next library global with flag " | 439 | kdDebug(150) << "Loading the next library global with flag " |
434 | << lt_dlopen_flag | 440 | << lt_dlopen_flag |
435 | << "." << endl; | 441 | << "." << endl; |
436 | */ | 442 | */ |
437 | tmp = library(name); | 443 | tmp = library(name); |
438 | /*US | 444 | /*US |
439 | lt_dlopen_flag = olt_dlopen_flag; | 445 | lt_dlopen_flag = olt_dlopen_flag; |
440 | */ | 446 | */ |
441 | return tmp; | 447 | return tmp; |
442 | } | 448 | } |
443 | 449 | ||
444 | 450 | ||
445 | KLibrary* KLibLoader::library( const char *name ) | 451 | KLibrary* KLibLoader::library( const char *name ) |
446 | { | 452 | { |
447 | if (!name) | 453 | if (!name) |
448 | return 0; | 454 | return 0; |
449 | 455 | ||
450 | KLibWrapPrivate* wrap = m_libs[name]; | 456 | KLibWrapPrivate* wrap = m_libs[name]; |
451 | if (wrap) { | 457 | if (wrap) { |
452 | /* Nothing to do to load the library. */ | 458 | /* Nothing to do to load the library. */ |
453 | wrap->ref_count++; | 459 | wrap->ref_count++; |
454 | return wrap->lib; | 460 | return wrap->lib; |
455 | } | 461 | } |
456 | 462 | ||
457 | /* Test if this library was loaded at some time, but got | 463 | /* Test if this library was loaded at some time, but got |
458 | unloaded meanwhile, whithout being dlclose()'ed. */ | 464 | unloaded meanwhile, whithout being dlclose()'ed. */ |
459 | QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); | 465 | QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); |
460 | for (; it.current(); ++it) { | 466 | for (; it.current(); ++it) { |
461 | if (it.current()->name == name) | 467 | if (it.current()->name == name) |
462 | wrap = it.current(); | 468 | wrap = it.current(); |
463 | } | 469 | } |
464 | 470 | ||
465 | if (wrap) { | 471 | if (wrap) { |
466 | d->pending_close.removeRef(wrap); | 472 | d->pending_close.removeRef(wrap); |
467 | if (!wrap->lib) { | 473 | if (!wrap->lib) { |
468 | /* This lib only was in loaded_stack, but not in m_libs. */ | 474 | /* This lib only was in loaded_stack, but not in m_libs. */ |
469 | wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); | 475 | wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); |
470 | } | 476 | } |
471 | wrap->ref_count++; | 477 | wrap->ref_count++; |
472 | } else { | 478 | } else { |
473 | QString libfile = findLibrary( name ); | 479 | QString libfile = findLibrary( name ); |
474 | if ( libfile.isEmpty() ) | 480 | if ( libfile.isEmpty() ) |
475 | return 0; | 481 | return 0; |
476 | #ifdef DESKTOP_VERSION | 482 | #ifdef DESKTOP_VERSION |
477 | QLibrary *qlib = new QLibrary( libfile.latin1() ); | 483 | QLibrary *qlib = new QLibrary( libfile.latin1() ); |
478 | #else | 484 | #else |
479 | QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); | 485 | QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); |
480 | #endif | 486 | #endif |
481 | 487 | ||
482 | //US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); | 488 | //US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); |
483 | //US if ( !handle ) | 489 | //US if ( !handle ) |
484 | if ( !qlib ) | 490 | if ( !qlib ) |
485 | { | 491 | { |
486 | //US const char* errmsg = lt_dlerror(); | 492 | //US const char* errmsg = lt_dlerror(); |
487 | char* errmsg; | 493 | char* errmsg; |
488 | sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); | 494 | sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); |
489 | qDebug(errmsg); | 495 | qDebug(errmsg); |
490 | 496 | ||
491 | if(errmsg) | 497 | if(errmsg) |
492 | d->errorMessage = QString::fromLatin1(errmsg); | 498 | d->errorMessage = QString::fromLatin1(errmsg); |
493 | else | 499 | else |
494 | d->errorMessage = QString::null; | 500 | d->errorMessage = QString::null; |
495 | kdWarning(150) << "library=" << name << ": file=" << libfile << ": " << d->errorMessage << endl; | 501 | kdWarning(150) << "library=" << name << ": file=" << libfile << ": " << d->errorMessage << endl; |
496 | return 0; | 502 | return 0; |
497 | } | 503 | } |
498 | else | 504 | else |
499 | d->errorMessage = QString::null; | 505 | d->errorMessage = QString::null; |
500 | 506 | ||
501 | KLibrary *lib = new KLibrary( name, libfile, qlib ); | 507 | KLibrary *lib = new KLibrary( name, libfile, qlib ); |
502 | wrap = new KLibWrapPrivate(lib, qlib); | 508 | wrap = new KLibWrapPrivate(lib, qlib); |
503 | d->loaded_stack.prepend(wrap); | 509 | d->loaded_stack.prepend(wrap); |
504 | } | 510 | } |
505 | m_libs.insert( name, wrap ); | 511 | m_libs.insert( name, wrap ); |
506 | 512 | ||
507 | connect( wrap->lib, SIGNAL( destroyed() ), | 513 | connect( wrap->lib, SIGNAL( destroyed() ), |
508 | this, SLOT( slotLibraryDestroyed() ) ); | 514 | this, SLOT( slotLibraryDestroyed() ) ); |
509 | 515 | ||
510 | return wrap->lib; | 516 | return wrap->lib; |
511 | } | 517 | } |
512 | 518 | ||
513 | QString KLibLoader::lastErrorMessage() const | 519 | QString KLibLoader::lastErrorMessage() const |
514 | { | 520 | { |
515 | return d->errorMessage; | 521 | return d->errorMessage; |
516 | } | 522 | } |
517 | 523 | ||
518 | void KLibLoader::unloadLibrary( const char *libname ) | 524 | void KLibLoader::unloadLibrary( const char *libname ) |
519 | { | 525 | { |
520 | KLibWrapPrivate *wrap = m_libs[ libname ]; | 526 | KLibWrapPrivate *wrap = m_libs[ libname ]; |
521 | if (!wrap) | 527 | if (!wrap) |
522 | return; | 528 | return; |
523 | if (--wrap->ref_count) | 529 | if (--wrap->ref_count) |
524 | return; | 530 | return; |
525 | 531 | ||
526 | // kdDebug(150) << "closing library " << libname << endl; | 532 | // kdDebug(150) << "closing library " << libname << endl; |
527 | 533 | ||
528 | m_libs.remove( libname ); | 534 | m_libs.remove( libname ); |
529 | 535 | ||
530 | disconnect( wrap->lib, SIGNAL( destroyed() ), | 536 | disconnect( wrap->lib, SIGNAL( destroyed() ), |
531 | this, SLOT( slotLibraryDestroyed() ) ); | 537 | this, SLOT( slotLibraryDestroyed() ) ); |
532 | close_pending( wrap ); | 538 | close_pending( wrap ); |
533 | } | 539 | } |
534 | 540 | ||
535 | KLibFactory* KLibLoader::factory( const char* name ) | 541 | KLibFactory* KLibLoader::factory( const char* name ) |
536 | { | 542 | { |
537 | KLibrary* lib = library( name ); | 543 | KLibrary* lib = library( name ); |
538 | if ( !lib ) | 544 | if ( !lib ) |
539 | return 0; | 545 | return 0; |
540 | 546 | ||
541 | return lib->factory(); | 547 | return lib->factory(); |
542 | } | 548 | } |
543 | 549 | ||
544 | void KLibLoader::slotLibraryDestroyed() | 550 | void KLibLoader::slotLibraryDestroyed() |
545 | { | 551 | { |
546 | const KLibrary *lib = static_cast<const KLibrary *>( sender() ); | 552 | const KLibrary *lib = static_cast<const KLibrary *>( sender() ); |
547 | 553 | ||
548 | QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); | 554 | QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); |
549 | for (; it.current(); ++it ) | 555 | for (; it.current(); ++it ) |
550 | if ( it.current()->lib == lib ) | 556 | if ( it.current()->lib == lib ) |
551 | { | 557 | { |
552 | KLibWrapPrivate *wrap = it.current(); | 558 | KLibWrapPrivate *wrap = it.current(); |
553 | wrap->lib = 0; /* the KLibrary object is already away */ | 559 | wrap->lib = 0; /* the KLibrary object is already away */ |
554 | m_libs.remove( it.currentKey() ); | 560 | m_libs.remove( it.currentKey() ); |
555 | close_pending( wrap ); | 561 | close_pending( wrap ); |
556 | return; | 562 | return; |
557 | } | 563 | } |
558 | } | 564 | } |
559 | 565 | ||
560 | void KLibLoader::close_pending(KLibWrapPrivate *wrap) | 566 | void KLibLoader::close_pending(KLibWrapPrivate *wrap) |
561 | { | 567 | { |
562 | if (wrap && !d->pending_close.containsRef( wrap )) | 568 | if (wrap && !d->pending_close.containsRef( wrap )) |
563 | d->pending_close.append( wrap ); | 569 | d->pending_close.append( wrap ); |
564 | 570 | ||
565 | /* First delete all KLibrary objects in pending_close, but _don't_ unload | 571 | /* First delete all KLibrary objects in pending_close, but _don't_ unload |
566 | the DSO behind it. */ | 572 | the DSO behind it. */ |
567 | QPtrListIterator<KLibWrapPrivate> it(d->pending_close); | 573 | QPtrListIterator<KLibWrapPrivate> it(d->pending_close); |
568 | for (; it.current(); ++it) { | 574 | for (; it.current(); ++it) { |
569 | wrap = it.current(); | 575 | wrap = it.current(); |
570 | if (wrap->lib) { | 576 | if (wrap->lib) { |
571 | disconnect( wrap->lib, SIGNAL( destroyed() ), | 577 | disconnect( wrap->lib, SIGNAL( destroyed() ), |
572 | this, SLOT( slotLibraryDestroyed() ) ); | 578 | this, SLOT( slotLibraryDestroyed() ) ); |
573 | delete wrap->lib; | 579 | delete wrap->lib; |
574 | wrap->lib = 0; | 580 | wrap->lib = 0; |
575 | } | 581 | } |
576 | } | 582 | } |
577 | 583 | ||
578 | if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return; | 584 | if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return; |
579 | 585 | ||
580 | bool deleted_one = false; | 586 | bool deleted_one = false; |
581 | while ((wrap = d->loaded_stack.first())) { | 587 | while ((wrap = d->loaded_stack.first())) { |
582 | /* Let's first see, if we want to try to unload this lib. | 588 | /* Let's first see, if we want to try to unload this lib. |
583 | If the env. var KDE_DOUNLOAD is set, we try to unload every lib. | 589 | If the env. var KDE_DOUNLOAD is set, we try to unload every lib. |
584 | If not, we look at the lib itself, and unload it only, if it exports | 590 | If not, we look at the lib itself, and unload it only, if it exports |
585 | the symbol __kde_do_unload. */ | 591 | the symbol __kde_do_unload. */ |
586 | if (d->unload_mode != KLibLoaderPrivate::UNLOAD | 592 | if (d->unload_mode != KLibLoaderPrivate::UNLOAD |
587 | && wrap->unload_mode != KLibWrapPrivate::UNLOAD) | 593 | && wrap->unload_mode != KLibWrapPrivate::UNLOAD) |
588 | break; | 594 | break; |
589 | 595 | ||
590 | /* Now ensure, that the libs are only unloaded in the reverse direction | 596 | /* Now ensure, that the libs are only unloaded in the reverse direction |
591 | they were loaded. */ | 597 | they were loaded. */ |
592 | if (!d->pending_close.containsRef( wrap )) { | 598 | if (!d->pending_close.containsRef( wrap )) { |
593 | if (!deleted_one) | 599 | if (!deleted_one) |
594 | /* Only diagnose, if we really haven't deleted anything. */ | 600 | /* Only diagnose, if we really haven't deleted anything. */ |
595 | // kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; | 601 | // kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; |
596 | break; | 602 | break; |
597 | } | 603 | } |
598 | 604 | ||
599 | // kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; | 605 | // kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; |
600 | 606 | ||
601 | #if 0 | 607 | #if 0 |
602 | #ifndef Q_WS_QWS | 608 | #ifndef Q_WS_QWS |
603 | if ( !deleted_one ) { | 609 | if ( !deleted_one ) { |
604 | /* Only do the hack once in this loop. | 610 | /* Only do the hack once in this loop. |
605 | WABA: *HACK* | 611 | WABA: *HACK* |
606 | We need to make sure to clear the clipboard before unloading a DSO | 612 | We need to make sure to clear the clipboard before unloading a DSO |
607 | because the DSO could have defined an object derived from QMimeSource | 613 | because the DSO could have defined an object derived from QMimeSource |
608 | and placed that on the clipboard. */ | 614 | and placed that on the clipboard. */ |
609 | /*kapp->clipboard()->clear();*/ | 615 | /*kapp->clipboard()->clear();*/ |
610 | 616 | ||
611 | /* Well.. let's do something more subtle... convert the clipboard context | 617 | /* Well.. let's do something more subtle... convert the clipboard context |
612 | to text. That should be safe as it only uses objects defined by Qt. */ | 618 | to text. That should be safe as it only uses objects defined by Qt. */ |
613 | 619 | ||
614 | QWidgetList *widgetlist = QApplication::topLevelWidgets(); | 620 | QWidgetList *widgetlist = QApplication::topLevelWidgets(); |
615 | QWidget *co = widgetlist->first(); | 621 | QWidget *co = widgetlist->first(); |
616 | while (co) { | 622 | while (co) { |
617 | if (qstrcmp(co->name(), "internal clipboard owner") == 0) { | 623 | if (qstrcmp(co->name(), "internal clipboard owner") == 0) { |
618 | if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId()) | 624 | if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId()) |
619 | kapp->clipboard()->setText(kapp->clipboard()->text()); | 625 | kapp->clipboard()->setText(kapp->clipboard()->text()); |
620 | 626 | ||
621 | break; | 627 | break; |
622 | } | 628 | } |
623 | co = widgetlist->next(); | 629 | co = widgetlist->next(); |
624 | } | 630 | } |
625 | delete widgetlist; | 631 | delete widgetlist; |
626 | } | 632 | } |
627 | #else | 633 | #else |
628 | // FIXME(E): Implement in Qt Embedded | 634 | // FIXME(E): Implement in Qt Embedded |
629 | #endif | 635 | #endif |
630 | 636 | ||
631 | #endif // 0 | 637 | #endif // 0 |
632 | deleted_one = true; | 638 | deleted_one = true; |
633 | //US lt_dlclose(wrap->handle); | 639 | //US lt_dlclose(wrap->handle); |
634 | wrap->handle->unload(); | 640 | wrap->handle->unload(); |
635 | 641 | ||
636 | d->pending_close.removeRef(wrap); | 642 | d->pending_close.removeRef(wrap); |
637 | /* loaded_stack is AutoDelete, so wrap is freed */ | 643 | /* loaded_stack is AutoDelete, so wrap is freed */ |
638 | d->loaded_stack.remove(); | 644 | d->loaded_stack.remove(); |
639 | } | 645 | } |
640 | } | 646 | } |
641 | 647 | ||
642 | void KLibLoader::virtual_hook( int, void* ) | 648 | void KLibLoader::virtual_hook( int, void* ) |
643 | { /*BASE::virtual_hook( id, data );*/ } | 649 | { /*BASE::virtual_hook( id, data );*/ } |
644 | 650 | ||
645 | void KLibFactory::virtual_hook( int, void* ) | 651 | void KLibFactory::virtual_hook( int, void* ) |
646 | { /*BASE::virtual_hook( id, data );*/ } | 652 | { /*BASE::virtual_hook( id, data );*/ } |
647 | 653 | ||
648 | //US #include "klibloader.moc" | 654 | //US #include "klibloader.moc" |
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index 7f51d78..e1c78f6 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp | |||
@@ -1,617 +1,627 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> | 2 | Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> |
3 | Copyright (C) 1999 Stephan Kulow <coolo@kde.org> | 3 | Copyright (C) 1999 Stephan Kulow <coolo@kde.org> |
4 | Copyright (C) 1999 Waldo Bastian <bastian@kde.org> | 4 | Copyright (C) 1999 Waldo Bastian <bastian@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License version 2 as published by the Free Software Foundation. | 8 | License version 2 as published by the Free Software Foundation. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> | 22 | * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> |
23 | * Version:$Id$ | 23 | * Version:$Id$ |
24 | * Generated:Thu Mar 5 16:05:28 EST 1998 | 24 | * Generated:Thu Mar 5 16:05:28 EST 1998 |
25 | */ | 25 | */ |
26 | 26 | ||
27 | //US #include "config.h" | 27 | //US #include "config.h" |
28 | 28 | ||
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include <assert.h> | 30 | #include <assert.h> |
31 | //US#include <errno.h> | 31 | //US#include <errno.h> |
32 | //US #ifdef HAVE_SYS_STAT_H | 32 | //US #ifdef HAVE_SYS_STAT_H |
33 | //US #include <sys/stat.h> | 33 | //US #include <sys/stat.h> |
34 | //US #endif | 34 | //US #endif |
35 | //US#include <sys/types.h> | 35 | //US#include <sys/types.h> |
36 | //US#include <dirent.h> | 36 | //US#include <dirent.h> |
37 | //US#include <pwd.h> | 37 | //US#include <pwd.h> |
38 | 38 | ||
39 | #include <qregexp.h> | 39 | #include <qregexp.h> |
40 | #include <qasciidict.h> | 40 | #include <qasciidict.h> |
41 | #include <qdict.h> | 41 | #include <qdict.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qfileinfo.h> | 43 | #include <qfileinfo.h> |
44 | #include <qstring.h> | 44 | #include <qstring.h> |
45 | #include <qapplication.h> | ||
46 | |||
45 | #include <qstringlist.h> | 47 | #include <qstringlist.h> |
46 | 48 | ||
47 | #include "kstandarddirs.h" | 49 | #include "kstandarddirs.h" |
48 | #include "kconfig.h" | 50 | #include "kconfig.h" |
49 | #include "kdebug.h" | 51 | #include "kdebug.h" |
50 | //US #include "kinstance.h" | 52 | //US #include "kinstance.h" |
51 | #include "kshell.h" | 53 | #include "kshell.h" |
52 | //US#include <sys/param.h> | 54 | //US#include <sys/param.h> |
53 | //US#include <unistd.h> | 55 | //US#include <unistd.h> |
54 | 56 | ||
55 | //US | 57 | //US |
56 | QString KStandardDirs::mAppDir = QString::null; | 58 | QString KStandardDirs::mAppDir = QString::null; |
57 | 59 | ||
58 | 60 | ||
59 | template class QDict<QStringList>; | 61 | template class QDict<QStringList>; |
60 | 62 | ||
61 | #if 0 | 63 | #if 0 |
62 | #include <qtextedit.h> | 64 | #include <qtextedit.h> |
63 | void ddd( QString op ) | 65 | void ddd( QString op ) |
64 | { | 66 | { |
65 | static QTextEdit * dot = 0; | 67 | static QTextEdit * dot = 0; |
66 | if ( ! dot ) | 68 | if ( ! dot ) |
67 | dot = new QTextEdit(); | 69 | dot = new QTextEdit(); |
68 | 70 | ||
69 | dot->show(); | 71 | dot->show(); |
70 | 72 | ||
71 | dot->append( op ); | 73 | dot->append( op ); |
72 | 74 | ||
73 | } | 75 | } |
74 | #endif | 76 | #endif |
75 | class KStandardDirs::KStandardDirsPrivate | 77 | class KStandardDirs::KStandardDirsPrivate |
76 | { | 78 | { |
77 | public: | 79 | public: |
78 | KStandardDirsPrivate() | 80 | KStandardDirsPrivate() |
79 | : restrictionsActive(false), | 81 | : restrictionsActive(false), |
80 | dataRestrictionActive(false) | 82 | dataRestrictionActive(false) |
81 | { } | 83 | { } |
82 | 84 | ||
83 | bool restrictionsActive; | 85 | bool restrictionsActive; |
84 | bool dataRestrictionActive; | 86 | bool dataRestrictionActive; |
85 | QAsciiDict<bool> restrictions; | 87 | QAsciiDict<bool> restrictions; |
86 | QStringList xdgdata_prefixes; | 88 | QStringList xdgdata_prefixes; |
87 | QStringList xdgconf_prefixes; | 89 | QStringList xdgconf_prefixes; |
88 | }; | 90 | }; |
89 | 91 | ||
90 | static const char* const types[] = {"html", "icon", "apps", "sound", | 92 | static const char* const types[] = {"html", "icon", "apps", "sound", |
91 | "data", "locale", "services", "mime", | 93 | "data", "locale", "services", "mime", |
92 | "servicetypes", "config", "exe", | 94 | "servicetypes", "config", "exe", |
93 | "wallpaper", "lib", "pixmap", "templates", | 95 | "wallpaper", "lib", "pixmap", "templates", |
94 | "module", "qtplugins", | 96 | "module", "qtplugins", |
95 | "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; | 97 | "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; |
96 | 98 | ||
97 | static int tokenize( QStringList& token, const QString& str, | 99 | static int tokenize( QStringList& token, const QString& str, |
98 | const QString& delim ); | 100 | const QString& delim ); |
99 | 101 | ||
100 | KStandardDirs::KStandardDirs( ) : addedCustoms(false) | 102 | KStandardDirs::KStandardDirs( ) : addedCustoms(false) |
101 | { | 103 | { |
102 | d = new KStandardDirsPrivate; | 104 | d = new KStandardDirsPrivate; |
103 | dircache.setAutoDelete(true); | 105 | dircache.setAutoDelete(true); |
104 | relatives.setAutoDelete(true); | 106 | relatives.setAutoDelete(true); |
105 | absolutes.setAutoDelete(true); | 107 | absolutes.setAutoDelete(true); |
106 | savelocations.setAutoDelete(true); | 108 | savelocations.setAutoDelete(true); |
107 | addKDEDefaults(); | 109 | addKDEDefaults(); |
108 | } | 110 | } |
109 | 111 | ||
110 | KStandardDirs::~KStandardDirs() | 112 | KStandardDirs::~KStandardDirs() |
111 | { | 113 | { |
112 | delete d; | 114 | delete d; |
113 | } | 115 | } |
114 | 116 | ||
115 | bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const | 117 | bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const |
116 | { | 118 | { |
117 | if (!d || !d->restrictionsActive) | 119 | if (!d || !d->restrictionsActive) |
118 | return false; | 120 | return false; |
119 | 121 | ||
120 | if (d->restrictions[type]) | 122 | if (d->restrictions[type]) |
121 | return true; | 123 | return true; |
122 | 124 | ||
123 | if (strcmp(type, "data")==0) | 125 | if (strcmp(type, "data")==0) |
124 | { | 126 | { |
125 | applyDataRestrictions(relPath); | 127 | applyDataRestrictions(relPath); |
126 | if (d->dataRestrictionActive) | 128 | if (d->dataRestrictionActive) |
127 | { | 129 | { |
128 | d->dataRestrictionActive = false; | 130 | d->dataRestrictionActive = false; |
129 | return true; | 131 | return true; |
130 | } | 132 | } |
131 | } | 133 | } |
132 | return false; | 134 | return false; |
133 | } | 135 | } |
134 | 136 | ||
135 | void KStandardDirs::applyDataRestrictions(const QString &relPath) const | 137 | void KStandardDirs::applyDataRestrictions(const QString &relPath) const |
136 | { | 138 | { |
137 | QString key; | 139 | QString key; |
138 | int i = relPath.find('/'); | 140 | int i = relPath.find('/'); |
139 | if (i != -1) | 141 | if (i != -1) |
140 | key = "data_"+relPath.left(i); | 142 | key = "data_"+relPath.left(i); |
141 | else | 143 | else |
142 | key = "data_"+relPath; | 144 | key = "data_"+relPath; |
143 | 145 | ||
144 | if (d && d->restrictions[key.latin1()]) | 146 | if (d && d->restrictions[key.latin1()]) |
145 | d->dataRestrictionActive = true; | 147 | d->dataRestrictionActive = true; |
146 | } | 148 | } |
147 | 149 | ||
148 | 150 | ||
149 | QStringList KStandardDirs::allTypes() const | 151 | QStringList KStandardDirs::allTypes() const |
150 | { | 152 | { |
151 | QStringList list; | 153 | QStringList list; |
152 | for (int i = 0; types[i] != 0; ++i) | 154 | for (int i = 0; types[i] != 0; ++i) |
153 | list.append(QString::fromLatin1(types[i])); | 155 | list.append(QString::fromLatin1(types[i])); |
154 | return list; | 156 | return list; |
155 | } | 157 | } |
156 | 158 | ||
157 | void KStandardDirs::addPrefix( const QString& _dir ) | 159 | void KStandardDirs::addPrefix( const QString& _dir ) |
158 | { | 160 | { |
159 | if (_dir.isNull()) | 161 | if (_dir.isNull()) |
160 | return; | 162 | return; |
161 | 163 | ||
162 | QString dir = _dir; | 164 | QString dir = _dir; |
163 | if (dir.at(dir.length() - 1) != '/') | 165 | if (dir.at(dir.length() - 1) != '/') |
164 | dir += '/'; | 166 | dir += '/'; |
165 | 167 | ||
166 | if (!prefixes.contains(dir)) { | 168 | if (!prefixes.contains(dir)) { |
167 | prefixes.append(dir); | 169 | prefixes.append(dir); |
168 | dircache.clear(); | 170 | dircache.clear(); |
169 | } | 171 | } |
170 | } | 172 | } |
171 | 173 | ||
172 | void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) | 174 | void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) |
173 | { | 175 | { |
174 | if (_dir.isNull()) | 176 | if (_dir.isNull()) |
175 | return; | 177 | return; |
176 | 178 | ||
177 | QString dir = _dir; | 179 | QString dir = _dir; |
178 | if (dir.at(dir.length() - 1) != '/') | 180 | if (dir.at(dir.length() - 1) != '/') |
179 | dir += '/'; | 181 | dir += '/'; |
180 | 182 | ||
181 | if (!d->xdgconf_prefixes.contains(dir)) { | 183 | if (!d->xdgconf_prefixes.contains(dir)) { |
182 | d->xdgconf_prefixes.append(dir); | 184 | d->xdgconf_prefixes.append(dir); |
183 | dircache.clear(); | 185 | dircache.clear(); |
184 | } | 186 | } |
185 | } | 187 | } |
186 | 188 | ||
187 | void KStandardDirs::addXdgDataPrefix( const QString& _dir ) | 189 | void KStandardDirs::addXdgDataPrefix( const QString& _dir ) |
188 | { | 190 | { |
189 | if (_dir.isNull()) | 191 | if (_dir.isNull()) |
190 | return; | 192 | return; |
191 | 193 | ||
192 | QString dir = _dir; | 194 | QString dir = _dir; |
193 | if (dir.at(dir.length() - 1) != '/') | 195 | if (dir.at(dir.length() - 1) != '/') |
194 | dir += '/'; | 196 | dir += '/'; |
195 | 197 | ||
196 | if (!d->xdgdata_prefixes.contains(dir)) { | 198 | if (!d->xdgdata_prefixes.contains(dir)) { |
197 | d->xdgdata_prefixes.append(dir); | 199 | d->xdgdata_prefixes.append(dir); |
198 | dircache.clear(); | 200 | dircache.clear(); |
199 | } | 201 | } |
200 | } | 202 | } |
201 | 203 | ||
202 | 204 | ||
203 | QString KStandardDirs::kfsstnd_prefixes() | 205 | QString KStandardDirs::kfsstnd_prefixes() |
204 | { | 206 | { |
205 | return prefixes.join(":"); | 207 | return prefixes.join(":"); |
206 | } | 208 | } |
207 | 209 | ||
208 | bool KStandardDirs::addResourceType( const char *type, | 210 | bool KStandardDirs::addResourceType( const char *type, |
209 | const QString& relativename ) | 211 | const QString& relativename ) |
210 | { | 212 | { |
211 | if (relativename.isNull()) | 213 | if (relativename.isNull()) |
212 | return false; | 214 | return false; |
213 | 215 | ||
214 | QStringList *rels = relatives.find(type); | 216 | QStringList *rels = relatives.find(type); |
215 | if (!rels) { | 217 | if (!rels) { |
216 | rels = new QStringList(); | 218 | rels = new QStringList(); |
217 | relatives.insert(type, rels); | 219 | relatives.insert(type, rels); |
218 | } | 220 | } |
219 | QString copy = relativename; | 221 | QString copy = relativename; |
220 | if (copy.at(copy.length() - 1) != '/') | 222 | if (copy.at(copy.length() - 1) != '/') |
221 | copy += '/'; | 223 | copy += '/'; |
222 | if (!rels->contains(copy)) { | 224 | if (!rels->contains(copy)) { |
223 | rels->prepend(copy); | 225 | rels->prepend(copy); |
224 | dircache.remove(type); // clean the cache | 226 | dircache.remove(type); // clean the cache |
225 | return true; | 227 | return true; |
226 | } | 228 | } |
227 | return false; | 229 | return false; |
228 | } | 230 | } |
229 | 231 | ||
230 | bool KStandardDirs::addResourceDir( const char *type, | 232 | bool KStandardDirs::addResourceDir( const char *type, |
231 | const QString& absdir) | 233 | const QString& absdir) |
232 | { | 234 | { |
233 | QStringList *paths = absolutes.find(type); | 235 | QStringList *paths = absolutes.find(type); |
234 | if (!paths) { | 236 | if (!paths) { |
235 | paths = new QStringList(); | 237 | paths = new QStringList(); |
236 | absolutes.insert(type, paths); | 238 | absolutes.insert(type, paths); |
237 | } | 239 | } |
238 | QString copy = absdir; | 240 | QString copy = absdir; |
239 | if (copy.at(copy.length() - 1) != '/') | 241 | if (copy.at(copy.length() - 1) != '/') |
240 | copy += '/'; | 242 | copy += '/'; |
241 | 243 | ||
242 | if (!paths->contains(copy)) { | 244 | if (!paths->contains(copy)) { |
243 | paths->append(copy); | 245 | paths->append(copy); |
244 | dircache.remove(type); // clean the cache | 246 | dircache.remove(type); // clean the cache |
245 | return true; | 247 | return true; |
246 | } | 248 | } |
247 | return false; | 249 | return false; |
248 | } | 250 | } |
249 | 251 | ||
250 | QString KStandardDirs::findResource( const char *type, | 252 | QString KStandardDirs::findResource( const char *type, |
251 | const QString& filename ) const | 253 | const QString& filename ) const |
252 | { | 254 | { |
253 | if (filename.at(0) == '/') | 255 | if (filename.at(0) == '/') |
254 | return filename; // absolute dirs are absolute dirs, right? :-/ | 256 | return filename; // absolute dirs are absolute dirs, right? :-/ |
255 | 257 | ||
256 | #if 0 | 258 | #if 0 |
257 | kdDebug() << "Find resource: " << type << endl; | 259 | kdDebug() << "Find resource: " << type << endl; |
258 | for (QStringList::ConstIterator pit = prefixes.begin(); | 260 | for (QStringList::ConstIterator pit = prefixes.begin(); |
259 | pit != prefixes.end(); | 261 | pit != prefixes.end(); |
260 | pit++) | 262 | pit++) |
261 | { | 263 | { |
262 | kdDebug() << "Prefix: " << *pit << endl; | 264 | kdDebug() << "Prefix: " << *pit << endl; |
263 | } | 265 | } |
264 | #endif | 266 | #endif |
265 | 267 | ||
266 | QString dir = findResourceDir(type, filename); | 268 | QString dir = findResourceDir(type, filename); |
267 | if (dir.isNull()) | 269 | if (dir.isNull()) |
268 | return dir; | 270 | return dir; |
269 | else return dir + filename; | 271 | else return dir + filename; |
270 | } | 272 | } |
271 | /*US | 273 | /*US |
272 | static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash) | 274 | static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash) |
273 | { | 275 | { |
274 | QCString cFile = QFile::encodeName(file); | 276 | QCString cFile = QFile::encodeName(file); |
275 | //US struct stat buff; | 277 | //US struct stat buff; |
276 | //US if ((access(cFile, R_OK) == 0) && | 278 | //US if ((access(cFile, R_OK) == 0) && |
277 | //US (stat( cFile, &buff ) == 0) && | 279 | //US (stat( cFile, &buff ) == 0) && |
278 | //US (S_ISREG( buff.st_mode ))) | 280 | //US (S_ISREG( buff.st_mode ))) |
279 | QFileInfo pathfnInfo(cFile); | 281 | QFileInfo pathfnInfo(cFile); |
280 | if (( pathfnInfo.isReadable() == true ) && | 282 | if (( pathfnInfo.isReadable() == true ) && |
281 | ( pathfnInfo.isFile()) ) | 283 | ( pathfnInfo.isFile()) ) |
282 | { | 284 | { |
283 | //US hash = hash + (Q_UINT32) buff.st_ctime; | 285 | //US hash = hash + (Q_UINT32) buff.st_ctime; |
284 | hash = hash + (Q_UINT32) pathfnInfo.lastModified(); | 286 | hash = hash + (Q_UINT32) pathfnInfo.lastModified(); |
285 | } | 287 | } |
286 | return hash; | 288 | return hash; |
287 | } | 289 | } |
288 | */ | 290 | */ |
289 | /*US | 291 | /*US |
290 | Q_UINT32 KStandardDirs::calcResourceHash( const char *type, | 292 | Q_UINT32 KStandardDirs::calcResourceHash( const char *type, |
291 | const QString& filename, bool deep) const | 293 | const QString& filename, bool deep) const |
292 | { | 294 | { |
293 | Q_UINT32 hash = 0; | 295 | Q_UINT32 hash = 0; |
294 | 296 | ||
295 | if (filename.at(0) == '/') | 297 | if (filename.at(0) == '/') |
296 | { | 298 | { |
297 | // absolute dirs are absolute dirs, right? :-/ | 299 | // absolute dirs are absolute dirs, right? :-/ |
298 | return updateHash(filename, hash); | 300 | return updateHash(filename, hash); |
299 | } | 301 | } |
300 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) | 302 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) |
301 | applyDataRestrictions(filename); | 303 | applyDataRestrictions(filename); |
302 | QStringList candidates = resourceDirs(type); | 304 | QStringList candidates = resourceDirs(type); |
303 | QString fullPath; | 305 | QString fullPath; |
304 | 306 | ||
305 | for (QStringList::ConstIterator it = candidates.begin(); | 307 | for (QStringList::ConstIterator it = candidates.begin(); |
306 | it != candidates.end(); it++) | 308 | it != candidates.end(); it++) |
307 | { | 309 | { |
308 | hash = updateHash(*it + filename, hash); | 310 | hash = updateHash(*it + filename, hash); |
309 | if (!deep && hash) | 311 | if (!deep && hash) |
310 | return hash; | 312 | return hash; |
311 | } | 313 | } |
312 | return hash; | 314 | return hash; |
313 | } | 315 | } |
314 | */ | 316 | */ |
315 | 317 | ||
316 | QStringList KStandardDirs::findDirs( const char *type, | 318 | QStringList KStandardDirs::findDirs( const char *type, |
317 | const QString& reldir ) const | 319 | const QString& reldir ) const |
318 | { | 320 | { |
319 | QStringList list; | 321 | QStringList list; |
320 | 322 | ||
321 | checkConfig(); | 323 | checkConfig(); |
322 | 324 | ||
323 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) | 325 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) |
324 | applyDataRestrictions(reldir); | 326 | applyDataRestrictions(reldir); |
325 | QStringList candidates = resourceDirs(type); | 327 | QStringList candidates = resourceDirs(type); |
326 | QDir testdir; | 328 | QDir testdir; |
327 | 329 | ||
328 | for (QStringList::ConstIterator it = candidates.begin(); | 330 | for (QStringList::ConstIterator it = candidates.begin(); |
329 | it != candidates.end(); it++) { | 331 | it != candidates.end(); it++) { |
330 | testdir.setPath(*it + reldir); | 332 | testdir.setPath(*it + reldir); |
331 | if (testdir.exists()) | 333 | if (testdir.exists()) |
332 | list.append(testdir.absPath() + '/'); | 334 | list.append(testdir.absPath() + '/'); |
333 | } | 335 | } |
334 | 336 | ||
335 | return list; | 337 | return list; |
336 | } | 338 | } |
337 | 339 | ||
338 | QString KStandardDirs::findResourceDir( const char *type, | 340 | QString KStandardDirs::findResourceDir( const char *type, |
339 | const QString& filename) const | 341 | const QString& filename) const |
340 | { | 342 | { |
341 | #ifndef NDEBUG | 343 | #ifndef NDEBUG |
342 | if (filename.isEmpty()) { | 344 | if (filename.isEmpty()) { |
343 | kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl; | 345 | kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl; |
344 | return QString::null; | 346 | return QString::null; |
345 | } | 347 | } |
346 | #endif | 348 | #endif |
347 | 349 | ||
348 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) | 350 | if (d && d->restrictionsActive && (strcmp(type, "data")==0)) |
349 | applyDataRestrictions(filename); | 351 | applyDataRestrictions(filename); |
350 | QStringList candidates = resourceDirs(type); | 352 | QStringList candidates = resourceDirs(type); |
351 | QString fullPath; | 353 | QString fullPath; |
352 | 354 | #ifdef DESKTOP_VERSION | |
355 | #ifdef _WIN32_ | ||
356 | candidates.prepend( qApp->applicationDirPath () +"\\"); | ||
357 | #else | ||
358 | candidates.prepend( qApp->applicationDirPath () +"/"); | ||
359 | #endif | ||
360 | #endif | ||
353 | for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) | 361 | for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) |
354 | { | 362 | { |
363 | //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1()); | ||
355 | if (exists(*it + filename)) | 364 | if (exists(*it + filename)) |
356 | return *it; | 365 | return *it; |
357 | } | 366 | } |
358 | 367 | ||
359 | #ifndef NDEBUG | 368 | #ifndef NDEBUG |
360 | if(false && type != "locale") | 369 | if(false && type != "locale") |
361 | kdDebug() << "KStdDirs::findResDir(): can't find \"" << filename << "\" in type \"" << type << "\"." << endl; | 370 | qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1()); |
371 | |||
362 | #endif | 372 | #endif |
363 | 373 | ||
364 | return QString::null; | 374 | return QString::null; |
365 | } | 375 | } |
366 | 376 | ||
367 | bool KStandardDirs::exists(const QString &fullPath) | 377 | bool KStandardDirs::exists(const QString &fullPath) |
368 | { | 378 | { |
369 | //US struct stat buff; | 379 | //US struct stat buff; |
370 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); | 380 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); |
371 | 381 | ||
372 | //US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) | 382 | //US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) |
373 | if (fullPathInfo.isReadable()) | 383 | if (fullPathInfo.isReadable()) |
374 | { | 384 | { |
375 | if (fullPath.at(fullPath.length() - 1) != '/') { | 385 | if (fullPath.at(fullPath.length() - 1) != '/') { |
376 | //US if (S_ISREG( buff.st_mode )) | 386 | //US if (S_ISREG( buff.st_mode )) |
377 | if (fullPathInfo.isFile()) | 387 | if (fullPathInfo.isFile()) |
378 | return true; | 388 | return true; |
379 | } | 389 | } |
380 | else { | 390 | else { |
381 | //US if (S_ISDIR( buff.st_mode )) | 391 | //US if (S_ISDIR( buff.st_mode )) |
382 | if (fullPathInfo.isDir()) | 392 | if (fullPathInfo.isDir()) |
383 | return true; | 393 | return true; |
384 | } | 394 | } |
385 | } | 395 | } |
386 | return false; | 396 | return false; |
387 | } | 397 | } |
388 | 398 | ||
389 | static void lookupDirectory(const QString& path, const QString &relPart, | 399 | static void lookupDirectory(const QString& path, const QString &relPart, |
390 | const QRegExp ®exp, | 400 | const QRegExp ®exp, |
391 | QStringList& list, | 401 | QStringList& list, |
392 | QStringList& relList, | 402 | QStringList& relList, |
393 | bool recursive, bool uniq) | 403 | bool recursive, bool uniq) |
394 | { | 404 | { |
395 | QString pattern = regexp.pattern(); | 405 | QString pattern = regexp.pattern(); |
396 | if (recursive || pattern.contains('?') || pattern.contains('*')) | 406 | if (recursive || pattern.contains('?') || pattern.contains('*')) |
397 | { | 407 | { |
398 | // We look for a set of files. | 408 | // We look for a set of files. |
399 | //US DIR *dp = opendir( QFile::encodeName(path)); | 409 | //US DIR *dp = opendir( QFile::encodeName(path)); |
400 | QDir dp(QFile::encodeName(path)); | 410 | QDir dp(QFile::encodeName(path)); |
401 | 411 | ||
402 | if (!dp.exists()) | 412 | if (!dp.exists()) |
403 | return; | 413 | return; |
404 | static int iii = 0; | 414 | static int iii = 0; |
405 | ++iii; | 415 | ++iii; |
406 | if ( iii == 5 ) | 416 | if ( iii == 5 ) |
407 | abort(); | 417 | abort(); |
408 | assert(path.at(path.length() - 1) == '/'); | 418 | assert(path.at(path.length() - 1) == '/'); |
409 | 419 | ||
410 | //US struct dirent *ep; | 420 | //US struct dirent *ep; |
411 | //US struct stat buff; | 421 | //US struct stat buff; |
412 | 422 | ||
413 | QString _dot("."); | 423 | QString _dot("."); |
414 | QString _dotdot(".."); | 424 | QString _dotdot(".."); |
415 | 425 | ||
416 | //US while( ( ep = readdir( dp ) ) != 0L ) | 426 | //US while( ( ep = readdir( dp ) ) != 0L ) |
417 | QStringList direntries = dp.entryList(); | 427 | QStringList direntries = dp.entryList(); |
418 | QStringList::Iterator it = direntries.begin(); | 428 | QStringList::Iterator it = direntries.begin(); |
419 | 429 | ||
420 | while ( it != list.end() ) // for each file... | 430 | while ( it != list.end() ) // for each file... |
421 | { | 431 | { |
422 | 432 | ||
423 | //US QString fn( QFile::decodeName(ep->d_name)); | 433 | //US QString fn( QFile::decodeName(ep->d_name)); |
424 | QString fn = (*it); // dp.entryList already decodes | 434 | QString fn = (*it); // dp.entryList already decodes |
425 | it++; | 435 | it++; |
426 | if ( fn.isNull() ) | 436 | if ( fn.isNull() ) |
427 | break; | 437 | break; |
428 | 438 | ||
429 | if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) | 439 | if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) |
430 | continue; | 440 | continue; |
431 | 441 | ||
432 | /*US | 442 | /*US |
433 | if (!recursive && !regexp.exactMatch(fn)) | 443 | if (!recursive && !regexp.exactMatch(fn)) |
434 | continue; // No match | 444 | continue; // No match |
435 | */ | 445 | */ |
436 | //US this should do the same: | 446 | //US this should do the same: |
437 | int pos = regexp.match(fn); | 447 | int pos = regexp.match(fn); |
438 | if (!recursive && !pos == 0) | 448 | if (!recursive && !pos == 0) |
439 | continue; // No match | 449 | continue; // No match |
440 | 450 | ||
441 | QString pathfn = path + fn; | 451 | QString pathfn = path + fn; |
442 | /*US | 452 | /*US |
443 | if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { | 453 | if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { |
444 | kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; | 454 | kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; |
445 | continue; // Couldn't stat (e.g. no read permissions) | 455 | continue; // Couldn't stat (e.g. no read permissions) |
446 | } | 456 | } |
447 | 457 | ||
448 | if ( recursive ) | 458 | if ( recursive ) |
449 | { | 459 | { |
450 | if ( S_ISDIR( buff.st_mode )) { | 460 | if ( S_ISDIR( buff.st_mode )) { |
451 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); | 461 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); |
452 | } | 462 | } |
453 | */ | 463 | */ |
454 | //US replacement: | 464 | //US replacement: |
455 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); | 465 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); |
456 | if ( pathfnInfo.isReadable() == false ) | 466 | if ( pathfnInfo.isReadable() == false ) |
457 | { | 467 | { |
458 | //US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; | 468 | //US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; |
459 | continue; // Couldn't stat (e.g. no read permissions) | 469 | continue; // Couldn't stat (e.g. no read permissions) |
460 | } | 470 | } |
461 | 471 | ||
462 | if ( recursive ) | 472 | if ( recursive ) |
463 | { | 473 | { |
464 | if ( pathfnInfo.isDir()) { | 474 | if ( pathfnInfo.isDir()) { |
465 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); | 475 | lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); |
466 | } | 476 | } |
467 | 477 | ||
468 | 478 | ||
469 | /*US | 479 | /*US |
470 | if (!regexp.exactMatch(fn)) | 480 | if (!regexp.exactMatch(fn)) |
471 | continue; // No match | 481 | continue; // No match |
472 | */ | 482 | */ |
473 | //US this should do the same: | 483 | //US this should do the same: |
474 | pos = regexp.match(fn); | 484 | pos = regexp.match(fn); |
475 | if (!pos == 0) | 485 | if (!pos == 0) |
476 | continue; // No match | 486 | continue; // No match |
477 | } | 487 | } |
478 | 488 | ||
479 | //US if ( S_ISREG( buff.st_mode)) | 489 | //US if ( S_ISREG( buff.st_mode)) |
480 | if ( pathfnInfo.isFile()) | 490 | if ( pathfnInfo.isFile()) |
481 | { | 491 | { |
482 | if (!uniq || !relList.contains(relPart + fn)) | 492 | if (!uniq || !relList.contains(relPart + fn)) |
483 | { | 493 | { |
484 | list.append( pathfn ); | 494 | list.append( pathfn ); |
485 | relList.append( relPart + fn ); | 495 | relList.append( relPart + fn ); |
486 | } | 496 | } |
487 | } | 497 | } |
488 | } | 498 | } |
489 | //US closedir( dp ); | 499 | //US closedir( dp ); |
490 | } | 500 | } |
491 | else | 501 | else |
492 | { | 502 | { |
493 | // We look for a single file. | 503 | // We look for a single file. |
494 | QString fn = pattern; | 504 | QString fn = pattern; |
495 | QString pathfn = path + fn; | 505 | QString pathfn = path + fn; |
496 | //US struct stat buff; | 506 | //US struct stat buff; |
497 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); | 507 | QFileInfo pathfnInfo(QFile::encodeName(pathfn)); |
498 | 508 | ||
499 | 509 | ||
500 | //US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) | 510 | //US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) |
501 | if ( pathfnInfo.isReadable() == false ) | 511 | if ( pathfnInfo.isReadable() == false ) |
502 | return; // File not found | 512 | return; // File not found |
503 | 513 | ||
504 | //US if ( S_ISREG( buff.st_mode)) | 514 | //US if ( S_ISREG( buff.st_mode)) |
505 | if ( pathfnInfo.isFile()) | 515 | if ( pathfnInfo.isFile()) |
506 | { | 516 | { |
507 | if (!uniq || !relList.contains(relPart + fn)) | 517 | if (!uniq || !relList.contains(relPart + fn)) |
508 | { | 518 | { |
509 | list.append( pathfn ); | 519 | list.append( pathfn ); |
510 | relList.append( relPart + fn ); | 520 | relList.append( relPart + fn ); |
511 | } | 521 | } |
512 | } | 522 | } |
513 | } | 523 | } |
514 | } | 524 | } |
515 | 525 | ||
516 | static void lookupPrefix(const QString& prefix, const QString& relpath, | 526 | static void lookupPrefix(const QString& prefix, const QString& relpath, |
517 | const QString& relPart, | 527 | const QString& relPart, |
518 | const QRegExp ®exp, | 528 | const QRegExp ®exp, |
519 | QStringList& list, | 529 | QStringList& list, |
520 | QStringList& relList, | 530 | QStringList& relList, |
521 | bool recursive, bool uniq) | 531 | bool recursive, bool uniq) |
522 | { | 532 | { |
523 | if (relpath.isNull()) { | 533 | if (relpath.isNull()) { |
524 | lookupDirectory(prefix, relPart, regexp, list, | 534 | lookupDirectory(prefix, relPart, regexp, list, |
525 | relList, recursive, uniq); | 535 | relList, recursive, uniq); |
526 | return; | 536 | return; |
527 | } | 537 | } |
528 | QString path; | 538 | QString path; |
529 | QString rest; | 539 | QString rest; |
530 | 540 | ||
531 | if (relpath.length()) | 541 | if (relpath.length()) |
532 | { | 542 | { |
533 | int slash = relpath.find('/'); | 543 | int slash = relpath.find('/'); |
534 | if (slash < 0) | 544 | if (slash < 0) |
535 | rest = relpath.left(relpath.length() - 1); | 545 | rest = relpath.left(relpath.length() - 1); |
536 | else { | 546 | else { |
537 | path = relpath.left(slash); | 547 | path = relpath.left(slash); |
538 | rest = relpath.mid(slash + 1); | 548 | rest = relpath.mid(slash + 1); |
539 | } | 549 | } |
540 | } | 550 | } |
541 | assert(prefix.at(prefix.length() - 1) == '/'); | 551 | assert(prefix.at(prefix.length() - 1) == '/'); |
542 | 552 | ||
543 | //US struct stat buff; | 553 | //US struct stat buff; |
544 | 554 | ||
545 | if (path.contains('*') || path.contains('?')) { | 555 | if (path.contains('*') || path.contains('?')) { |
546 | QRegExp pathExp(path, true, true); | 556 | QRegExp pathExp(path, true, true); |
547 | //USDIR *dp = opendir( QFile::encodeName(prefix) ); | 557 | //USDIR *dp = opendir( QFile::encodeName(prefix) ); |
548 | QDir dp(QFile::encodeName(prefix)); | 558 | QDir dp(QFile::encodeName(prefix)); |
549 | 559 | ||
550 | //USif (!dp) | 560 | //USif (!dp) |
551 | if (!dp.exists()) | 561 | if (!dp.exists()) |
552 | { | 562 | { |
553 | return; | 563 | return; |
554 | } | 564 | } |
555 | 565 | ||
556 | //USstruct dirent *ep; | 566 | //USstruct dirent *ep; |
557 | 567 | ||
558 | QString _dot("."); | 568 | QString _dot("."); |
559 | QString _dotdot(".."); | 569 | QString _dotdot(".."); |
560 | 570 | ||
561 | //USwhile( ( ep = readdir( dp ) ) != 0L ) | 571 | //USwhile( ( ep = readdir( dp ) ) != 0L ) |
562 | QStringList direntries = dp.entryList(); | 572 | QStringList direntries = dp.entryList(); |
563 | QStringList::Iterator it = direntries.begin(); | 573 | QStringList::Iterator it = direntries.begin(); |
564 | 574 | ||
565 | while ( it != list.end() ) // for each file... | 575 | while ( it != list.end() ) // for each file... |
566 | { | 576 | { |
567 | //US QString fn( QFile::decodeName(ep->d_name)); | 577 | //US QString fn( QFile::decodeName(ep->d_name)); |
568 | QString fn = (*it); // dp.entryList() already encodes the strings | 578 | QString fn = (*it); // dp.entryList() already encodes the strings |
569 | it++; | 579 | it++; |
570 | 580 | ||
571 | if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~') | 581 | if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~') |
572 | continue; | 582 | continue; |
573 | 583 | ||
574 | #ifdef DESKTOP_VERSION | 584 | #ifdef DESKTOP_VERSION |
575 | 585 | ||
576 | if (pathExp.search(fn) == -1) | 586 | if (pathExp.search(fn) == -1) |
577 | continue; // No match | 587 | continue; // No match |
578 | 588 | ||
579 | #else | 589 | #else |
580 | //US this should do the same: | 590 | //US this should do the same: |
581 | if (pathExp.find(fn, 0) == -1) | 591 | if (pathExp.find(fn, 0) == -1) |
582 | continue; // No match | 592 | continue; // No match |
583 | #endif | 593 | #endif |
584 | QString rfn = relPart+fn; | 594 | QString rfn = relPart+fn; |
585 | fn = prefix + fn; | 595 | fn = prefix + fn; |
586 | //US if ( stat( QFile::encodeName(fn), &buff ) != 0 ) | 596 | //US if ( stat( QFile::encodeName(fn), &buff ) != 0 ) |
587 | QFileInfo fnInfo(QFile::encodeName(fn)); | 597 | QFileInfo fnInfo(QFile::encodeName(fn)); |
588 | if ( fnInfo.isReadable() == false ) | 598 | if ( fnInfo.isReadable() == false ) |
589 | { | 599 | { |
590 | //US kdDebug() << "Error statting " << fn << " : " << perror << endl; | 600 | //US kdDebug() << "Error statting " << fn << " : " << perror << endl; |
591 | continue; // Couldn't stat (e.g. no permissions) | 601 | continue; // Couldn't stat (e.g. no permissions) |
592 | } | 602 | } |
593 | //US if ( S_ISDIR( buff.st_mode )) | 603 | //US if ( S_ISDIR( buff.st_mode )) |
594 | if ( fnInfo.isDir() ) | 604 | if ( fnInfo.isDir() ) |
595 | 605 | ||
596 | lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq); | 606 | lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq); |
597 | } | 607 | } |
598 | 608 | ||
599 | //USclosedir( dp ); | 609 | //USclosedir( dp ); |
600 | } else { | 610 | } else { |
601 | // Don't stat, if the dir doesn't exist we will find out | 611 | // Don't stat, if the dir doesn't exist we will find out |
602 | // when we try to open it. | 612 | // when we try to open it. |
603 | lookupPrefix(prefix + path + '/', rest, | 613 | lookupPrefix(prefix + path + '/', rest, |
604 | relPart + path + '/', regexp, list, | 614 | relPart + path + '/', regexp, list, |
605 | relList, recursive, uniq); | 615 | relList, recursive, uniq); |
606 | } | 616 | } |
607 | } | 617 | } |
608 | 618 | ||
609 | QStringList | 619 | QStringList |
610 | KStandardDirs::findAllResources( const char *type, | 620 | KStandardDirs::findAllResources( const char *type, |
611 | const QString& filter, | 621 | const QString& filter, |
612 | bool recursive, | 622 | bool recursive, |
613 | bool uniq, | 623 | bool uniq, |
614 | QStringList &relList) const | 624 | QStringList &relList) const |
615 | { | 625 | { |
616 | QStringList list; | 626 | QStringList list; |
617 | if (filter.at(0) == '/') // absolute paths we return | 627 | if (filter.at(0) == '/') // absolute paths we return |
@@ -716,768 +726,771 @@ void KStandardDirs::createSpecialResource(const char *type) | |||
716 | addResourceDir(type, dir+'/'); | 726 | addResourceDir(type, dir+'/'); |
717 | } | 727 | } |
718 | */ | 728 | */ |
719 | 729 | ||
720 | QStringList KStandardDirs::resourceDirs(const char *type) const | 730 | QStringList KStandardDirs::resourceDirs(const char *type) const |
721 | { | 731 | { |
722 | QStringList *candidates = dircache.find(type); | 732 | QStringList *candidates = dircache.find(type); |
723 | 733 | ||
724 | if (!candidates) { // filling cache | 734 | if (!candidates) { // filling cache |
725 | /*US | 735 | /*US |
726 | if (strcmp(type, "socket") == 0) | 736 | if (strcmp(type, "socket") == 0) |
727 | const_cast<KStandardDirs *>(this)->createSpecialResource(type); | 737 | const_cast<KStandardDirs *>(this)->createSpecialResource(type); |
728 | else if (strcmp(type, "tmp") == 0) | 738 | else if (strcmp(type, "tmp") == 0) |
729 | const_cast<KStandardDirs *>(this)->createSpecialResource(type); | 739 | const_cast<KStandardDirs *>(this)->createSpecialResource(type); |
730 | else if (strcmp(type, "cache") == 0) | 740 | else if (strcmp(type, "cache") == 0) |
731 | const_cast<KStandardDirs *>(this)->createSpecialResource(type); | 741 | const_cast<KStandardDirs *>(this)->createSpecialResource(type); |
732 | */ | 742 | */ |
733 | QDir testdir; | 743 | QDir testdir; |
734 | 744 | ||
735 | candidates = new QStringList(); | 745 | candidates = new QStringList(); |
736 | QStringList *dirs; | 746 | QStringList *dirs; |
737 | 747 | ||
738 | bool restrictionActive = false; | 748 | bool restrictionActive = false; |
739 | if (d && d->restrictionsActive) | 749 | if (d && d->restrictionsActive) |
740 | { | 750 | { |
741 | if (d->dataRestrictionActive) | 751 | if (d->dataRestrictionActive) |
742 | restrictionActive = true; | 752 | restrictionActive = true; |
743 | else if (d->restrictions["all"]) | 753 | else if (d->restrictions["all"]) |
744 | restrictionActive = true; | 754 | restrictionActive = true; |
745 | else if (d->restrictions[type]) | 755 | else if (d->restrictions[type]) |
746 | restrictionActive = true; | 756 | restrictionActive = true; |
747 | d->dataRestrictionActive = false; // Reset | 757 | d->dataRestrictionActive = false; // Reset |
748 | } | 758 | } |
749 | 759 | ||
750 | dirs = relatives.find(type); | 760 | dirs = relatives.find(type); |
751 | if (dirs) | 761 | if (dirs) |
752 | { | 762 | { |
753 | bool local = true; | 763 | bool local = true; |
754 | const QStringList *prefixList = 0; | 764 | const QStringList *prefixList = 0; |
755 | if (strncmp(type, "xdgdata-", 8) == 0) | 765 | if (strncmp(type, "xdgdata-", 8) == 0) |
756 | prefixList = &(d->xdgdata_prefixes); | 766 | prefixList = &(d->xdgdata_prefixes); |
757 | else if (strncmp(type, "xdgconf-", 8) == 0) | 767 | else if (strncmp(type, "xdgconf-", 8) == 0) |
758 | prefixList = &(d->xdgconf_prefixes); | 768 | prefixList = &(d->xdgconf_prefixes); |
759 | else | 769 | else |
760 | prefixList = &prefixes; | 770 | prefixList = &prefixes; |
761 | 771 | ||
762 | for (QStringList::ConstIterator pit = prefixList->begin(); | 772 | for (QStringList::ConstIterator pit = prefixList->begin(); |
763 | pit != prefixList->end(); | 773 | pit != prefixList->end(); |
764 | pit++) | 774 | pit++) |
765 | { | 775 | { |
766 | for (QStringList::ConstIterator it = dirs->begin(); | 776 | for (QStringList::ConstIterator it = dirs->begin(); |
767 | it != dirs->end(); ++it) { | 777 | it != dirs->end(); ++it) { |
768 | QString path = realPath(*pit + *it); | 778 | QString path = realPath(*pit + *it); |
769 | testdir.setPath(path); | 779 | testdir.setPath(path); |
770 | if (local && restrictionActive) | 780 | if (local && restrictionActive) |
771 | continue; | 781 | continue; |
772 | if ((local || testdir.exists()) && !candidates->contains(path)) | 782 | if ((local || testdir.exists()) && !candidates->contains(path)) |
773 | candidates->append(path); | 783 | candidates->append(path); |
774 | } | 784 | } |
775 | local = false; | 785 | local = false; |
776 | } | 786 | } |
777 | } | 787 | } |
778 | dirs = absolutes.find(type); | 788 | dirs = absolutes.find(type); |
779 | if (dirs) | 789 | if (dirs) |
780 | for (QStringList::ConstIterator it = dirs->begin(); | 790 | for (QStringList::ConstIterator it = dirs->begin(); |
781 | it != dirs->end(); ++it) | 791 | it != dirs->end(); ++it) |
782 | { | 792 | { |
783 | testdir.setPath(*it); | 793 | testdir.setPath(*it); |
784 | if (testdir.exists()) | 794 | if (testdir.exists()) |
785 | { | 795 | { |
786 | QString filename = realPath(*it); | 796 | QString filename = realPath(*it); |
787 | if (!candidates->contains(filename)) | 797 | if (!candidates->contains(filename)) |
788 | candidates->append(filename); | 798 | candidates->append(filename); |
789 | } | 799 | } |
790 | } | 800 | } |
791 | dircache.insert(type, candidates); | 801 | dircache.insert(type, candidates); |
792 | } | 802 | } |
793 | 803 | ||
794 | #if 0 | 804 | #if 0 |
795 | kdDebug() << "found dirs for resource " << type << ":" << endl; | 805 | kdDebug() << "found dirs for resource " << type << ":" << endl; |
796 | for (QStringList::ConstIterator pit = candidates->begin(); | 806 | for (QStringList::ConstIterator pit = candidates->begin(); |
797 | pit != candidates->end(); | 807 | pit != candidates->end(); |
798 | pit++) | 808 | pit++) |
799 | { | 809 | { |
800 | fprintf(stderr, "%s\n", (*pit).latin1()); | 810 | fprintf(stderr, "%s\n", (*pit).latin1()); |
801 | } | 811 | } |
802 | #endif | 812 | #endif |
803 | 813 | ||
804 | 814 | ||
805 | return *candidates; | 815 | return *candidates; |
806 | } | 816 | } |
807 | 817 | ||
808 | /*US | 818 | /*US |
809 | QString KStandardDirs::findExe( const QString& appname, | 819 | QString KStandardDirs::findExe( const QString& appname, |
810 | const QString& pstr, bool ignore) | 820 | const QString& pstr, bool ignore) |
811 | { | 821 | { |
812 | QFileInfo info; | 822 | QFileInfo info; |
813 | 823 | ||
814 | // absolute path ? | 824 | // absolute path ? |
815 | if (appname.startsWith(QString::fromLatin1("/"))) | 825 | if (appname.startsWith(QString::fromLatin1("/"))) |
816 | { | 826 | { |
817 | info.setFile( appname ); | 827 | info.setFile( appname ); |
818 | if( info.exists() && ( ignore || info.isExecutable() ) | 828 | if( info.exists() && ( ignore || info.isExecutable() ) |
819 | && info.isFile() ) { | 829 | && info.isFile() ) { |
820 | return appname; | 830 | return appname; |
821 | } | 831 | } |
822 | return QString::null; | 832 | return QString::null; |
823 | } | 833 | } |
824 | 834 | ||
825 | //US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname); | 835 | //US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname); |
826 | QString p = QString("%1/%2").arg(appname).arg(appname); | 836 | QString p = QString("%1/%2").arg(appname).arg(appname); |
827 | qDebug("KStandardDirs::findExe this is probably wrong"); | 837 | qDebug("KStandardDirs::findExe this is probably wrong"); |
828 | 838 | ||
829 | info.setFile( p ); | 839 | info.setFile( p ); |
830 | if( info.exists() && ( ignore || info.isExecutable() ) | 840 | if( info.exists() && ( ignore || info.isExecutable() ) |
831 | && ( info.isFile() || info.isSymLink() ) ) { | 841 | && ( info.isFile() || info.isSymLink() ) ) { |
832 | return p; | 842 | return p; |
833 | } | 843 | } |
834 | 844 | ||
835 | QStringList tokens; | 845 | QStringList tokens; |
836 | p = pstr; | 846 | p = pstr; |
837 | 847 | ||
838 | if( p.isNull() ) { | 848 | if( p.isNull() ) { |
839 | p = getenv( "PATH" ); | 849 | p = getenv( "PATH" ); |
840 | } | 850 | } |
841 | 851 | ||
842 | tokenize( tokens, p, ":\b" ); | 852 | tokenize( tokens, p, ":\b" ); |
843 | 853 | ||
844 | // split path using : or \b as delimiters | 854 | // split path using : or \b as delimiters |
845 | for( unsigned i = 0; i < tokens.count(); i++ ) { | 855 | for( unsigned i = 0; i < tokens.count(); i++ ) { |
846 | p = tokens[ i ]; | 856 | p = tokens[ i ]; |
847 | 857 | ||
848 | if ( p[ 0 ] == '~' ) | 858 | if ( p[ 0 ] == '~' ) |
849 | { | 859 | { |
850 | int len = p.find( '/' ); | 860 | int len = p.find( '/' ); |
851 | if ( len == -1 ) | 861 | if ( len == -1 ) |
852 | len = p.length(); | 862 | len = p.length(); |
853 | if ( len == 1 ) | 863 | if ( len == 1 ) |
854 | p.replace( 0, 1, QDir::homeDirPath() ); | 864 | p.replace( 0, 1, QDir::homeDirPath() ); |
855 | else | 865 | else |
856 | { | 866 | { |
857 | QString user = p.mid( 1, len - 1 ); | 867 | QString user = p.mid( 1, len - 1 ); |
858 | struct passwd *dir = getpwnam( user.local8Bit().data() ); | 868 | struct passwd *dir = getpwnam( user.local8Bit().data() ); |
859 | if ( dir && strlen( dir->pw_dir ) ) | 869 | if ( dir && strlen( dir->pw_dir ) ) |
860 | p.replace( 0, len, QString::fromLocal8Bit( dir->pw_dir ) ); | 870 | p.replace( 0, len, QString::fromLocal8Bit( dir->pw_dir ) ); |
861 | } | 871 | } |
862 | } | 872 | } |
863 | 873 | ||
864 | p += "/"; | 874 | p += "/"; |
865 | p += appname; | 875 | p += appname; |
866 | 876 | ||
867 | // Check for executable in this tokenized path | 877 | // Check for executable in this tokenized path |
868 | info.setFile( p ); | 878 | info.setFile( p ); |
869 | 879 | ||
870 | if( info.exists() && ( ignore || info.isExecutable() ) | 880 | if( info.exists() && ( ignore || info.isExecutable() ) |
871 | && ( info.isFile() || info.isSymLink() ) ) { | 881 | && ( info.isFile() || info.isSymLink() ) ) { |
872 | return p; | 882 | return p; |
873 | } | 883 | } |
874 | } | 884 | } |
875 | 885 | ||
876 | // If we reach here, the executable wasn't found. | 886 | // If we reach here, the executable wasn't found. |
877 | // So return empty string. | 887 | // So return empty string. |
878 | 888 | ||
879 | return QString::null; | 889 | return QString::null; |
880 | } | 890 | } |
881 | 891 | ||
882 | int KStandardDirs::findAllExe( QStringList& list, const QString& appname, | 892 | int KStandardDirs::findAllExe( QStringList& list, const QString& appname, |
883 | const QString& pstr, bool ignore ) | 893 | const QString& pstr, bool ignore ) |
884 | { | 894 | { |
885 | QString p = pstr; | 895 | QString p = pstr; |
886 | QFileInfo info; | 896 | QFileInfo info; |
887 | QStringList tokens; | 897 | QStringList tokens; |
888 | 898 | ||
889 | if( p.isNull() ) { | 899 | if( p.isNull() ) { |
890 | p = getenv( "PATH" ); | 900 | p = getenv( "PATH" ); |
891 | } | 901 | } |
892 | 902 | ||
893 | list.clear(); | 903 | list.clear(); |
894 | tokenize( tokens, p, ":\b" ); | 904 | tokenize( tokens, p, ":\b" ); |
895 | 905 | ||
896 | for ( unsigned i = 0; i < tokens.count(); i++ ) { | 906 | for ( unsigned i = 0; i < tokens.count(); i++ ) { |
897 | p = tokens[ i ]; | 907 | p = tokens[ i ]; |
898 | p += "/"; | 908 | p += "/"; |
899 | p += appname; | 909 | p += appname; |
900 | 910 | ||
901 | info.setFile( p ); | 911 | info.setFile( p ); |
902 | 912 | ||
903 | if( info.exists() && (ignore || info.isExecutable()) | 913 | if( info.exists() && (ignore || info.isExecutable()) |
904 | && info.isFile() ) { | 914 | && info.isFile() ) { |
905 | list.append( p ); | 915 | list.append( p ); |
906 | } | 916 | } |
907 | 917 | ||
908 | } | 918 | } |
909 | 919 | ||
910 | return list.count(); | 920 | return list.count(); |
911 | } | 921 | } |
912 | */ | 922 | */ |
913 | 923 | ||
914 | static int tokenize( QStringList& tokens, const QString& str, | 924 | static int tokenize( QStringList& tokens, const QString& str, |
915 | const QString& delim ) | 925 | const QString& delim ) |
916 | { | 926 | { |
917 | int len = str.length(); | 927 | int len = str.length(); |
918 | QString token = ""; | 928 | QString token = ""; |
919 | 929 | ||
920 | for( int index = 0; index < len; index++) | 930 | for( int index = 0; index < len; index++) |
921 | { | 931 | { |
922 | if ( delim.find( str[ index ] ) >= 0 ) | 932 | if ( delim.find( str[ index ] ) >= 0 ) |
923 | { | 933 | { |
924 | tokens.append( token ); | 934 | tokens.append( token ); |
925 | token = ""; | 935 | token = ""; |
926 | } | 936 | } |
927 | else | 937 | else |
928 | { | 938 | { |
929 | token += str[ index ]; | 939 | token += str[ index ]; |
930 | } | 940 | } |
931 | } | 941 | } |
932 | if ( token.length() > 0 ) | 942 | if ( token.length() > 0 ) |
933 | { | 943 | { |
934 | tokens.append( token ); | 944 | tokens.append( token ); |
935 | } | 945 | } |
936 | 946 | ||
937 | return tokens.count(); | 947 | return tokens.count(); |
938 | } | 948 | } |
939 | 949 | ||
940 | QString KStandardDirs::kde_default(const char *type) { | 950 | QString KStandardDirs::kde_default(const char *type) { |
941 | if (!strcmp(type, "data")) | 951 | if (!strcmp(type, "data")) |
942 | return "apps/"; | 952 | return "apps/"; |
943 | if (!strcmp(type, "html")) | 953 | if (!strcmp(type, "html")) |
944 | return "share/doc/HTML/"; | 954 | return "share/doc/HTML/"; |
945 | if (!strcmp(type, "icon")) | 955 | if (!strcmp(type, "icon")) |
946 | return "share/icons/"; | 956 | return "share/icons/"; |
947 | if (!strcmp(type, "config")) | 957 | if (!strcmp(type, "config")) |
948 | return "config/"; | 958 | return "config/"; |
949 | if (!strcmp(type, "pixmap")) | 959 | if (!strcmp(type, "pixmap")) |
950 | return "share/pixmaps/"; | 960 | return "share/pixmaps/"; |
951 | if (!strcmp(type, "apps")) | 961 | if (!strcmp(type, "apps")) |
952 | return "share/applnk/"; | 962 | return "share/applnk/"; |
953 | if (!strcmp(type, "sound")) | 963 | if (!strcmp(type, "sound")) |
954 | return "share/sounds/"; | 964 | return "share/sounds/"; |
955 | if (!strcmp(type, "locale")) | 965 | if (!strcmp(type, "locale")) |
956 | return "share/locale/"; | 966 | return "share/locale/"; |
957 | if (!strcmp(type, "services")) | 967 | if (!strcmp(type, "services")) |
958 | return "share/services/"; | 968 | return "share/services/"; |
959 | if (!strcmp(type, "servicetypes")) | 969 | if (!strcmp(type, "servicetypes")) |
960 | return "share/servicetypes/"; | 970 | return "share/servicetypes/"; |
961 | if (!strcmp(type, "mime")) | 971 | if (!strcmp(type, "mime")) |
962 | return "share/mimelnk/"; | 972 | return "share/mimelnk/"; |
963 | if (!strcmp(type, "cgi")) | 973 | if (!strcmp(type, "cgi")) |
964 | return "cgi-bin/"; | 974 | return "cgi-bin/"; |
965 | if (!strcmp(type, "wallpaper")) | 975 | if (!strcmp(type, "wallpaper")) |
966 | return "share/wallpapers/"; | 976 | return "share/wallpapers/"; |
967 | if (!strcmp(type, "templates")) | 977 | if (!strcmp(type, "templates")) |
968 | return "share/templates/"; | 978 | return "share/templates/"; |
969 | if (!strcmp(type, "exe")) | 979 | if (!strcmp(type, "exe")) |
970 | return "bin/"; | 980 | return "bin/"; |
971 | if (!strcmp(type, "lib")) | 981 | if (!strcmp(type, "lib")) |
972 | return "lib/"; | 982 | return "lib/"; |
973 | if (!strcmp(type, "module")) | 983 | if (!strcmp(type, "module")) |
974 | return "lib/kde3/"; | 984 | return "lib/kde3/"; |
975 | if (!strcmp(type, "qtplugins")) | 985 | if (!strcmp(type, "qtplugins")) |
976 | return "lib/kde3/plugins"; | 986 | return "lib/kde3/plugins"; |
977 | if (!strcmp(type, "xdgdata-apps")) | 987 | if (!strcmp(type, "xdgdata-apps")) |
978 | return "applications/"; | 988 | return "applications/"; |
979 | if (!strcmp(type, "xdgdata-dirs")) | 989 | if (!strcmp(type, "xdgdata-dirs")) |
980 | return "desktop-directories/"; | 990 | return "desktop-directories/"; |
981 | if (!strcmp(type, "xdgconf-menu")) | 991 | if (!strcmp(type, "xdgconf-menu")) |
982 | return "menus/"; | 992 | return "menus/"; |
983 | qFatal("unknown resource type %s", type); | 993 | qFatal("unknown resource type %s", type); |
984 | return QString::null; | 994 | return QString::null; |
985 | } | 995 | } |
986 | 996 | ||
987 | QString KStandardDirs::saveLocation(const char *type, | 997 | QString KStandardDirs::saveLocation(const char *type, |
988 | const QString& suffix, | 998 | const QString& suffix, |
989 | bool create) const | 999 | bool create) const |
990 | { | 1000 | { |
991 | //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); | 1001 | //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); |
992 | //return ""; | 1002 | //return ""; |
993 | checkConfig(); | 1003 | checkConfig(); |
994 | 1004 | ||
995 | QString *pPath = savelocations.find(type); | 1005 | QString *pPath = savelocations.find(type); |
996 | if (!pPath) | 1006 | if (!pPath) |
997 | { | 1007 | { |
998 | QStringList *dirs = relatives.find(type); | 1008 | QStringList *dirs = relatives.find(type); |
999 | if (!dirs && ( | 1009 | if (!dirs && ( |
1000 | (strcmp(type, "socket") == 0) || | 1010 | (strcmp(type, "socket") == 0) || |
1001 | (strcmp(type, "tmp") == 0) || | 1011 | (strcmp(type, "tmp") == 0) || |
1002 | (strcmp(type, "cache") == 0) )) | 1012 | (strcmp(type, "cache") == 0) )) |
1003 | { | 1013 | { |
1004 | (void) resourceDirs(type); // Generate socket|tmp|cache resource. | 1014 | (void) resourceDirs(type); // Generate socket|tmp|cache resource. |
1005 | dirs = relatives.find(type); // Search again. | 1015 | dirs = relatives.find(type); // Search again. |
1006 | } | 1016 | } |
1007 | if (dirs) | 1017 | if (dirs) |
1008 | { | 1018 | { |
1009 | // Check for existance of typed directory + suffix | 1019 | // Check for existance of typed directory + suffix |
1010 | if (strncmp(type, "xdgdata-", 8) == 0) | 1020 | if (strncmp(type, "xdgdata-", 8) == 0) |
1011 | pPath = new QString(realPath(localxdgdatadir() + dirs->last())); | 1021 | pPath = new QString(realPath(localxdgdatadir() + dirs->last())); |
1012 | else if (strncmp(type, "xdgconf-", 8) == 0) | 1022 | else if (strncmp(type, "xdgconf-", 8) == 0) |
1013 | pPath = new QString(realPath(localxdgconfdir() + dirs->last())); | 1023 | pPath = new QString(realPath(localxdgconfdir() + dirs->last())); |
1014 | else | 1024 | else |
1015 | pPath = new QString(realPath(localkdedir() + dirs->last())); | 1025 | pPath = new QString(realPath(localkdedir() + dirs->last())); |
1016 | } | 1026 | } |
1017 | else { | 1027 | else { |
1018 | dirs = absolutes.find(type); | 1028 | dirs = absolutes.find(type); |
1019 | if (!dirs) | 1029 | if (!dirs) |
1020 | qFatal("KStandardDirs: The resource type %s is not registered", type); | 1030 | qFatal("KStandardDirs: The resource type %s is not registered", type); |
1021 | pPath = new QString(realPath(dirs->last())); | 1031 | pPath = new QString(realPath(dirs->last())); |
1022 | } | 1032 | } |
1023 | 1033 | ||
1024 | savelocations.insert(type, pPath); | 1034 | savelocations.insert(type, pPath); |
1025 | } | 1035 | } |
1026 | 1036 | ||
1027 | QString fullPath = *pPath + suffix; | 1037 | QString fullPath = *pPath + suffix; |
1028 | //US struct stat st; | 1038 | //US struct stat st; |
1029 | //US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) | 1039 | //US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) |
1030 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); | 1040 | QFileInfo fullPathInfo(QFile::encodeName(fullPath)); |
1031 | if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) | 1041 | if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) |
1032 | 1042 | ||
1033 | 1043 | ||
1034 | { | 1044 | { |
1035 | if(!create) { | 1045 | if(!create) { |
1036 | #ifndef NDEBUG | 1046 | #ifndef NDEBUG |
1037 | qDebug("save location %s doesn't exist", fullPath.latin1()); | 1047 | qDebug("save location %s doesn't exist", fullPath.latin1()); |
1038 | #endif | 1048 | #endif |
1039 | return fullPath; | 1049 | return fullPath; |
1040 | } | 1050 | } |
1041 | if(!makeDir(fullPath, 0700)) { | 1051 | if(!makeDir(fullPath, 0700)) { |
1042 | qWarning("failed to create %s", fullPath.latin1()); | 1052 | qWarning("failed to create %s", fullPath.latin1()); |
1043 | return fullPath; | 1053 | return fullPath; |
1044 | } | 1054 | } |
1045 | dircache.remove(type); | 1055 | dircache.remove(type); |
1046 | } | 1056 | } |
1047 | return fullPath; | 1057 | return fullPath; |
1048 | } | 1058 | } |
1049 | 1059 | ||
1050 | QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) | 1060 | QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) |
1051 | { | 1061 | { |
1052 | QString fullPath = absPath; | 1062 | QString fullPath = absPath; |
1053 | int i = absPath.findRev('/'); | 1063 | int i = absPath.findRev('/'); |
1054 | if (i != -1) | 1064 | if (i != -1) |
1055 | { | 1065 | { |
1056 | fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize | 1066 | fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize |
1057 | } | 1067 | } |
1058 | 1068 | ||
1059 | QStringList candidates = resourceDirs(type); | 1069 | QStringList candidates = resourceDirs(type); |
1060 | 1070 | ||
1061 | for (QStringList::ConstIterator it = candidates.begin(); | 1071 | for (QStringList::ConstIterator it = candidates.begin(); |
1062 | it != candidates.end(); it++) | 1072 | it != candidates.end(); it++) |
1063 | if (fullPath.startsWith(*it)) | 1073 | if (fullPath.startsWith(*it)) |
1064 | { | 1074 | { |
1065 | return fullPath.mid((*it).length()); | 1075 | return fullPath.mid((*it).length()); |
1066 | } | 1076 | } |
1067 | 1077 | ||
1068 | return absPath; | 1078 | return absPath; |
1069 | } | 1079 | } |
1070 | 1080 | ||
1071 | 1081 | ||
1072 | bool KStandardDirs::makeDir(const QString& dir2, int mode) | 1082 | bool KStandardDirs::makeDir(const QString& dir2, int mode) |
1073 | { | 1083 | { |
1074 | QString dir = QDir::convertSeparators( dir2 ); | 1084 | QString dir = QDir::convertSeparators( dir2 ); |
1075 | #if 0 | 1085 | #if 0 |
1076 | //LR | 1086 | //LR |
1077 | 1087 | ||
1078 | // we want an absolute path | 1088 | // we want an absolute path |
1079 | if (dir.at(0) != '/') | 1089 | if (dir.at(0) != '/') |
1080 | return false; | 1090 | return false; |
1081 | 1091 | ||
1082 | QString target = dir; | 1092 | QString target = dir; |
1083 | uint len = target.length(); | 1093 | uint len = target.length(); |
1084 | 1094 | ||
1085 | // append trailing slash if missing | 1095 | // append trailing slash if missing |
1086 | if (dir.at(len - 1) != '/') | 1096 | if (dir.at(len - 1) != '/') |
1087 | target += '/'; | 1097 | target += '/'; |
1088 | 1098 | ||
1089 | QString base(""); | 1099 | QString base(""); |
1090 | uint i = 1; | 1100 | uint i = 1; |
1091 | 1101 | ||
1092 | while( i < len ) | 1102 | while( i < len ) |
1093 | { | 1103 | { |
1094 | //US struct stat st; | 1104 | //US struct stat st; |
1095 | int pos = target.find('/', i); | 1105 | int pos = target.find('/', i); |
1096 | base += target.mid(i - 1, pos - i + 1); | 1106 | base += target.mid(i - 1, pos - i + 1); |
1097 | QCString baseEncoded = QFile::encodeName(base); | 1107 | QCString baseEncoded = QFile::encodeName(base); |
1098 | // bail out if we encountered a problem | 1108 | // bail out if we encountered a problem |
1099 | //US if (stat(baseEncoded, &st) != 0) | 1109 | //US if (stat(baseEncoded, &st) != 0) |
1100 | QFileInfo baseEncodedInfo(baseEncoded); | 1110 | QFileInfo baseEncodedInfo(baseEncoded); |
1101 | if (!baseEncodedInfo.exists()) | 1111 | if (!baseEncodedInfo.exists()) |
1102 | { | 1112 | { |
1103 | // Directory does not exist.... | 1113 | // Directory does not exist.... |
1104 | // Or maybe a dangling symlink ? | 1114 | // Or maybe a dangling symlink ? |
1105 | //US if (lstat(baseEncoded, &st) == 0) | 1115 | //US if (lstat(baseEncoded, &st) == 0) |
1106 | if (baseEncodedInfo.isSymLink()) { | 1116 | if (baseEncodedInfo.isSymLink()) { |
1107 | //US (void)unlink(baseEncoded); // try removing | 1117 | //US (void)unlink(baseEncoded); // try removing |
1108 | QFile(baseEncoded).remove(); | 1118 | QFile(baseEncoded).remove(); |
1109 | } | 1119 | } |
1110 | 1120 | ||
1111 | //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) | 1121 | //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) |
1112 | QDir dirObj; | 1122 | QDir dirObj; |
1113 | if ( dirObj.mkdir(baseEncoded) != true ) | 1123 | if ( dirObj.mkdir(baseEncoded) != true ) |
1114 | { | 1124 | { |
1115 | //US perror("trying to create local folder"); | 1125 | //US perror("trying to create local folder"); |
1116 | return false; // Couldn't create it :-( | 1126 | return false; // Couldn't create it :-( |
1117 | } | 1127 | } |
1118 | } | 1128 | } |
1119 | i = pos + 1; | 1129 | i = pos + 1; |
1120 | } | 1130 | } |
1121 | return true; | 1131 | return true; |
1122 | #endif | 1132 | #endif |
1123 | 1133 | ||
1124 | // ******************************************** | 1134 | // ******************************************** |
1125 | // new code for WIN32 | 1135 | // new code for WIN32 |
1126 | QDir dirObj; | 1136 | QDir dirObj; |
1127 | 1137 | ||
1128 | 1138 | ||
1129 | // we want an absolute path | 1139 | // we want an absolute path |
1130 | #ifndef _WIN32_ | 1140 | #ifndef _WIN32_ |
1131 | if (dir.at(0) != '/') | 1141 | if (dir.at(0) != '/') |
1132 | return false; | 1142 | return false; |
1133 | #endif | 1143 | #endif |
1134 | 1144 | ||
1135 | QString target = dir; | 1145 | QString target = dir; |
1136 | uint len = target.length(); | 1146 | uint len = target.length(); |
1137 | #ifndef _WIN32_ | 1147 | #ifndef _WIN32_ |
1138 | // append trailing slash if missing | 1148 | // append trailing slash if missing |
1139 | if (dir.at(len - 1) != '/') | 1149 | if (dir.at(len - 1) != '/') |
1140 | target += '/'; | 1150 | target += '/'; |
1141 | #endif | 1151 | #endif |
1142 | 1152 | ||
1143 | QString base(""); | 1153 | QString base(""); |
1144 | uint i = 1; | 1154 | uint i = 1; |
1145 | 1155 | ||
1146 | while( i < len ) | 1156 | while( i < len ) |
1147 | { | 1157 | { |
1148 | //US struct stat st; | 1158 | //US struct stat st; |
1149 | #ifndef _WIN32_ | 1159 | #ifndef _WIN32_ |
1150 | int pos = target.find('/', i); | 1160 | int pos = target.find('/', i); |
1151 | #else | 1161 | #else |
1152 | int pos = target.find('\\', i); | 1162 | int pos = target.find('\\', i); |
1153 | #endif | 1163 | #endif |
1154 | if ( pos < 0 ) | 1164 | if ( pos < 0 ) |
1155 | return true; | 1165 | return true; |
1156 | base += target.mid(i - 1, pos - i + 1); | 1166 | base += target.mid(i - 1, pos - i + 1); |
1157 | //QMessageBox::information( 0,"cap111", base, 1 ); | 1167 | //QMessageBox::information( 0,"cap111", base, 1 ); |
1158 | /*US | 1168 | /*US |
1159 | QCString baseEncoded = QFile::encodeName(base); | 1169 | QCString baseEncoded = QFile::encodeName(base); |
1160 | // bail out if we encountered a problem | 1170 | // bail out if we encountered a problem |
1161 | if (stat(baseEncoded, &st) != 0) | 1171 | if (stat(baseEncoded, &st) != 0) |
1162 | { | 1172 | { |
1163 | // Directory does not exist.... | 1173 | // Directory does not exist.... |
1164 | // Or maybe a dangling symlink ? | 1174 | // Or maybe a dangling symlink ? |
1165 | if (lstat(baseEncoded, &st) == 0) | 1175 | if (lstat(baseEncoded, &st) == 0) |
1166 | (void)unlink(baseEncoded); // try removing | 1176 | (void)unlink(baseEncoded); // try removing |
1167 | 1177 | ||
1168 | 1178 | ||
1169 | if ( mkdir(baseEncoded, (mode_t) mode) != 0) { | 1179 | if ( mkdir(baseEncoded, (mode_t) mode) != 0) { |
1170 | perror("trying to create local folder"); | 1180 | perror("trying to create local folder"); |
1171 | return false; // Couldn't create it :-( | 1181 | return false; // Couldn't create it :-( |
1172 | } | 1182 | } |
1173 | } | 1183 | } |
1174 | */ | 1184 | */ |
1175 | 1185 | ||
1176 | if (dirObj.exists(base) == false) | 1186 | if (dirObj.exists(base) == false) |
1177 | { | 1187 | { |
1178 | //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); | 1188 | //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); |
1179 | if (dirObj.mkdir(base) != true) | 1189 | if (dirObj.mkdir(base) != true) |
1180 | { | 1190 | { |
1181 | qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); | 1191 | qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); |
1182 | return false; | 1192 | return false; |
1183 | } | 1193 | } |
1184 | } | 1194 | } |
1185 | 1195 | ||
1186 | i = pos + 1; | 1196 | i = pos + 1; |
1187 | } | 1197 | } |
1188 | return true; | 1198 | return true; |
1189 | 1199 | ||
1190 | } | 1200 | } |
1191 | 1201 | ||
1192 | static QString readEnvPath(const char *env) | 1202 | static QString readEnvPath(const char *env) |
1193 | { | 1203 | { |
1194 | #ifdef _WIN32_ | 1204 | #ifdef _WIN32_ |
1195 | return ""; | 1205 | return ""; |
1196 | #else | 1206 | #else |
1197 | QCString c_path = getenv(env); | 1207 | QCString c_path = getenv(env); |
1198 | if (c_path.isEmpty()) | 1208 | if (c_path.isEmpty()) |
1199 | return QString::null; | 1209 | return QString::null; |
1200 | return QFile::decodeName(c_path); | 1210 | return QFile::decodeName(c_path); |
1201 | #endif | 1211 | #endif |
1202 | } | 1212 | } |
1203 | 1213 | ||
1204 | void KStandardDirs::addKDEDefaults() | 1214 | void KStandardDirs::addKDEDefaults() |
1205 | { | 1215 | { |
1206 | //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); | 1216 | //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); |
1207 | //return; | 1217 | //return; |
1208 | QStringList kdedirList; | 1218 | QStringList kdedirList; |
1209 | 1219 | ||
1210 | // begin KDEDIRS | 1220 | // begin KDEDIRS |
1211 | QString kdedirs = readEnvPath("MICROKDEDIRS"); | 1221 | QString kdedirs = readEnvPath("MICROKDEDIRS"); |
1212 | if (!kdedirs.isEmpty()) | 1222 | if (!kdedirs.isEmpty()) |
1213 | { | 1223 | { |
1214 | tokenize(kdedirList, kdedirs, ":"); | 1224 | tokenize(kdedirList, kdedirs, ":"); |
1215 | } | 1225 | } |
1216 | else | 1226 | else |
1217 | { | 1227 | { |
1218 | QString kdedir = readEnvPath("MICROKDEDIR"); | 1228 | QString kdedir = readEnvPath("MICROKDEDIR"); |
1219 | if (!kdedir.isEmpty()) | 1229 | if (!kdedir.isEmpty()) |
1220 | { | 1230 | { |
1221 | kdedir = KShell::tildeExpand(kdedir); | 1231 | kdedir = KShell::tildeExpand(kdedir); |
1222 | kdedirList.append(kdedir); | 1232 | kdedirList.append(kdedir); |
1223 | } | 1233 | } |
1224 | } | 1234 | } |
1225 | //US kdedirList.append(KDEDIR); | 1235 | //US kdedirList.append(KDEDIR); |
1226 | //US for embedded, add qtopia dir as kdedir | 1236 | //US for embedded, add qtopia dir as kdedir |
1237 | |||
1238 | #ifndef DESKTOP_VERSION | ||
1227 | kdedirList.append(readEnvPath("QPEDIR" )); | 1239 | kdedirList.append(readEnvPath("QPEDIR" )); |
1240 | #endif | ||
1228 | 1241 | ||
1229 | #ifdef __KDE_EXECPREFIX | 1242 | #ifdef __KDE_EXECPREFIX |
1230 | QString execPrefix(__KDE_EXECPREFIX); | 1243 | QString execPrefix(__KDE_EXECPREFIX); |
1231 | if (execPrefix!="NONE") | 1244 | if (execPrefix!="NONE") |
1232 | kdedirList.append(execPrefix); | 1245 | kdedirList.append(execPrefix); |
1233 | #endif | 1246 | #endif |
1234 | 1247 | ||
1235 | QString localKdeDir; | 1248 | QString localKdeDir; |
1236 | 1249 | ||
1237 | //US if (getuid()) | 1250 | //US if (getuid()) |
1238 | if (true) | 1251 | if (true) |
1239 | { | 1252 | { |
1240 | localKdeDir = readEnvPath("MICROKDEHOME"); | 1253 | localKdeDir = readEnvPath("MICROKDEHOME"); |
1241 | if (!localKdeDir.isEmpty()) | 1254 | if (!localKdeDir.isEmpty()) |
1242 | { | 1255 | { |
1243 | if (localKdeDir.at(localKdeDir.length()-1) != '/') | 1256 | if (localKdeDir.at(localKdeDir.length()-1) != '/') |
1244 | localKdeDir += '/'; | 1257 | localKdeDir += '/'; |
1245 | } | 1258 | } |
1246 | else | 1259 | else |
1247 | { | 1260 | { |
1248 | localKdeDir = QDir::homeDirPath() + "/kdepim/"; | 1261 | localKdeDir = QDir::homeDirPath() + "/kdepim/"; |
1249 | } | 1262 | } |
1250 | } | 1263 | } |
1251 | else | 1264 | else |
1252 | { | 1265 | { |
1253 | // We treat root different to prevent root messing up the | 1266 | // We treat root different to prevent root messing up the |
1254 | // file permissions in the users home directory. | 1267 | // file permissions in the users home directory. |
1255 | localKdeDir = readEnvPath("MICROKDEROOTHOME"); | 1268 | localKdeDir = readEnvPath("MICROKDEROOTHOME"); |
1256 | if (!localKdeDir.isEmpty()) | 1269 | if (!localKdeDir.isEmpty()) |
1257 | { | 1270 | { |
1258 | if (localKdeDir.at(localKdeDir.length()-1) != '/') | 1271 | if (localKdeDir.at(localKdeDir.length()-1) != '/') |
1259 | localKdeDir += '/'; | 1272 | localKdeDir += '/'; |
1260 | } | 1273 | } |
1261 | else | 1274 | else |
1262 | { | 1275 | { |
1263 | //US struct passwd *pw = getpwuid(0); | 1276 | //US struct passwd *pw = getpwuid(0); |
1264 | //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; | 1277 | //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; |
1265 | qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); | 1278 | qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); |
1266 | } | 1279 | } |
1267 | 1280 | ||
1268 | } | 1281 | } |
1269 | 1282 | ||
1270 | //US localKdeDir = appDir(); | 1283 | //US localKdeDir = appDir(); |
1271 | 1284 | ||
1272 | //US | 1285 | //US |
1273 | // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); | 1286 | // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); |
1274 | if (localKdeDir != "-/") | 1287 | if (localKdeDir != "-/") |
1275 | { | 1288 | { |
1276 | localKdeDir = KShell::tildeExpand(localKdeDir); | 1289 | localKdeDir = KShell::tildeExpand(localKdeDir); |
1277 | addPrefix(localKdeDir); | 1290 | addPrefix(localKdeDir); |
1278 | } | 1291 | } |
1279 | 1292 | ||
1280 | for (QStringList::ConstIterator it = kdedirList.begin(); | 1293 | for (QStringList::ConstIterator it = kdedirList.begin(); |
1281 | it != kdedirList.end(); it++) | 1294 | it != kdedirList.end(); it++) |
1282 | { | 1295 | { |
1283 | QString dir = KShell::tildeExpand(*it); | 1296 | QString dir = KShell::tildeExpand(*it); |
1284 | addPrefix(dir); | 1297 | addPrefix(dir); |
1285 | } | 1298 | } |
1286 | // end KDEDIRS | 1299 | // end KDEDIRS |
1287 | 1300 | ||
1288 | // begin XDG_CONFIG_XXX | 1301 | // begin XDG_CONFIG_XXX |
1289 | QStringList xdgdirList; | 1302 | QStringList xdgdirList; |
1290 | QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); | 1303 | QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); |
1291 | if (!xdgdirs.isEmpty()) | 1304 | if (!xdgdirs.isEmpty()) |
1292 | { | 1305 | { |
1293 | tokenize(xdgdirList, xdgdirs, ":"); | 1306 | tokenize(xdgdirList, xdgdirs, ":"); |
1294 | } | 1307 | } |
1295 | else | 1308 | else |
1296 | { | 1309 | { |
1297 | xdgdirList.clear(); | 1310 | xdgdirList.clear(); |
1298 | xdgdirList.append("/etc/xdg"); | 1311 | xdgdirList.append("/etc/xdg"); |
1299 | } | 1312 | } |
1300 | 1313 | ||
1301 | QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); | 1314 | QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); |
1302 | if (!localXdgDir.isEmpty()) | 1315 | if (!localXdgDir.isEmpty()) |
1303 | { | 1316 | { |
1304 | if (localXdgDir.at(localXdgDir.length()-1) != '/') | 1317 | if (localXdgDir.at(localXdgDir.length()-1) != '/') |
1305 | localXdgDir += '/'; | 1318 | localXdgDir += '/'; |
1306 | } | 1319 | } |
1307 | else | 1320 | else |
1308 | { | 1321 | { |
1309 | //US if (getuid()) | 1322 | //US if (getuid()) |
1310 | if (true) | 1323 | if (true) |
1311 | { | 1324 | { |
1312 | localXdgDir = QDir::homeDirPath() + "/.config/"; | 1325 | localXdgDir = QDir::homeDirPath() + "/.config/"; |
1313 | } | 1326 | } |
1314 | else | 1327 | else |
1315 | { | 1328 | { |
1316 | //US struct passwd *pw = getpwuid(0); | 1329 | //US struct passwd *pw = getpwuid(0); |
1317 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; | 1330 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; |
1318 | qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); | 1331 | qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); |
1319 | } | 1332 | } |
1320 | } | 1333 | } |
1321 | 1334 | ||
1322 | localXdgDir = KShell::tildeExpand(localXdgDir); | 1335 | localXdgDir = KShell::tildeExpand(localXdgDir); |
1323 | addXdgConfigPrefix(localXdgDir); | 1336 | addXdgConfigPrefix(localXdgDir); |
1324 | 1337 | ||
1325 | for (QStringList::ConstIterator it = xdgdirList.begin(); | 1338 | for (QStringList::ConstIterator it = xdgdirList.begin(); |
1326 | it != xdgdirList.end(); it++) | 1339 | it != xdgdirList.end(); it++) |
1327 | { | 1340 | { |
1328 | QString dir = KShell::tildeExpand(*it); | 1341 | QString dir = KShell::tildeExpand(*it); |
1329 | addXdgConfigPrefix(dir); | 1342 | addXdgConfigPrefix(dir); |
1330 | } | 1343 | } |
1331 | // end XDG_CONFIG_XXX | 1344 | // end XDG_CONFIG_XXX |
1332 | 1345 | ||
1333 | // begin XDG_DATA_XXX | 1346 | // begin XDG_DATA_XXX |
1334 | xdgdirs = readEnvPath("XDG_DATA_DIRS"); | 1347 | xdgdirs = readEnvPath("XDG_DATA_DIRS"); |
1335 | if (!xdgdirs.isEmpty()) | 1348 | if (!xdgdirs.isEmpty()) |
1336 | { | 1349 | { |
1337 | tokenize(xdgdirList, xdgdirs, ":"); | 1350 | tokenize(xdgdirList, xdgdirs, ":"); |
1338 | } | 1351 | } |
1339 | else | 1352 | else |
1340 | { | 1353 | { |
1341 | xdgdirList.clear(); | 1354 | xdgdirList.clear(); |
1342 | for (QStringList::ConstIterator it = kdedirList.begin(); | 1355 | for (QStringList::ConstIterator it = kdedirList.begin(); |
1343 | it != kdedirList.end(); it++) | 1356 | it != kdedirList.end(); it++) |
1344 | { | 1357 | { |
1345 | QString dir = *it; | 1358 | QString dir = *it; |
1346 | if (dir.at(dir.length()-1) != '/') | 1359 | if (dir.at(dir.length()-1) != '/') |
1347 | dir += '/'; | 1360 | dir += '/'; |
1348 | xdgdirList.append(dir+"share/"); | 1361 | xdgdirList.append(dir+"share/"); |
1349 | } | 1362 | } |
1350 | 1363 | ||
1351 | xdgdirList.append("/usr/local/share/"); | 1364 | xdgdirList.append("/usr/local/share/"); |
1352 | xdgdirList.append("/usr/share/"); | 1365 | xdgdirList.append("/usr/share/"); |
1353 | } | 1366 | } |
1354 | 1367 | ||
1355 | localXdgDir = readEnvPath("XDG_DATA_HOME"); | 1368 | localXdgDir = readEnvPath("XDG_DATA_HOME"); |
1356 | if (!localXdgDir.isEmpty()) | 1369 | if (!localXdgDir.isEmpty()) |
1357 | { | 1370 | { |
1358 | if (localXdgDir.at(localXdgDir.length()-1) != '/') | 1371 | if (localXdgDir.at(localXdgDir.length()-1) != '/') |
1359 | localXdgDir += '/'; | 1372 | localXdgDir += '/'; |
1360 | } | 1373 | } |
1361 | else | 1374 | else |
1362 | { | 1375 | { |
1363 | //US if (getuid()) | 1376 | //US if (getuid()) |
1364 | if (true) | 1377 | if (true) |
1365 | { | 1378 | { |
1366 | localXdgDir = QDir::homeDirPath() + "/.local/share/"; | 1379 | localXdgDir = QDir::homeDirPath() + "/.local/share/"; |
1367 | } | 1380 | } |
1368 | else | 1381 | else |
1369 | { | 1382 | { |
1370 | //US struct passwd *pw = getpwuid(0); | 1383 | //US struct passwd *pw = getpwuid(0); |
1371 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; | 1384 | //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; |
1372 | qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); | 1385 | qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); |
1373 | } | 1386 | } |
1374 | } | 1387 | } |
1375 | 1388 | ||
1376 | localXdgDir = KShell::tildeExpand(localXdgDir); | 1389 | localXdgDir = KShell::tildeExpand(localXdgDir); |
1377 | addXdgDataPrefix(localXdgDir); | 1390 | addXdgDataPrefix(localXdgDir); |
1378 | 1391 | ||
1379 | for (QStringList::ConstIterator it = xdgdirList.begin(); | 1392 | for (QStringList::ConstIterator it = xdgdirList.begin(); |
1380 | it != xdgdirList.end(); it++) | 1393 | it != xdgdirList.end(); it++) |
1381 | { | 1394 | { |
1382 | QString dir = KShell::tildeExpand(*it); | 1395 | QString dir = KShell::tildeExpand(*it); |
1383 | 1396 | ||
1384 | addXdgDataPrefix(dir); | 1397 | addXdgDataPrefix(dir); |
1385 | } | 1398 | } |
1386 | // end XDG_DATA_XXX | 1399 | // end XDG_DATA_XXX |
1387 | 1400 | ||
1388 | 1401 | ||
1389 | uint index = 0; | 1402 | uint index = 0; |
1390 | while (types[index] != 0) { | 1403 | while (types[index] != 0) { |
1391 | addResourceType(types[index], kde_default(types[index])); | 1404 | addResourceType(types[index], kde_default(types[index])); |
1392 | index++; | 1405 | index++; |
1393 | } | 1406 | } |
1394 | 1407 | ||
1395 | addResourceDir("home", QDir::homeDirPath()); | 1408 | addResourceDir("home", QDir::homeDirPath()); |
1396 | } | 1409 | } |
1397 | 1410 | ||
1398 | void KStandardDirs::checkConfig() const | 1411 | void KStandardDirs::checkConfig() const |
1399 | { | 1412 | { |
1400 | /*US | 1413 | /*US |
1401 | if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) | 1414 | if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) |
1402 | const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); | 1415 | const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); |
1403 | */ | 1416 | */ |
1404 | if (!addedCustoms && KGlobal::config()) | 1417 | if (!addedCustoms && KGlobal::config()) |
1405 | const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); | 1418 | const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); |
1406 | } | 1419 | } |
1407 | 1420 | ||
1408 | bool KStandardDirs::addCustomized(KConfig *config) | 1421 | bool KStandardDirs::addCustomized(KConfig *config) |
1409 | { | 1422 | { |
1410 | if (addedCustoms) // there are already customized entries | 1423 | if (addedCustoms) // there are already customized entries |
1411 | return false; // we just quite and hope they are the right ones | 1424 | return false; // we just quite and hope they are the right ones |
1412 | 1425 | ||
1413 | // save the numbers of config directories. If this changes, | 1426 | // save the numbers of config directories. If this changes, |
1414 | // we will return true to give KConfig a chance to reparse | 1427 | // we will return true to give KConfig a chance to reparse |
1415 | uint configdirs = resourceDirs("config").count(); | 1428 | uint configdirs = resourceDirs("config").count(); |
1416 | 1429 | ||
1417 | // reading the prefixes in | 1430 | // reading the prefixes in |
1418 | QString oldGroup = config->group(); | 1431 | QString oldGroup = config->group(); |
1419 | config->setGroup("Directories"); | 1432 | config->setGroup("Directories"); |
1420 | 1433 | ||
1421 | QStringList list; | 1434 | QStringList list; |
1422 | QStringList::ConstIterator it; | 1435 | QStringList::ConstIterator it; |
1423 | list = config->readListEntry("prefixes"); | 1436 | list = config->readListEntry("prefixes"); |
1424 | for (it = list.begin(); it != list.end(); it++) | 1437 | for (it = list.begin(); it != list.end(); it++) |
1425 | addPrefix(*it); | 1438 | addPrefix(*it); |
1426 | 1439 | ||
1427 | // iterating over all entries in the group Directories | 1440 | // iterating over all entries in the group Directories |
1428 | // to find entries that start with dir_$type | 1441 | // to find entries that start with dir_$type |
1429 | /*US | 1442 | /*US |
1430 | QMap<QString, QString> entries = config->entryMap("Directories"); | 1443 | QMap<QString, QString> entries = config->entryMap("Directories"); |
1431 | 1444 | ||
1432 | QMap<QString, QString>::ConstIterator it2; | 1445 | QMap<QString, QString>::ConstIterator it2; |
1433 | for (it2 = entries.begin(); it2 != entries.end(); it2++) | 1446 | for (it2 = entries.begin(); it2 != entries.end(); it2++) |
1434 | { | 1447 | { |
1435 | QString key = it2.key(); | 1448 | QString key = it2.key(); |
1436 | if (key.left(4) == "dir_") { | 1449 | if (key.left(4) == "dir_") { |
1437 | // generate directory list, there may be more than 1. | 1450 | // generate directory list, there may be more than 1. |
1438 | QStringList dirs = QStringList::split(',', *it2); | 1451 | QStringList dirs = QStringList::split(',', *it2); |
1439 | QStringList::Iterator sIt(dirs.begin()); | 1452 | QStringList::Iterator sIt(dirs.begin()); |
1440 | QString resType = key.mid(4, key.length()); | 1453 | QString resType = key.mid(4, key.length()); |
1441 | for (; sIt != dirs.end(); ++sIt) { | 1454 | for (; sIt != dirs.end(); ++sIt) { |
1442 | addResourceDir(resType.latin1(), *sIt); | 1455 | addResourceDir(resType.latin1(), *sIt); |
1443 | } | 1456 | } |
1444 | } | 1457 | } |
1445 | } | 1458 | } |
1446 | 1459 | ||
1447 | // Process KIOSK restrictions. | 1460 | // Process KIOSK restrictions. |
1448 | config->setGroup("KDE Resource Restrictions"); | 1461 | config->setGroup("KDE Resource Restrictions"); |
1449 | entries = config->entryMap("KDE Resource Restrictions"); | 1462 | entries = config->entryMap("KDE Resource Restrictions"); |
1450 | for (it2 = entries.begin(); it2 != entries.end(); it2++) | 1463 | for (it2 = entries.begin(); it2 != entries.end(); it2++) |
1451 | { | 1464 | { |
1452 | QString key = it2.key(); | 1465 | QString key = it2.key(); |
1453 | if (!config->readBoolEntry(key, true)) | 1466 | if (!config->readBoolEntry(key, true)) |
1454 | { | 1467 | { |
1455 | d->restrictionsActive = true; | 1468 | d->restrictionsActive = true; |
1456 | d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do | 1469 | d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do |
1457 | dircache.remove(key.latin1()); | 1470 | dircache.remove(key.latin1()); |
1458 | } | 1471 | } |
1459 | } | 1472 | } |
1460 | */ | 1473 | */ |
1461 | // save it for future calls - that will return | 1474 | // save it for future calls - that will return |
1462 | addedCustoms = true; | 1475 | addedCustoms = true; |
1463 | config->setGroup(oldGroup); | 1476 | config->setGroup(oldGroup); |
1464 | 1477 | ||
1465 | // return true if the number of config dirs changed | 1478 | // return true if the number of config dirs changed |
1466 | return (resourceDirs("config").count() != configdirs); | 1479 | return (resourceDirs("config").count() != configdirs); |
1467 | } | 1480 | } |
1468 | 1481 | ||
1469 | QString KStandardDirs::localkdedir() const | 1482 | QString KStandardDirs::localkdedir() const |
1470 | { | 1483 | { |
1471 | // Return the prefix to use for saving | 1484 | // Return the prefix to use for saving |
1472 | return prefixes.first(); | 1485 | return prefixes.first(); |
1473 | } | 1486 | } |
1474 | 1487 | ||
1475 | QString KStandardDirs::localxdgdatadir() const | 1488 | QString KStandardDirs::localxdgdatadir() const |
1476 | { | 1489 | { |
1477 | // Return the prefix to use for saving | 1490 | // Return the prefix to use for saving |
1478 | return d->xdgdata_prefixes.first(); | 1491 | return d->xdgdata_prefixes.first(); |
1479 | } | 1492 | } |
1480 | 1493 | ||
1481 | QString KStandardDirs::localxdgconfdir() const | 1494 | QString KStandardDirs::localxdgconfdir() const |
1482 | { | 1495 | { |
1483 | // Return the prefix to use for saving | 1496 | // Return the prefix to use for saving |