author | leseb <leseb> | 2002-08-30 18:10:11 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-08-30 18:10:11 (UTC) |
commit | b5ec106e5f612042987397a5a5b6683fdabaf793 (patch) (unidiff) | |
tree | 58da0aac60a7a39cca162fe222107c9e3d676dac | |
parent | f6125710c0ca99fc62ffce69973a168b6604f29d (diff) | |
download | opie-b5ec106e5f612042987397a5a5b6683fdabaf793.zip opie-b5ec106e5f612042987397a5a5b6683fdabaf793.tar.gz opie-b5ec106e5f612042987397a5a5b6683fdabaf793.tar.bz2 |
Try to handle RAM storage for documents
-rw-r--r-- | library/applnk.cpp | 2 | ||||
-rw-r--r-- | library/global.cpp | 4 | ||||
-rw-r--r-- | library/lnkproperties.cpp | 7 | ||||
-rw-r--r-- | library/storage.cpp | 14 |
4 files changed, 16 insertions, 11 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index 5185b5f..778ccab 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -1,727 +1,727 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_MIMEEXT | 21 | #define QTOPIA_INTERNAL_MIMEEXT |
22 | 22 | ||
23 | #include "applnk.h" | 23 | #include "applnk.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/categories.h> | 26 | #include <qpe/categories.h> |
27 | #include <qpe/categoryselect.h> | 27 | #include <qpe/categoryselect.h> |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | #include <qpe/global.h> | 29 | #include <qpe/global.h> |
30 | #include <qpe/mimetype.h> | 30 | #include <qpe/mimetype.h> |
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/storage.h> | 32 | #include <qpe/storage.h> |
33 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
34 | 34 | ||
35 | #include <qdict.h> | 35 | #include <qdict.h> |
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | #include <qregexp.h> | 37 | #include <qregexp.h> |
38 | 38 | ||
39 | #ifdef Q_WS_QWS | 39 | #ifdef Q_WS_QWS |
40 | #include <qgfx_qws.h> | 40 | #include <qgfx_qws.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | 44 | ||
45 | int AppLnk::lastId = 5000; | 45 | int AppLnk::lastId = 5000; |
46 | 46 | ||
47 | static int smallSize = 14; | 47 | static int smallSize = 14; |
48 | static int bigSize = 32; | 48 | static int bigSize = 32; |
49 | 49 | ||
50 | static QString safeFileName(const QString& n) | 50 | static QString safeFileName(const QString& n) |
51 | { | 51 | { |
52 | QString safename=n; | 52 | QString safename=n; |
53 | safename.replace(QRegExp("[^0-9A-Za-z.]"),"_"); // Njaard says this is broken | 53 | safename.replace(QRegExp("[^0-9A-Za-z.]"),"_"); // Njaard says this is broken |
54 | safename.replace(QRegExp("^[^A-Za-z]*"),""); | 54 | safename.replace(QRegExp("^[^A-Za-z]*"),""); |
55 | if ( safename.isEmpty() ) | 55 | if ( safename.isEmpty() ) |
56 | safename = "_"; | 56 | safename = "_"; |
57 | return safename; | 57 | return safename; |
58 | } | 58 | } |
59 | 59 | ||
60 | static bool prepareDirectories(const QString& lf) | 60 | static bool prepareDirectories(const QString& lf) |
61 | { | 61 | { |
62 | if ( !QFile::exists(lf) ) { | 62 | if ( !QFile::exists(lf) ) { |
63 | // May need to create directories | 63 | // May need to create directories |
64 | QFileInfo fi(lf); | 64 | QFileInfo fi(lf); |
65 | if ( system(("mkdir -p "+fi.dirPath(TRUE))) ) | 65 | if ( system(("mkdir -p "+fi.dirPath(TRUE))) ) |
66 | return FALSE; | 66 | return FALSE; |
67 | } | 67 | } |
68 | return TRUE; | 68 | return TRUE; |
69 | } | 69 | } |
70 | 70 | ||
71 | class AppLnkPrivate | 71 | class AppLnkPrivate |
72 | { | 72 | { |
73 | public: | 73 | public: |
74 | QArray<int> mCat; | 74 | QArray<int> mCat; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | /*! | 77 | /*! |
78 | \class AppLnk applnk.h | 78 | \class AppLnk applnk.h |
79 | \brief The AppLnk class represents an application available on the system. | 79 | \brief The AppLnk class represents an application available on the system. |
80 | 80 | ||
81 | Information about applications are stored in Qtopia as ".desktop" files. | 81 | Information about applications are stored in Qtopia as ".desktop" files. |
82 | When read, these files are stored as AppLnk objects. | 82 | When read, these files are stored as AppLnk objects. |
83 | */ | 83 | */ |
84 | 84 | ||
85 | /*! | 85 | /*! |
86 | Sets the size used for small icons to \a small pixels. | 86 | Sets the size used for small icons to \a small pixels. |
87 | Only affects AppLnk objects created after the call. | 87 | Only affects AppLnk objects created after the call. |
88 | */ | 88 | */ |
89 | void AppLnk::setSmallIconSize(int small) | 89 | void AppLnk::setSmallIconSize(int small) |
90 | { | 90 | { |
91 | smallSize = small; | 91 | smallSize = small; |
92 | } | 92 | } |
93 | 93 | ||
94 | /*! | 94 | /*! |
95 | Returns the size used for small icons. | 95 | Returns the size used for small icons. |
96 | */ | 96 | */ |
97 | int AppLnk::smallIconSize() | 97 | int AppLnk::smallIconSize() |
98 | { | 98 | { |
99 | return smallSize; | 99 | return smallSize; |
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | /*! | 103 | /*! |
104 | Sets the size used for large icons to \a big pixels. | 104 | Sets the size used for large icons to \a big pixels. |
105 | Only affects AppLnk objects created after the call. | 105 | Only affects AppLnk objects created after the call. |
106 | */ | 106 | */ |
107 | void AppLnk::setBigIconSize(int big) | 107 | void AppLnk::setBigIconSize(int big) |
108 | { | 108 | { |
109 | bigSize = big; | 109 | bigSize = big; |
110 | } | 110 | } |
111 | 111 | ||
112 | /*! | 112 | /*! |
113 | Returns the size used for large icons. | 113 | Returns the size used for large icons. |
114 | */ | 114 | */ |
115 | int AppLnk::bigIconSize() | 115 | int AppLnk::bigIconSize() |
116 | { | 116 | { |
117 | return bigSize; | 117 | return bigSize; |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | /*! | 121 | /*! |
122 | \fn QString AppLnk::name() const | 122 | \fn QString AppLnk::name() const |
123 | 123 | ||
124 | Returns the Name property. | 124 | Returns the Name property. |
125 | */ | 125 | */ |
126 | /*! | 126 | /*! |
127 | \fn QString AppLnk::exec() const | 127 | \fn QString AppLnk::exec() const |
128 | 128 | ||
129 | Returns the Exec property. This is the executable program associated | 129 | Returns the Exec property. This is the executable program associated |
130 | with the AppLnk. | 130 | with the AppLnk. |
131 | */ | 131 | */ |
132 | /*! | 132 | /*! |
133 | \fn QString AppLnk::rotation() const | 133 | \fn QString AppLnk::rotation() const |
134 | 134 | ||
135 | Returns the Rotation property. | 135 | Returns the Rotation property. |
136 | */ | 136 | */ |
137 | /*! | 137 | /*! |
138 | \fn QString AppLnk::comment() const | 138 | \fn QString AppLnk::comment() const |
139 | 139 | ||
140 | Returns the Comment property. | 140 | Returns the Comment property. |
141 | */ | 141 | */ |
142 | /*! | 142 | /*! |
143 | \fn QStringList AppLnk::mimeTypes() const | 143 | \fn QStringList AppLnk::mimeTypes() const |
144 | 144 | ||
145 | Returns the MimeTypes property. This is the list of MIME types | 145 | Returns the MimeTypes property. This is the list of MIME types |
146 | that the application can view or edit. | 146 | that the application can view or edit. |
147 | */ | 147 | */ |
148 | /*! | 148 | /*! |
149 | \fn const QArray<int>& AppLnk::categories() const | 149 | \fn const QArray<int>& AppLnk::categories() const |
150 | 150 | ||
151 | Returns the Categories property. | 151 | Returns the Categories property. |
152 | */ | 152 | */ |
153 | 153 | ||
154 | const QArray<int>& AppLnk::categories() const | 154 | const QArray<int>& AppLnk::categories() const |
155 | { | 155 | { |
156 | return d->mCat; | 156 | return d->mCat; |
157 | } | 157 | } |
158 | 158 | ||
159 | /*! | 159 | /*! |
160 | \fn int AppLnk::id() const | 160 | \fn int AppLnk::id() const |
161 | 161 | ||
162 | Returns the id of the AppLnk. If the AppLnk is not in an AppLnkSet, | 162 | Returns the id of the AppLnk. If the AppLnk is not in an AppLnkSet, |
163 | this value is 0, otherwise it is a value that is unique for the | 163 | this value is 0, otherwise it is a value that is unique for the |
164 | duration of the current process. | 164 | duration of the current process. |
165 | */ | 165 | */ |
166 | 166 | ||
167 | /*! | 167 | /*! |
168 | \fn bool AppLnk::isValid() const | 168 | \fn bool AppLnk::isValid() const |
169 | 169 | ||
170 | Returns whether this AppLnk is valid. | 170 | Returns whether this AppLnk is valid. |
171 | */ | 171 | */ |
172 | 172 | ||
173 | /*! | 173 | /*! |
174 | Creates an invalid AppLnk. | 174 | Creates an invalid AppLnk. |
175 | 175 | ||
176 | \sa isValid() | 176 | \sa isValid() |
177 | */ | 177 | */ |
178 | AppLnk::AppLnk() | 178 | AppLnk::AppLnk() |
179 | { | 179 | { |
180 | mId = 0; | 180 | mId = 0; |
181 | d = new AppLnkPrivate(); | 181 | d = new AppLnkPrivate(); |
182 | } | 182 | } |
183 | 183 | ||
184 | /*! | 184 | /*! |
185 | Loads \a file as an AppLnk. | 185 | Loads \a file as an AppLnk. |
186 | */ | 186 | */ |
187 | AppLnk::AppLnk( const QString &file ) | 187 | AppLnk::AppLnk( const QString &file ) |
188 | { | 188 | { |
189 | QStringList sl; | 189 | QStringList sl; |
190 | d = new AppLnkPrivate(); | 190 | d = new AppLnkPrivate(); |
191 | if ( !file.isNull() ) { | 191 | if ( !file.isNull() ) { |
192 | Config config( file, Config::File ); | 192 | Config config( file, Config::File ); |
193 | 193 | ||
194 | if ( config.isValid() ) { | 194 | if ( config.isValid() ) { |
195 | config.setGroup( "Desktop Entry" ); | 195 | config.setGroup( "Desktop Entry" ); |
196 | 196 | ||
197 | mName = config.readEntry( "Name", file ); | 197 | mName = config.readEntry( "Name", file ); |
198 | mExec = config.readEntry( "Exec" ); | 198 | mExec = config.readEntry( "Exec" ); |
199 | mType = config.readEntry( "Type", QString::null ); | 199 | mType = config.readEntry( "Type", QString::null ); |
200 | mIconFile = config.readEntry( "Icon", QString::null ); | 200 | mIconFile = config.readEntry( "Icon", QString::null ); |
201 | mRotation = config.readEntry( "Rotation", "" ); | 201 | mRotation = config.readEntry( "Rotation", "" ); |
202 | mComment = config.readEntry( "Comment", QString::null ); | 202 | mComment = config.readEntry( "Comment", QString::null ); |
203 | mMimeTypes = config.readListEntry( "MimeType", ';' ); | 203 | mMimeTypes = config.readListEntry( "MimeType", ';' ); |
204 | mMimeTypeIcons = config.readListEntry( "MimeTypeIcons", ';' ); | 204 | mMimeTypeIcons = config.readListEntry( "MimeTypeIcons", ';' ); |
205 | mLinkFile = file; | 205 | mLinkFile = file; |
206 | mFile = config.readEntry("File", QString::null); | 206 | mFile = config.readEntry("File", QString::null); |
207 | sl = config.readListEntry("Categories", ';'); | 207 | sl = config.readListEntry("Categories", ';'); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | // let's try our darndest to create categories... | 210 | // let's try our darndest to create categories... |
211 | Categories cat( 0 ); | 211 | Categories cat( 0 ); |
212 | cat.load( categoryFileName() ); | 212 | cat.load( categoryFileName() ); |
213 | d->mCat.resize( sl.count() ); | 213 | d->mCat.resize( sl.count() ); |
214 | int i; | 214 | int i; |
215 | QStringList::Iterator it; | 215 | QStringList::Iterator it; |
216 | for ( i = 0, it = sl.begin(); it != sl.end(); | 216 | for ( i = 0, it = sl.begin(); it != sl.end(); |
217 | ++it, i++ ) { | 217 | ++it, i++ ) { |
218 | 218 | ||
219 | bool number; | 219 | bool number; |
220 | int id = (*it).toInt( &number ); | 220 | int id = (*it).toInt( &number ); |
221 | if ( !number ) { | 221 | if ( !number ) { |
222 | // convert from old school... | 222 | // convert from old school... |
223 | id = cat.id( "Document Viewer", *it ); | 223 | id = cat.id( "Document Viewer", *it ); |
224 | if ( id == 0 ) | 224 | if ( id == 0 ) |
225 | id = cat.addCategory( "Document Viewer", *it ); | 225 | id = cat.addCategory( "Document Viewer", *it ); |
226 | } | 226 | } |
227 | d->mCat[i] = id; | 227 | d->mCat[i] = id; |
228 | } | 228 | } |
229 | mId = 0; | 229 | mId = 0; |
230 | } | 230 | } |
231 | 231 | ||
232 | /*! | 232 | /*! |
233 | Returns a small pixmap associated with the application. | 233 | Returns a small pixmap associated with the application. |
234 | */ | 234 | */ |
235 | const QPixmap& AppLnk::pixmap() const | 235 | const QPixmap& AppLnk::pixmap() const |
236 | { | 236 | { |
237 | if ( mPixmap.isNull() ) { | 237 | if ( mPixmap.isNull() ) { |
238 | AppLnk* that = (AppLnk*)this; | 238 | AppLnk* that = (AppLnk*)this; |
239 | if ( mIconFile.isEmpty() ) { | 239 | if ( mIconFile.isEmpty() ) { |
240 | MimeType mt(type()); | 240 | MimeType mt(type()); |
241 | that->mPixmap = mt.pixmap(); | 241 | that->mPixmap = mt.pixmap(); |
242 | if ( that->mPixmap.isNull() ) | 242 | if ( that->mPixmap.isNull() ) |
243 | that->mPixmap = Resource::loadPixmap("UnknownDocument-14"); | 243 | that->mPixmap = Resource::loadPixmap("UnknownDocument-14"); |
244 | return that->mPixmap; | 244 | return that->mPixmap; |
245 | } | 245 | } |
246 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); | 246 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); |
247 | that->mPixmap.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | 247 | that->mPixmap.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); |
248 | that->mBigPixmap.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | 248 | that->mBigPixmap.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); |
249 | return that->mPixmap; | 249 | return that->mPixmap; |
250 | } | 250 | } |
251 | return mPixmap; | 251 | return mPixmap; |
252 | } | 252 | } |
253 | 253 | ||
254 | /*! | 254 | /*! |
255 | Returns a large pixmap associated with the application. | 255 | Returns a large pixmap associated with the application. |
256 | */ | 256 | */ |
257 | const QPixmap& AppLnk::bigPixmap() const | 257 | const QPixmap& AppLnk::bigPixmap() const |
258 | { | 258 | { |
259 | if ( mBigPixmap.isNull() ) { | 259 | if ( mBigPixmap.isNull() ) { |
260 | AppLnk* that = (AppLnk*)this; | 260 | AppLnk* that = (AppLnk*)this; |
261 | if ( mIconFile.isEmpty() ) { | 261 | if ( mIconFile.isEmpty() ) { |
262 | MimeType mt(type()); | 262 | MimeType mt(type()); |
263 | that->mBigPixmap = mt.bigPixmap(); | 263 | that->mBigPixmap = mt.bigPixmap(); |
264 | if ( that->mBigPixmap.isNull() ) | 264 | if ( that->mBigPixmap.isNull() ) |
265 | that->mBigPixmap = Resource::loadPixmap("UnknownDocument"); | 265 | that->mBigPixmap = Resource::loadPixmap("UnknownDocument"); |
266 | return that->mBigPixmap; | 266 | return that->mBigPixmap; |
267 | } | 267 | } |
268 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); | 268 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); |
269 | that->mPixmap.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | 269 | that->mPixmap.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); |
270 | that->mBigPixmap.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | 270 | that->mBigPixmap.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); |
271 | return that->mBigPixmap; | 271 | return that->mBigPixmap; |
272 | } | 272 | } |
273 | return mBigPixmap; | 273 | return mBigPixmap; |
274 | } | 274 | } |
275 | 275 | ||
276 | /*! | 276 | /*! |
277 | Returns the type of the application. | 277 | Returns the type of the application. |
278 | */ | 278 | */ |
279 | QString AppLnk::type() const | 279 | QString AppLnk::type() const |
280 | { | 280 | { |
281 | if ( mType.isNull() ) { | 281 | if ( mType.isNull() ) { |
282 | AppLnk* that = (AppLnk*)this; | 282 | AppLnk* that = (AppLnk*)this; |
283 | MimeType mt(file()); | 283 | MimeType mt(file()); |
284 | that->mType = mt.id(); | 284 | that->mType = mt.id(); |
285 | return that->mType; | 285 | return that->mType; |
286 | } | 286 | } |
287 | return mType; | 287 | return mType; |
288 | } | 288 | } |
289 | 289 | ||
290 | /*! | 290 | /*! |
291 | Returns the file associated with the AppLnk. | 291 | Returns the file associated with the AppLnk. |
292 | 292 | ||
293 | \sa exec() | 293 | \sa exec() |
294 | */ | 294 | */ |
295 | QString AppLnk::file() const | 295 | QString AppLnk::file() const |
296 | { | 296 | { |
297 | if ( mFile.isNull() ) { | 297 | if ( mFile.isNull() ) { |
298 | AppLnk* that = (AppLnk*)this; // copy? | 298 | AppLnk* that = (AppLnk*)this; // copy? |
299 | QString ext = MimeType(mType).extension(); | 299 | QString ext = MimeType(mType).extension(); |
300 | if ( !ext.isEmpty() ) | 300 | if ( !ext.isEmpty() ) |
301 | ext = "." + ext; | 301 | ext = "." + ext; |
302 | if ( !mLinkFile.isEmpty() ) { | 302 | if ( !mLinkFile.isEmpty() ) { |
303 | that->mFile = | 303 | that->mFile = |
304 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") | 304 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") |
305 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; | 305 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; |
306 | } else if ( mType.contains('/') ) { | 306 | } else if ( mType.contains('/') ) { |
307 | that->mFile = | 307 | that->mFile = |
308 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); | 308 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); |
309 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { // a .desktop with the same name exists | 309 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { // a .desktop with the same name exists |
310 | int n=1; | 310 | int n=1; |
311 | qWarning("AppLnk::file() n=1 %s", that->mFile.latin1() ); | 311 | qWarning("AppLnk::file() n=1 %s", that->mFile.latin1() ); |
312 | QString nn; | 312 | QString nn; |
313 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) | 313 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) |
314 | || QFile::exists(nn+".desktop")) | 314 | || QFile::exists(nn+".desktop")) |
315 | n++; | 315 | n++; |
316 | that->mFile = nn; | 316 | that->mFile = nn; |
317 | qWarning("AppLnl::file() now mFile is %s", that->mFile.latin1() ); | 317 | qWarning("AppLnl::file() now mFile is %s", that->mFile.latin1() ); |
318 | } | 318 | } |
319 | that->mLinkFile = that->mFile+".desktop"; | 319 | that->mLinkFile = that->mFile+".desktop"; |
320 | that->mFile += ext; | 320 | that->mFile += ext; |
321 | } | 321 | } |
322 | prepareDirectories(that->mFile); | 322 | prepareDirectories(that->mFile); |
323 | QFile f(that->mFile); | 323 | QFile f(that->mFile); |
324 | if ( !f.open(IO_WriteOnly) ) | 324 | if ( !f.open(IO_WriteOnly) ) |
325 | that->mFile = QString::null; | 325 | that->mFile = QString::null; |
326 | return that->mFile; | 326 | return that->mFile; |
327 | } | 327 | } |
328 | return mFile; | 328 | return mFile; |
329 | } | 329 | } |
330 | 330 | ||
331 | /*! | 331 | /*! |
332 | Returns the desktop file coresponding to this AppLnk. | 332 | Returns the desktop file coresponding to this AppLnk. |
333 | 333 | ||
334 | \sa file(), exec() | 334 | \sa file(), exec() |
335 | */ | 335 | */ |
336 | QString AppLnk::linkFile() const | 336 | QString AppLnk::linkFile() const |
337 | { | 337 | { |
338 | if ( mLinkFile.isNull() ) { | 338 | if ( mLinkFile.isNull() ) { |
339 | AppLnk* that = (AppLnk*)this; | 339 | AppLnk* that = (AppLnk*)this; |
340 | if ( type().contains('/') ) { | 340 | if ( type().contains('/') ) { |
341 | StorageInfo storage; | 341 | StorageInfo storage; |
342 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); | 342 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); |
343 | if ( fs && fs->isRemovable() ) { | 343 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs" ) ) { |
344 | that->mLinkFile = fs->path(); | 344 | that->mLinkFile = fs->path(); |
345 | } else | 345 | } else |
346 | that->mLinkFile = getenv( "HOME" ); | 346 | that->mLinkFile = getenv( "HOME" ); |
347 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); | 347 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); |
348 | if ( QFile::exists(that->mLinkFile+".desktop") ) { // ok the file exists lets check if we point to the same file | 348 | if ( QFile::exists(that->mLinkFile+".desktop") ) { // ok the file exists lets check if we point to the same file |
349 | int n=1; | 349 | int n=1; |
350 | QString nn; | 350 | QString nn; |
351 | AppLnk lnk( that->mLinkFile+".desktop" ); | 351 | AppLnk lnk( that->mLinkFile+".desktop" ); |
352 | if(that->file() != lnk.file() ){ | 352 | if(that->file() != lnk.file() ){ |
353 | qWarning("AppLnk::linkFile exists %s", that->mLinkFile.latin1() ); | 353 | qWarning("AppLnk::linkFile exists %s", that->mLinkFile.latin1() ); |
354 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")){ | 354 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")){ |
355 | n++; | 355 | n++; |
356 | AppLnk lnk(nn ); // just to be sure | 356 | AppLnk lnk(nn ); // just to be sure |
357 | if(lnk.file() ==that->file() ){ | 357 | if(lnk.file() ==that->file() ){ |
358 | break; | 358 | break; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | that->mLinkFile = nn; | 361 | that->mLinkFile = nn; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | that->mLinkFile += ".desktop"; | 364 | that->mLinkFile += ".desktop"; |
365 | qWarning("AppLnk::linkFile is %s", that->mLinkFile.latin1() ); | 365 | qWarning("AppLnk::linkFile is %s", that->mLinkFile.latin1() ); |
366 | storeLink(); | 366 | storeLink(); |
367 | } | 367 | } |
368 | return that->mLinkFile; | 368 | return that->mLinkFile; |
369 | } | 369 | } |
370 | return mLinkFile; | 370 | return mLinkFile; |
371 | } | 371 | } |
372 | 372 | ||
373 | /*! | 373 | /*! |
374 | Copies \a copy. | 374 | Copies \a copy. |
375 | */ | 375 | */ |
376 | AppLnk::AppLnk( const AppLnk © ) | 376 | AppLnk::AppLnk( const AppLnk © ) |
377 | { | 377 | { |
378 | mName = copy.mName; | 378 | mName = copy.mName; |
379 | mPixmap = copy.mPixmap; | 379 | mPixmap = copy.mPixmap; |
380 | mBigPixmap = copy.mBigPixmap; | 380 | mBigPixmap = copy.mBigPixmap; |
381 | mExec = copy.mExec; | 381 | mExec = copy.mExec; |
382 | mType = copy.mType; | 382 | mType = copy.mType; |
383 | mRotation = copy.mRotation; | 383 | mRotation = copy.mRotation; |
384 | mComment = copy.mComment; | 384 | mComment = copy.mComment; |
385 | mFile = copy.mFile; | 385 | mFile = copy.mFile; |
386 | mLinkFile = copy.mLinkFile; | 386 | mLinkFile = copy.mLinkFile; |
387 | mIconFile = copy.mIconFile; | 387 | mIconFile = copy.mIconFile; |
388 | mMimeTypes = copy.mMimeTypes; | 388 | mMimeTypes = copy.mMimeTypes; |
389 | mMimeTypeIcons = copy.mMimeTypeIcons; | 389 | mMimeTypeIcons = copy.mMimeTypeIcons; |
390 | mId = 0; | 390 | mId = 0; |
391 | d = new AppLnkPrivate(); | 391 | d = new AppLnkPrivate(); |
392 | d->mCat = copy.d->mCat; | 392 | d->mCat = copy.d->mCat; |
393 | } | 393 | } |
394 | 394 | ||
395 | /*! | 395 | /*! |
396 | Destroys the AppLnk. Note that if the AppLnk is current a member of | 396 | Destroys the AppLnk. Note that if the AppLnk is current a member of |
397 | an AppLnkSet, this will produce a run-time warning. | 397 | an AppLnkSet, this will produce a run-time warning. |
398 | 398 | ||
399 | \sa AppLnkSet::add(), AppLnkSet::remove() | 399 | \sa AppLnkSet::add(), AppLnkSet::remove() |
400 | */ | 400 | */ |
401 | AppLnk::~AppLnk() | 401 | AppLnk::~AppLnk() |
402 | { | 402 | { |
403 | if ( mId ) | 403 | if ( mId ) |
404 | qWarning("Deleting AppLnk that is in an AppLnkSet"); | 404 | qWarning("Deleting AppLnk that is in an AppLnkSet"); |
405 | if ( d ) | 405 | if ( d ) |
406 | delete d; | 406 | delete d; |
407 | } | 407 | } |
408 | 408 | ||
409 | /*! | 409 | /*! |
410 | Executes the application associated with this AppLnk. | 410 | Executes the application associated with this AppLnk. |
411 | */ | 411 | */ |
412 | void AppLnk::execute() const | 412 | void AppLnk::execute() const |
413 | { | 413 | { |
414 | execute(QStringList()); | 414 | execute(QStringList()); |
415 | } | 415 | } |
416 | 416 | ||
417 | /*! | 417 | /*! |
418 | Executes the application associated with this AppLnk, with | 418 | Executes the application associated with this AppLnk, with |
419 | \a args as arguments. | 419 | \a args as arguments. |
420 | */ | 420 | */ |
421 | void AppLnk::execute(const QStringList& args) const | 421 | void AppLnk::execute(const QStringList& args) const |
422 | { | 422 | { |
423 | #ifdef Q_WS_QWS | 423 | #ifdef Q_WS_QWS |
424 | if ( !mRotation.isEmpty() ) { | 424 | if ( !mRotation.isEmpty() ) { |
425 | // ######## this will only work in the server | 425 | // ######## this will only work in the server |
426 | int rot = QPEApplication::defaultRotation(); | 426 | int rot = QPEApplication::defaultRotation(); |
427 | rot = (rot+mRotation.toInt())%360; | 427 | rot = (rot+mRotation.toInt())%360; |
428 | QCString old = getenv("QWS_DISPLAY"); | 428 | QCString old = getenv("QWS_DISPLAY"); |
429 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); | 429 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); |
430 | invoke(args); | 430 | invoke(args); |
431 | setenv("QWS_DISPLAY", old.data(), 1); | 431 | setenv("QWS_DISPLAY", old.data(), 1); |
432 | } else | 432 | } else |
433 | #endif | 433 | #endif |
434 | invoke(args); | 434 | invoke(args); |
435 | } | 435 | } |
436 | 436 | ||
437 | /*! | 437 | /*! |
438 | Invokes the application associated with this AppLnk, with | 438 | Invokes the application associated with this AppLnk, with |
439 | \a args as arguments. Rotation is not taken into account by | 439 | \a args as arguments. Rotation is not taken into account by |
440 | this function, you should not call it directly. | 440 | this function, you should not call it directly. |
441 | 441 | ||
442 | \sa execute() | 442 | \sa execute() |
443 | */ | 443 | */ |
444 | void AppLnk::invoke(const QStringList& args) const | 444 | void AppLnk::invoke(const QStringList& args) const |
445 | { | 445 | { |
446 | Global::execute( exec(), args[0] ); | 446 | Global::execute( exec(), args[0] ); |
447 | } | 447 | } |
448 | 448 | ||
449 | /*! | 449 | /*! |
450 | Sets the Exec property to \a exec. | 450 | Sets the Exec property to \a exec. |
451 | 451 | ||
452 | \sa exec() | 452 | \sa exec() |
453 | */ | 453 | */ |
454 | void AppLnk::setExec( const QString& exec ) | 454 | void AppLnk::setExec( const QString& exec ) |
455 | { | 455 | { |
456 | mExec = exec; | 456 | mExec = exec; |
457 | } | 457 | } |
458 | 458 | ||
459 | /*! | 459 | /*! |
460 | Sets the Name property to \a docname. | 460 | Sets the Name property to \a docname. |
461 | 461 | ||
462 | \sa name() | 462 | \sa name() |
463 | */ | 463 | */ |
464 | void AppLnk::setName( const QString& docname ) | 464 | void AppLnk::setName( const QString& docname ) |
465 | { | 465 | { |
466 | mName = docname; | 466 | mName = docname; |
467 | } | 467 | } |
468 | 468 | ||
469 | /*! | 469 | /*! |
470 | Sets the File property to \a filename. | 470 | Sets the File property to \a filename. |
471 | 471 | ||
472 | \sa file() | 472 | \sa file() |
473 | */ | 473 | */ |
474 | void AppLnk::setFile( const QString& filename ) | 474 | void AppLnk::setFile( const QString& filename ) |
475 | { | 475 | { |
476 | mFile = filename; | 476 | mFile = filename; |
477 | } | 477 | } |
478 | 478 | ||
479 | /*! | 479 | /*! |
480 | Sets the LinkFile property to \a filename. | 480 | Sets the LinkFile property to \a filename. |
481 | 481 | ||
482 | \sa linkFile() | 482 | \sa linkFile() |
483 | */ | 483 | */ |
484 | void AppLnk::setLinkFile( const QString& filename ) | 484 | void AppLnk::setLinkFile( const QString& filename ) |
485 | { | 485 | { |
486 | mLinkFile = filename; | 486 | mLinkFile = filename; |
487 | } | 487 | } |
488 | 488 | ||
489 | /*! | 489 | /*! |
490 | Sets the Comment property to \a comment. | 490 | Sets the Comment property to \a comment. |
491 | 491 | ||
492 | \sa comment() | 492 | \sa comment() |
493 | */ | 493 | */ |
494 | void AppLnk::setComment( const QString& comment ) | 494 | void AppLnk::setComment( const QString& comment ) |
495 | { | 495 | { |
496 | mComment = comment; | 496 | mComment = comment; |
497 | } | 497 | } |
498 | 498 | ||
499 | /*! | 499 | /*! |
500 | Sets the Type property to \a type. | 500 | Sets the Type property to \a type. |
501 | 501 | ||
502 | \sa type() | 502 | \sa type() |
503 | */ | 503 | */ |
504 | void AppLnk::setType( const QString& type ) | 504 | void AppLnk::setType( const QString& type ) |
505 | { | 505 | { |
506 | mType = type; | 506 | mType = type; |
507 | } | 507 | } |
508 | 508 | ||
509 | /*! | 509 | /*! |
510 | Sets the Icon property to \a iconname. | 510 | Sets the Icon property to \a iconname. |
511 | 511 | ||
512 | \sa pixmap(), bigPixmap() | 512 | \sa pixmap(), bigPixmap() |
513 | */ | 513 | */ |
514 | void AppLnk::setIcon( const QString& iconname ) | 514 | void AppLnk::setIcon( const QString& iconname ) |
515 | { | 515 | { |
516 | mIconFile = iconname; | 516 | mIconFile = iconname; |
517 | QImage unscaledIcon = Resource::loadImage( mIconFile ); | 517 | QImage unscaledIcon = Resource::loadImage( mIconFile ); |
518 | mPixmap.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | 518 | mPixmap.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); |
519 | mBigPixmap.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | 519 | mBigPixmap.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); |
520 | } | 520 | } |
521 | 521 | ||
522 | /*! | 522 | /*! |
523 | Sets the Categories property to \a c. | 523 | Sets the Categories property to \a c. |
524 | 524 | ||
525 | \sa categories() | 525 | \sa categories() |
526 | */ | 526 | */ |
527 | void AppLnk::setCategories( const QArray<int>& c ) | 527 | void AppLnk::setCategories( const QArray<int>& c ) |
528 | { | 528 | { |
529 | d->mCat = c; | 529 | d->mCat = c; |
530 | } | 530 | } |
531 | 531 | ||
532 | /*! | 532 | /*! |
533 | \fn QStringList AppLnk::mimeTypeIcons() const | 533 | \fn QStringList AppLnk::mimeTypeIcons() const |
534 | 534 | ||
535 | Returns the MimeTypeIcons property of the AppLnk. | 535 | Returns the MimeTypeIcons property of the AppLnk. |
536 | */ | 536 | */ |
537 | 537 | ||
538 | /*! | 538 | /*! |
539 | Attempts to ensure that the link file for this AppLnk exists, including | 539 | Attempts to ensure that the link file for this AppLnk exists, including |
540 | creating any required directories. Returns TRUE if successful. | 540 | creating any required directories. Returns TRUE if successful. |
541 | */ | 541 | */ |
542 | bool AppLnk::ensureLinkExists() const | 542 | bool AppLnk::ensureLinkExists() const |
543 | { | 543 | { |
544 | QString lf = linkFile(); | 544 | QString lf = linkFile(); |
545 | return prepareDirectories(lf); | 545 | return prepareDirectories(lf); |
546 | } | 546 | } |
547 | 547 | ||
548 | /*! | 548 | /*! |
549 | Commits the AppLnk to disk. Returns whether the operation succeeded. | 549 | Commits the AppLnk to disk. Returns whether the operation succeeded. |
550 | 550 | ||
551 | The "linkChanged(QString)" message is sent to the | 551 | The "linkChanged(QString)" message is sent to the |
552 | "QPE/System" QCop channel as a result. | 552 | "QPE/System" QCop channel as a result. |
553 | */ | 553 | */ |
554 | bool AppLnk::writeLink() const | 554 | bool AppLnk::writeLink() const |
555 | { | 555 | { |
556 | // Only re-writes settable parts | 556 | // Only re-writes settable parts |
557 | QString lf = linkFile(); | 557 | QString lf = linkFile(); |
558 | if ( !ensureLinkExists() ) | 558 | if ( !ensureLinkExists() ) |
559 | return FALSE; | 559 | return FALSE; |
560 | storeLink(); | 560 | storeLink(); |
561 | return TRUE; | 561 | return TRUE; |
562 | } | 562 | } |
563 | 563 | ||
564 | void AppLnk::storeLink() const | 564 | void AppLnk::storeLink() const |
565 | { | 565 | { |
566 | Config config( mLinkFile, Config::File ); | 566 | Config config( mLinkFile, Config::File ); |
567 | config.setGroup("Desktop Entry"); | 567 | config.setGroup("Desktop Entry"); |
568 | config.writeEntry("Name",mName); | 568 | config.writeEntry("Name",mName); |
569 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); | 569 | if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile); |
570 | config.writeEntry("Type",type()); | 570 | config.writeEntry("Type",type()); |
571 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); | 571 | if ( !mComment.isNull() ) config.writeEntry("Comment",mComment); |
572 | config.writeEntry("File",file()); | 572 | config.writeEntry("File",file()); |
573 | // write out the id... | 573 | // write out the id... |
574 | int i; | 574 | int i; |
575 | QStringList sl; | 575 | QStringList sl; |
576 | for ( i = 0; i < int(d->mCat.count()); i++ ) { | 576 | for ( i = 0; i < int(d->mCat.count()); i++ ) { |
577 | sl.append( QString::number( d->mCat[i] ) ); | 577 | sl.append( QString::number( d->mCat[i] ) ); |
578 | } | 578 | } |
579 | config.writeEntry( "Categories", sl, ';' ); | 579 | config.writeEntry( "Categories", sl, ';' ); |
580 | 580 | ||
581 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 581 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
582 | e << mLinkFile; | 582 | e << mLinkFile; |
583 | } | 583 | } |
584 | 584 | ||
585 | /*! | 585 | /*! |
586 | Sets the property named \a key to \a value. | 586 | Sets the property named \a key to \a value. |
587 | */ | 587 | */ |
588 | void AppLnk::setProperty(const QString& key, const QString& value) | 588 | void AppLnk::setProperty(const QString& key, const QString& value) |
589 | { | 589 | { |
590 | if ( ensureLinkExists() ) { | 590 | if ( ensureLinkExists() ) { |
591 | Config cfg(linkFile(), Config::File); | 591 | Config cfg(linkFile(), Config::File); |
592 | cfg.writeEntry(key,value); | 592 | cfg.writeEntry(key,value); |
593 | } | 593 | } |
594 | } | 594 | } |
595 | 595 | ||
596 | /*! | 596 | /*! |
597 | Returns the property named \a key. | 597 | Returns the property named \a key. |
598 | */ | 598 | */ |
599 | QString AppLnk::property(const QString& key) const | 599 | QString AppLnk::property(const QString& key) const |
600 | { | 600 | { |
601 | QString lf = linkFile(); | 601 | QString lf = linkFile(); |
602 | if ( !QFile::exists(lf) ) | 602 | if ( !QFile::exists(lf) ) |
603 | return QString::null; | 603 | return QString::null; |
604 | Config cfg(lf, Config::File); | 604 | Config cfg(lf, Config::File); |
605 | return cfg.readEntry(key); | 605 | return cfg.readEntry(key); |
606 | } | 606 | } |
607 | 607 | ||
608 | 608 | ||
609 | /*! | 609 | /*! |
610 | Deletes both the linkFile() and file() associated with this AppLnk. | 610 | Deletes both the linkFile() and file() associated with this AppLnk. |
611 | */ | 611 | */ |
612 | void AppLnk::removeFiles() | 612 | void AppLnk::removeFiles() |
613 | { | 613 | { |
614 | bool valid = isValid(); | 614 | bool valid = isValid(); |
615 | if ( !valid || !linkFileKnown() || QFile::remove(linkFile()) ) { | 615 | if ( !valid || !linkFileKnown() || QFile::remove(linkFile()) ) { |
616 | if ( QFile::remove(file()) ) { | 616 | if ( QFile::remove(file()) ) { |
617 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 617 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
618 | if ( linkFileKnown() ) | 618 | if ( linkFileKnown() ) |
619 | e << linkFile(); | 619 | e << linkFile(); |
620 | else | 620 | else |
621 | e << file(); | 621 | e << file(); |
622 | } else if ( valid ) { | 622 | } else if ( valid ) { |
623 | // restore link | 623 | // restore link |
624 | writeLink(); | 624 | writeLink(); |
625 | } | 625 | } |
626 | } | 626 | } |
627 | } | 627 | } |
628 | 628 | ||
629 | /*! | 629 | /*! |
630 | Delete the linkFile(), leaving any file() untouched. | 630 | Delete the linkFile(), leaving any file() untouched. |
631 | */ | 631 | */ |
632 | void AppLnk::removeLinkFile() | 632 | void AppLnk::removeLinkFile() |
633 | { | 633 | { |
634 | if ( isValid() && linkFileKnown() && QFile::remove(linkFile()) ) { | 634 | if ( isValid() && linkFileKnown() && QFile::remove(linkFile()) ) { |
635 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 635 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
636 | e << linkFile(); | 636 | e << linkFile(); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | 639 | ||
640 | class AppLnkSetPrivate { | 640 | class AppLnkSetPrivate { |
641 | public: | 641 | public: |
642 | AppLnkSetPrivate() | 642 | AppLnkSetPrivate() |
643 | { | 643 | { |
644 | typPix.setAutoDelete(TRUE); | 644 | typPix.setAutoDelete(TRUE); |
645 | typPixBig.setAutoDelete(TRUE); | 645 | typPixBig.setAutoDelete(TRUE); |
646 | typName.setAutoDelete(TRUE); | 646 | typName.setAutoDelete(TRUE); |
647 | } | 647 | } |
648 | 648 | ||
649 | QDict<QPixmap> typPix; | 649 | QDict<QPixmap> typPix; |
650 | QDict<QPixmap> typPixBig; | 650 | QDict<QPixmap> typPixBig; |
651 | QDict<QString> typName; | 651 | QDict<QString> typName; |
652 | }; | 652 | }; |
653 | 653 | ||
654 | /*! | 654 | /*! |
655 | \class AppLnkSet applnk.h | 655 | \class AppLnkSet applnk.h |
656 | \brief The AppLnkSet class is a set of AppLnk objects. | 656 | \brief The AppLnkSet class is a set of AppLnk objects. |
657 | */ | 657 | */ |
658 | 658 | ||
659 | /*! | 659 | /*! |
660 | \fn QStringList AppLnkSet::types() const | 660 | \fn QStringList AppLnkSet::types() const |
661 | 661 | ||
662 | Returns the list of types in the set. | 662 | Returns the list of types in the set. |
663 | 663 | ||
664 | \sa AppLnk::type(), typeName(), typePixmap(), typeBigPixmap() | 664 | \sa AppLnk::type(), typeName(), typePixmap(), typeBigPixmap() |
665 | */ | 665 | */ |
666 | 666 | ||
667 | /*! | 667 | /*! |
668 | \fn const QList<AppLnk>& AppLnkSet::children() const | 668 | \fn const QList<AppLnk>& AppLnkSet::children() const |
669 | 669 | ||
670 | Returns the members of the set. | 670 | Returns the members of the set. |
671 | */ | 671 | */ |
672 | 672 | ||
673 | /*! | 673 | /*! |
674 | Constructs an empty AppLnkSet. | 674 | Constructs an empty AppLnkSet. |
675 | */ | 675 | */ |
676 | AppLnkSet::AppLnkSet() : | 676 | AppLnkSet::AppLnkSet() : |
677 | d(new AppLnkSetPrivate) | 677 | d(new AppLnkSetPrivate) |
678 | { | 678 | { |
679 | } | 679 | } |
680 | 680 | ||
681 | /*! | 681 | /*! |
682 | Constructs an AppLnkSet that contains AppLnk objects representing | 682 | Constructs an AppLnkSet that contains AppLnk objects representing |
683 | all the files in a \a directory (recursively). | 683 | all the files in a \a directory (recursively). |
684 | 684 | ||
685 | The directories may contain ".directory" files which overrides | 685 | The directories may contain ".directory" files which overrides |
686 | any AppLnk::type() value of AppLnk objects found in the directory. | 686 | any AppLnk::type() value of AppLnk objects found in the directory. |
687 | This allows simple localization of application types. | 687 | This allows simple localization of application types. |
688 | */ | 688 | */ |
689 | AppLnkSet::AppLnkSet( const QString &directory ) : | 689 | AppLnkSet::AppLnkSet( const QString &directory ) : |
690 | d(new AppLnkSetPrivate) | 690 | d(new AppLnkSetPrivate) |
691 | { | 691 | { |
692 | QDir dir( directory ); | 692 | QDir dir( directory ); |
693 | mFile = directory; | 693 | mFile = directory; |
694 | findChildren(directory,QString::null,QString::null); | 694 | findChildren(directory,QString::null,QString::null); |
695 | } | 695 | } |
696 | 696 | ||
697 | /*! | 697 | /*! |
698 | Detaches all AppLnk objects from the set. The set become empty | 698 | Detaches all AppLnk objects from the set. The set become empty |
699 | and the call becomes responsible for deleting the AppLnk objects. | 699 | and the call becomes responsible for deleting the AppLnk objects. |
700 | */ | 700 | */ |
701 | void AppLnkSet::detachChildren() | 701 | void AppLnkSet::detachChildren() |
702 | { | 702 | { |
703 | QListIterator<AppLnk> it( mApps ); | 703 | QListIterator<AppLnk> it( mApps ); |
704 | for ( ; it.current(); ) { | 704 | for ( ; it.current(); ) { |
705 | AppLnk* a = *it; | 705 | AppLnk* a = *it; |
706 | ++it; | 706 | ++it; |
707 | a->mId = 0; | 707 | a->mId = 0; |
708 | } | 708 | } |
709 | mApps.clear(); | 709 | mApps.clear(); |
710 | } | 710 | } |
711 | 711 | ||
712 | /*! | 712 | /*! |
713 | Destroys the set, deleting all AppLnk objects it contains. | 713 | Destroys the set, deleting all AppLnk objects it contains. |
714 | 714 | ||
715 | \sa detachChildren() | 715 | \sa detachChildren() |
716 | */ | 716 | */ |
717 | AppLnkSet::~AppLnkSet() | 717 | AppLnkSet::~AppLnkSet() |
718 | { | 718 | { |
719 | QListIterator<AppLnk> it( mApps ); | 719 | QListIterator<AppLnk> it( mApps ); |
720 | for ( ; it.current(); ) { | 720 | for ( ; it.current(); ) { |
721 | AppLnk* a = *it; | 721 | AppLnk* a = *it; |
722 | ++it; | 722 | ++it; |
723 | a->mId = 0; | 723 | a->mId = 0; |
724 | delete a; | 724 | delete a; |
725 | } | 725 | } |
726 | delete d; | 726 | delete d; |
727 | } | 727 | } |
diff --git a/library/global.cpp b/library/global.cpp index edb7b85..ab27b3f 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -300,427 +300,431 @@ void Global::addWords(const QString& dictname, const QStringList& wordlist) | |||
300 | QString Global::applicationFileName(const QString& appname, const QString& filename) | 300 | QString Global::applicationFileName(const QString& appname, const QString& filename) |
301 | { | 301 | { |
302 | QDir d; | 302 | QDir d; |
303 | QString r = getenv("HOME"); | 303 | QString r = getenv("HOME"); |
304 | r += "/Applications/"; | 304 | r += "/Applications/"; |
305 | if ( !QFile::exists( r ) ) | 305 | if ( !QFile::exists( r ) ) |
306 | if ( d.mkdir(r) == false ) | 306 | if ( d.mkdir(r) == false ) |
307 | return QString::null; | 307 | return QString::null; |
308 | r += appname; | 308 | r += appname; |
309 | if ( !QFile::exists( r ) ) | 309 | if ( !QFile::exists( r ) ) |
310 | if ( d.mkdir(r) == false ) | 310 | if ( d.mkdir(r) == false ) |
311 | return QString::null; | 311 | return QString::null; |
312 | r += "/"; r += filename; | 312 | r += "/"; r += filename; |
313 | return r; | 313 | return r; |
314 | } | 314 | } |
315 | 315 | ||
316 | /*! | 316 | /*! |
317 | \internal | 317 | \internal |
318 | */ | 318 | */ |
319 | void Global::createDocDir() | 319 | void Global::createDocDir() |
320 | { | 320 | { |
321 | if ( !docDirCreated ) { | 321 | if ( !docDirCreated ) { |
322 | docDirCreated = TRUE; | 322 | docDirCreated = TRUE; |
323 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); | 323 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | /*! | 328 | /*! |
329 | Displays a status \a message to the user. This generally appears | 329 | Displays a status \a message to the user. This generally appears |
330 | in the taskbar for some amount of time, then disappears. | 330 | in the taskbar for some amount of time, then disappears. |
331 | */ | 331 | */ |
332 | void Global::statusMessage(const QString& message) | 332 | void Global::statusMessage(const QString& message) |
333 | { | 333 | { |
334 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 334 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
335 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); | 335 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); |
336 | e << message; | 336 | e << message; |
337 | #endif | 337 | #endif |
338 | } | 338 | } |
339 | 339 | ||
340 | /*! | 340 | /*! |
341 | \internal | 341 | \internal |
342 | */ | 342 | */ |
343 | void Global::applyStyle() | 343 | void Global::applyStyle() |
344 | { | 344 | { |
345 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 345 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
346 | QCopChannel::send( "QPE/System", "applyStyle()" ); | 346 | QCopChannel::send( "QPE/System", "applyStyle()" ); |
347 | #else | 347 | #else |
348 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version | 348 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version |
349 | #endif | 349 | #endif |
350 | } | 350 | } |
351 | 351 | ||
352 | /*! | 352 | /*! |
353 | \internal | 353 | \internal |
354 | */ | 354 | */ |
355 | QWidget *Global::shutdown( bool ) | 355 | QWidget *Global::shutdown( bool ) |
356 | { | 356 | { |
357 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 357 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
358 | QCopChannel::send( "QPE/System", "shutdown()" ); | 358 | QCopChannel::send( "QPE/System", "shutdown()" ); |
359 | #endif | 359 | #endif |
360 | return 0; | 360 | return 0; |
361 | } | 361 | } |
362 | 362 | ||
363 | /*! | 363 | /*! |
364 | \internal | 364 | \internal |
365 | */ | 365 | */ |
366 | QWidget *Global::restart( bool ) | 366 | QWidget *Global::restart( bool ) |
367 | { | 367 | { |
368 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 368 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
369 | QCopChannel::send( "QPE/System", "restart()" ); | 369 | QCopChannel::send( "QPE/System", "restart()" ); |
370 | #endif | 370 | #endif |
371 | return 0; | 371 | return 0; |
372 | } | 372 | } |
373 | 373 | ||
374 | /*! | 374 | /*! |
375 | Explicitly show the current input method. | 375 | Explicitly show the current input method. |
376 | */ | 376 | */ |
377 | void Global::showInputMethod() | 377 | void Global::showInputMethod() |
378 | { | 378 | { |
379 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 379 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
380 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); | 380 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); |
381 | #endif | 381 | #endif |
382 | } | 382 | } |
383 | 383 | ||
384 | /*! | 384 | /*! |
385 | Explicitly hide the current input method. | 385 | Explicitly hide the current input method. |
386 | */ | 386 | */ |
387 | void Global::hideInputMethod() | 387 | void Global::hideInputMethod() |
388 | { | 388 | { |
389 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 389 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
390 | QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); | 390 | QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); |
391 | #endif | 391 | #endif |
392 | } | 392 | } |
393 | 393 | ||
394 | 394 | ||
395 | /*! | 395 | /*! |
396 | \internal | 396 | \internal |
397 | */ | 397 | */ |
398 | bool Global::isBuiltinCommand( const QString &name ) | 398 | bool Global::isBuiltinCommand( const QString &name ) |
399 | { | 399 | { |
400 | if(!builtin) | 400 | if(!builtin) |
401 | return FALSE; // yes, it can happen | 401 | return FALSE; // yes, it can happen |
402 | for (int i = 0; builtin[i].file; i++) { | 402 | for (int i = 0; builtin[i].file; i++) { |
403 | if ( builtin[i].file == name ) { | 403 | if ( builtin[i].file == name ) { |
404 | return TRUE; | 404 | return TRUE; |
405 | } | 405 | } |
406 | } | 406 | } |
407 | return FALSE; | 407 | return FALSE; |
408 | } | 408 | } |
409 | 409 | ||
410 | Global::Command* Global::builtin=0; | 410 | Global::Command* Global::builtin=0; |
411 | QGuardedPtr<QWidget> *Global::running=0; | 411 | QGuardedPtr<QWidget> *Global::running=0; |
412 | 412 | ||
413 | /*! | 413 | /*! |
414 | \class Global::Command | 414 | \class Global::Command |
415 | \brief The Global::Command class is internal. | 415 | \brief The Global::Command class is internal. |
416 | \internal | 416 | \internal |
417 | */ | 417 | */ |
418 | 418 | ||
419 | /*! | 419 | /*! |
420 | \internal | 420 | \internal |
421 | */ | 421 | */ |
422 | void Global::setBuiltinCommands( Command* list ) | 422 | void Global::setBuiltinCommands( Command* list ) |
423 | { | 423 | { |
424 | if ( running ) | 424 | if ( running ) |
425 | delete [] running; | 425 | delete [] running; |
426 | 426 | ||
427 | builtin = list; | 427 | builtin = list; |
428 | int count = 0; | 428 | int count = 0; |
429 | if (!builtin) | 429 | if (!builtin) |
430 | return; | 430 | return; |
431 | while ( builtin[count].file ) | 431 | while ( builtin[count].file ) |
432 | count++; | 432 | count++; |
433 | 433 | ||
434 | running = new QGuardedPtr<QWidget> [ count ]; | 434 | running = new QGuardedPtr<QWidget> [ count ]; |
435 | } | 435 | } |
436 | 436 | ||
437 | /*! | 437 | /*! |
438 | \internal | 438 | \internal |
439 | */ | 439 | */ |
440 | void Global::setDocument( QWidget* receiver, const QString& document ) | 440 | void Global::setDocument( QWidget* receiver, const QString& document ) |
441 | { | 441 | { |
442 | Emitter emitter(receiver,document); | 442 | Emitter emitter(receiver,document); |
443 | } | 443 | } |
444 | 444 | ||
445 | /*! | 445 | /*! |
446 | \internal | 446 | \internal |
447 | */ | 447 | */ |
448 | bool Global::terminateBuiltin( const QString& n ) | 448 | bool Global::terminateBuiltin( const QString& n ) |
449 | { | 449 | { |
450 | if (!builtin) | 450 | if (!builtin) |
451 | return FALSE; | 451 | return FALSE; |
452 | for (int i = 0; builtin[i].file; i++) { | 452 | for (int i = 0; builtin[i].file; i++) { |
453 | if ( builtin[i].file == n ) { | 453 | if ( builtin[i].file == n ) { |
454 | delete running[i]; | 454 | delete running[i]; |
455 | return TRUE; | 455 | return TRUE; |
456 | } | 456 | } |
457 | } | 457 | } |
458 | return FALSE; | 458 | return FALSE; |
459 | } | 459 | } |
460 | 460 | ||
461 | /*! | 461 | /*! |
462 | \internal | 462 | \internal |
463 | */ | 463 | */ |
464 | void Global::terminate( const AppLnk* app ) | 464 | void Global::terminate( const AppLnk* app ) |
465 | { | 465 | { |
466 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this | 466 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this |
467 | 467 | ||
468 | QCString channel = "QPE/Application/" + app->exec().utf8(); | 468 | QCString channel = "QPE/Application/" + app->exec().utf8(); |
469 | if ( QCopChannel::isRegistered(channel) ) { | 469 | if ( QCopChannel::isRegistered(channel) ) { |
470 | QCopEnvelope e(channel, "quit()"); | 470 | QCopEnvelope e(channel, "quit()"); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | 473 | ||
474 | /*! | 474 | /*! |
475 | Low-level function to run command \a c. Not recommended. | 475 | Low-level function to run command \a c. Not recommended. |
476 | */ | 476 | */ |
477 | void Global::invoke(const QString &c) | 477 | void Global::invoke(const QString &c) |
478 | { | 478 | { |
479 | // Convert the command line in to a list of arguments | 479 | // Convert the command line in to a list of arguments |
480 | QStringList list = QStringList::split(QRegExp(" *"),c); | 480 | QStringList list = QStringList::split(QRegExp(" *"),c); |
481 | 481 | ||
482 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 482 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
483 | QString ap=list[0]; | 483 | QString ap=list[0]; |
484 | // see if the application is already running | 484 | // see if the application is already running |
485 | // XXX should lock file /tmp/qcop-msg-ap | 485 | // XXX should lock file /tmp/qcop-msg-ap |
486 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { | 486 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { |
487 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 487 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
488 | e << ap; | 488 | e << ap; |
489 | return; | 489 | return; |
490 | } | 490 | } |
491 | // XXX should unlock file /tmp/qcop-msg-ap | 491 | // XXX should unlock file /tmp/qcop-msg-ap |
492 | //see if it is being started | 492 | //see if it is being started |
493 | if ( StartingAppList::isStarting( ap ) ) { | 493 | if ( StartingAppList::isStarting( ap ) ) { |
494 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 494 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
495 | e << ap; | 495 | e << ap; |
496 | return; | 496 | return; |
497 | } | 497 | } |
498 | 498 | ||
499 | #endif | 499 | #endif |
500 | 500 | ||
501 | #ifdef QT_NO_QWS_MULTIPROCESS | 501 | #ifdef QT_NO_QWS_MULTIPROCESS |
502 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); | 502 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); |
503 | #else | 503 | #else |
504 | 504 | ||
505 | QStrList slist; | 505 | QStrList slist; |
506 | unsigned int j; | 506 | unsigned int j; |
507 | for ( j = 0; j < list.count(); j++ ) | 507 | for ( j = 0; j < list.count(); j++ ) |
508 | slist.append( list[j].utf8() ); | 508 | slist.append( list[j].utf8() ); |
509 | 509 | ||
510 | const char **args = new (const char *)[slist.count() + 1]; | 510 | const char **args = new (const char *)[slist.count() + 1]; |
511 | for ( j = 0; j < slist.count(); j++ ) | 511 | for ( j = 0; j < slist.count(); j++ ) |
512 | args[j] = slist.at(j); | 512 | args[j] = slist.at(j); |
513 | args[j] = NULL; | 513 | args[j] = NULL; |
514 | 514 | ||
515 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 515 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
516 | // an attempt to show a wait... | 516 | // an attempt to show a wait... |
517 | // more logic should be used, but this will be fine for the moment... | 517 | // more logic should be used, but this will be fine for the moment... |
518 | QCopEnvelope ( "QPE/System", "busy()" ); | 518 | QCopEnvelope ( "QPE/System", "busy()" ); |
519 | #endif | 519 | #endif |
520 | 520 | ||
521 | #ifdef HAVE_QUICKEXEC | 521 | #ifdef HAVE_QUICKEXEC |
522 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; | 522 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; |
523 | qDebug("libfile = %s", libexe.latin1() ); | 523 | qDebug("libfile = %s", libexe.latin1() ); |
524 | if ( QFile::exists( libexe ) ) { | 524 | if ( QFile::exists( libexe ) ) { |
525 | qDebug("calling quickexec %s", libexe.latin1() ); | 525 | qDebug("calling quickexec %s", libexe.latin1() ); |
526 | quickexecv( libexe.utf8().data(), (const char **)args ); | 526 | quickexecv( libexe.utf8().data(), (const char **)args ); |
527 | } else | 527 | } else |
528 | #endif | 528 | #endif |
529 | { | 529 | { |
530 | if ( !::vfork() ) { | 530 | if ( !::vfork() ) { |
531 | for ( int fd = 3; fd < 100; fd++ ) | 531 | for ( int fd = 3; fd < 100; fd++ ) |
532 | ::close( fd ); | 532 | ::close( fd ); |
533 | ::setpgid( ::getpid(), ::getppid() ); | 533 | ::setpgid( ::getpid(), ::getppid() ); |
534 | // Try bindir first, so that foo/bar works too | 534 | // Try bindir first, so that foo/bar works too |
535 | ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); | 535 | ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); |
536 | ::execvp( args[0], (char * const *)args ); | 536 | ::execvp( args[0], (char * const *)args ); |
537 | _exit( -1 ); | 537 | _exit( -1 ); |
538 | } | 538 | } |
539 | } | 539 | } |
540 | StartingAppList::add( list[0] ); | 540 | StartingAppList::add( list[0] ); |
541 | #endif //QT_NO_QWS_MULTIPROCESS | 541 | #endif //QT_NO_QWS_MULTIPROCESS |
542 | } | 542 | } |
543 | 543 | ||
544 | /*! | 544 | /*! |
545 | Executes application identfied by \a c, passing \a document. | 545 | Executes application identfied by \a c, passing \a document. |
546 | 546 | ||
547 | Note that you might be better off sending a QCop message to | 547 | Note that you might be better off sending a QCop message to |
548 | the application's QPE/Application/<i>appname</i> channel. | 548 | the application's QPE/Application/<i>appname</i> channel. |
549 | */ | 549 | */ |
550 | void Global::execute( const QString &c, const QString& document ) | 550 | void Global::execute( const QString &c, const QString& document ) |
551 | { | 551 | { |
552 | if ( qApp->type() != QApplication::GuiServer ) { | 552 | if ( qApp->type() != QApplication::GuiServer ) { |
553 | // ask the server to do the work | 553 | // ask the server to do the work |
554 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 554 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
555 | if ( document.isNull() ) { | 555 | if ( document.isNull() ) { |
556 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 556 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
557 | e << c; | 557 | e << c; |
558 | } else { | 558 | } else { |
559 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); | 559 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); |
560 | e << c << document; | 560 | e << c << document; |
561 | } | 561 | } |
562 | #endif | 562 | #endif |
563 | return; | 563 | return; |
564 | } | 564 | } |
565 | 565 | ||
566 | // Attempt to execute the app using a builtin class for the app first | 566 | // Attempt to execute the app using a builtin class for the app first |
567 | // else try and find it in the bin directory | 567 | // else try and find it in the bin directory |
568 | if (builtin) { | 568 | if (builtin) { |
569 | for (int i = 0; builtin[i].file; i++) { | 569 | for (int i = 0; builtin[i].file; i++) { |
570 | if ( builtin[i].file == c ) { | 570 | if ( builtin[i].file == c ) { |
571 | if ( running[i] ) { | 571 | if ( running[i] ) { |
572 | if ( !document.isNull() && builtin[i].documentary ) | 572 | if ( !document.isNull() && builtin[i].documentary ) |
573 | setDocument(running[i], document); | 573 | setDocument(running[i], document); |
574 | running[i]->raise(); | 574 | running[i]->raise(); |
575 | running[i]->show(); | 575 | running[i]->show(); |
576 | running[i]->setActiveWindow(); | 576 | running[i]->setActiveWindow(); |
577 | } else { | 577 | } else { |
578 | running[i] = builtin[i].func( builtin[i].maximized ); | 578 | running[i] = builtin[i].func( builtin[i].maximized ); |
579 | } | 579 | } |
580 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 580 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
581 | e << c; // that was quick ;-) | 581 | e << c; // that was quick ;-) |
582 | return; | 582 | return; |
583 | } | 583 | } |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | //Global::invoke(c, document); | 587 | //Global::invoke(c, document); |
588 | 588 | ||
589 | // Convert the command line in to a list of arguments | 589 | // Convert the command line in to a list of arguments |
590 | QStringList list = QStringList::split(QRegExp(" *"),c); | 590 | QStringList list = QStringList::split(QRegExp(" *"),c); |
591 | 591 | ||
592 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 592 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
593 | QString ap=list[0]; | 593 | QString ap=list[0]; |
594 | 594 | ||
595 | qDebug("executing %s", ap.latin1() ); | 595 | qDebug("executing %s", ap.latin1() ); |
596 | if ( ap == "suspend" ) { | 596 | if ( ap == "suspend" ) { |
597 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 597 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
598 | return; | 598 | return; |
599 | } | 599 | } |
600 | 600 | ||
601 | /* if need be, sending a qcop message will result in an invoke, see | 601 | /* if need be, sending a qcop message will result in an invoke, see |
602 | preceeding function */ | 602 | preceeding function */ |
603 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | 603 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } |
604 | if ( !document.isEmpty() ) { | 604 | if ( !document.isEmpty() ) { |
605 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); | 605 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); |
606 | env << document; | 606 | env << document; |
607 | } | 607 | } |
608 | #endif | 608 | #endif |
609 | } | 609 | } |
610 | 610 | ||
611 | /*! | 611 | /*! |
612 | Returns the string \a s with the characters backslash, ", and $ | 612 | Returns the string \a s with the characters backslash, ", and $ |
613 | quoted by a preceeding backslash. | 613 | quoted by a preceeding backslash. |
614 | */ | 614 | */ |
615 | QString Global::shellQuote(const QString& s) | 615 | QString Global::shellQuote(const QString& s) |
616 | { | 616 | { |
617 | QString r="\""; | 617 | QString r="\""; |
618 | for (int i=0; i<(int)s.length(); i++) { | 618 | for (int i=0; i<(int)s.length(); i++) { |
619 | char c = s[i].latin1(); | 619 | char c = s[i].latin1(); |
620 | switch (c) { | 620 | switch (c) { |
621 | case '\\': case '"': case '$': | 621 | case '\\': case '"': case '$': |
622 | r+="\\"; | 622 | r+="\\"; |
623 | } | 623 | } |
624 | r += s[i]; | 624 | r += s[i]; |
625 | } | 625 | } |
626 | r += "\""; | 626 | r += "\""; |
627 | return r; | 627 | return r; |
628 | } | 628 | } |
629 | 629 | ||
630 | /*! | 630 | /*! |
631 | Returns the string \a s with the characters backslash and " | 631 | Returns the string \a s with the characters backslash and " |
632 | quoted by a preceeding backslash. | 632 | quoted by a preceeding backslash. |
633 | */ | 633 | */ |
634 | QString Global::stringQuote(const QString& s) | 634 | QString Global::stringQuote(const QString& s) |
635 | { | 635 | { |
636 | QString r="\""; | 636 | QString r="\""; |
637 | for (int i=0; i<(int)s.length(); i++) { | 637 | for (int i=0; i<(int)s.length(); i++) { |
638 | char c = s[i].latin1(); | 638 | char c = s[i].latin1(); |
639 | switch (c) { | 639 | switch (c) { |
640 | case '\\': case '"': | 640 | case '\\': case '"': |
641 | r+="\\"; | 641 | r+="\\"; |
642 | } | 642 | } |
643 | r += s[i]; | 643 | r += s[i]; |
644 | } | 644 | } |
645 | r += "\""; | 645 | r += "\""; |
646 | return r; | 646 | return r; |
647 | } | 647 | } |
648 | 648 | ||
649 | /*! | 649 | /*! |
650 | Finds all documents on the system's document directories which | 650 | Finds all documents on the system's document directories which |
651 | match the filter \a mimefilter, and appends the resulting DocLnk | 651 | match the filter \a mimefilter, and appends the resulting DocLnk |
652 | objects to \a folder. | 652 | objects to \a folder. |
653 | */ | 653 | */ |
654 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) | 654 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) |
655 | { | 655 | { |
656 | QString homedocs = QString(getenv("HOME")) + "/Documents"; | 656 | QString homedocs = QString(getenv("HOME")) + "/Documents"; |
657 | DocLnkSet d(homedocs,mimefilter); | 657 | DocLnkSet d(homedocs,mimefilter); |
658 | folder->appendFrom(d); | 658 | folder->appendFrom(d); |
659 | /** let's do intellegint way of searching these files | 659 | /** let's do intellegint way of searching these files |
660 | * a) the user don't want to check mediums global | 660 | * a) the user don't want to check mediums global |
661 | * b) the user wants to check but use the global options for it | 661 | * b) the user wants to check but use the global options for it |
662 | * c) the user wants to check it but not this medium | 662 | * c) the user wants to check it but not this medium |
663 | * d) the user wants to check and this medium as well | 663 | * d) the user wants to check and this medium as well |
664 | * | 664 | * |
665 | * In all cases we need to apply a different mimefilter to | 665 | * In all cases we need to apply a different mimefilter to |
666 | * the medium. | 666 | * the medium. |
667 | * a) mimefilter.isEmpty() we need to apply the responding filter | 667 | * a) mimefilter.isEmpty() we need to apply the responding filter |
668 | * either the global or the one on the medium | 668 | * either the global or the one on the medium |
669 | * | 669 | * |
670 | * b) mimefilter is set to an application we need to find out if the | 670 | * b) mimefilter is set to an application we need to find out if the |
671 | * mimetypes are included in the mime mask of the medium | 671 | * mimetypes are included in the mime mask of the medium |
672 | */ | 672 | */ |
673 | StorageInfo storage; | 673 | StorageInfo storage; |
674 | const QList<FileSystem> &fs = storage.fileSystems(); | 674 | const QList<FileSystem> &fs = storage.fileSystems(); |
675 | QListIterator<FileSystem> it ( fs ); | 675 | QListIterator<FileSystem> it ( fs ); |
676 | for ( ; it.current(); ++it ) { | 676 | for ( ; it.current(); ++it ) { |
677 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 677 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
678 | // this is a candidate look at the cf and see if we should search on it | 678 | // this is a candidate look at the cf and see if we should search on it |
679 | QString path = (*it)->path(); | 679 | QString path = (*it)->path(); |
680 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) | 680 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) |
681 | continue; | 681 | continue; |
682 | DocLnkSet ide( path, mimefilter ); | 682 | DocLnkSet ide( path, mimefilter ); |
683 | folder->appendFrom(ide); | 683 | folder->appendFrom(ide); |
684 | } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | ||
685 | QString path = (*it)->path() + "/Documents"; | ||
686 | DocLnkSet ide( path, mimefilter ); | ||
687 | folder->appendFrom(ide); | ||
684 | } | 688 | } |
685 | } | 689 | } |
686 | } | 690 | } |
687 | 691 | ||
688 | QStringList Global::languageList() | 692 | QStringList Global::languageList() |
689 | { | 693 | { |
690 | QString lang = getenv("LANG"); | 694 | QString lang = getenv("LANG"); |
691 | QStringList langs; | 695 | QStringList langs; |
692 | langs.append(lang); | 696 | langs.append(lang); |
693 | int i = lang.find("."); | 697 | int i = lang.find("."); |
694 | if ( i > 0 ) | 698 | if ( i > 0 ) |
695 | lang = lang.left( i ); | 699 | lang = lang.left( i ); |
696 | i = lang.find( "_" ); | 700 | i = lang.find( "_" ); |
697 | if ( i > 0 ) | 701 | if ( i > 0 ) |
698 | langs.append(lang.left(i)); | 702 | langs.append(lang.left(i)); |
699 | return langs; | 703 | return langs; |
700 | } | 704 | } |
701 | 705 | ||
702 | QStringList Global::helpPath() | 706 | QStringList Global::helpPath() |
703 | { | 707 | { |
704 | QStringList path; | 708 | QStringList path; |
705 | QStringList langs = Global::languageList(); | 709 | QStringList langs = Global::languageList(); |
706 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { | 710 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { |
707 | QString lang = *it; | 711 | QString lang = *it; |
708 | if ( !lang.isEmpty() ) | 712 | if ( !lang.isEmpty() ) |
709 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; | 713 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; |
710 | } | 714 | } |
711 | path += QPEApplication::qpeDir() + "/pics"; | 715 | path += QPEApplication::qpeDir() + "/pics"; |
712 | path += QPEApplication::qpeDir() + "/help/en/html"; | 716 | path += QPEApplication::qpeDir() + "/help/en/html"; |
713 | path += QPEApplication::qpeDir() + "/docs"; | 717 | path += QPEApplication::qpeDir() + "/docs"; |
714 | QString dir = QDir::current().canonicalPath(); | 718 | QString dir = QDir::current().canonicalPath(); |
715 | if ( dir == "/" ) | 719 | if ( dir == "/" ) |
716 | dir += "/docs"; | 720 | dir += "/docs"; |
717 | else { | 721 | else { |
718 | path += dir + "/../pics"; | 722 | path += dir + "/../pics"; |
719 | dir += "/../docs"; | 723 | dir += "/../docs"; |
720 | path += dir; | 724 | path += dir; |
721 | } | 725 | } |
722 | return path; | 726 | return path; |
723 | } | 727 | } |
724 | 728 | ||
725 | 729 | ||
726 | #include "global.moc" | 730 | #include "global.moc" |
diff --git a/library/lnkproperties.cpp b/library/lnkproperties.cpp index e8baca6..c020328 100644 --- a/library/lnkproperties.cpp +++ b/library/lnkproperties.cpp | |||
@@ -1,314 +1,315 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | 21 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT |
22 | // have this class. | 22 | // have this class. |
23 | #define QTOPIA_INTERNAL_FSLP | 23 | #define QTOPIA_INTERNAL_FSLP |
24 | #include "lnkproperties.h" | 24 | #include "lnkproperties.h" |
25 | #include "lnkproperties.h" | 25 | #include "lnkproperties.h" |
26 | #include "lnkpropertiesbase_p.h" | 26 | #include "lnkpropertiesbase_p.h" |
27 | #include "ir.h" | 27 | #include "ir.h" |
28 | 28 | ||
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
31 | #include <qpe/categorywidget.h> | 31 | #include <qpe/categorywidget.h> |
32 | #include <qpe/qcopenvelope_qws.h> | 32 | #include <qpe/qcopenvelope_qws.h> |
33 | #include <qpe/filemanager.h> | 33 | #include <qpe/filemanager.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/storage.h> | 35 | #include <qpe/storage.h> |
36 | #include <qpe/qpemessagebox.h> | 36 | #include <qpe/qpemessagebox.h> |
37 | 37 | ||
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qgroupbox.h> | 41 | #include <qgroupbox.h> |
42 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qfile.h> | 45 | #include <qfile.h> |
46 | #include <qfileinfo.h> | 46 | #include <qfileinfo.h> |
47 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
48 | #include <qsize.h> | 48 | #include <qsize.h> |
49 | #include <qcombobox.h> | 49 | #include <qcombobox.h> |
50 | #include <qregexp.h> | 50 | #include <qregexp.h> |
51 | 51 | ||
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | 53 | ||
54 | LnkProperties::LnkProperties( AppLnk* l, QWidget* parent ) | 54 | LnkProperties::LnkProperties( AppLnk* l, QWidget* parent ) |
55 | : QDialog( parent, 0, TRUE ), lnk(l), fileSize( 0 ) | 55 | : QDialog( parent, 0, TRUE ), lnk(l), fileSize( 0 ) |
56 | { | 56 | { |
57 | QVBoxLayout *vbox = new QVBoxLayout( this ); | 57 | QVBoxLayout *vbox = new QVBoxLayout( this ); |
58 | d = new LnkPropertiesBase( this ); | 58 | d = new LnkPropertiesBase( this ); |
59 | vbox->add( d ); | 59 | vbox->add( d ); |
60 | 60 | ||
61 | d->docname->setText(l->name()); | 61 | d->docname->setText(l->name()); |
62 | QString inf; | 62 | QString inf; |
63 | if ( l->type().isEmpty() ) { | 63 | if ( l->type().isEmpty() ) { |
64 | d->type->hide(); | 64 | d->type->hide(); |
65 | d->typeLabel->hide(); | 65 | d->typeLabel->hide(); |
66 | } else { | 66 | } else { |
67 | d->type->setText( l->type() ); | 67 | d->type->setText( l->type() ); |
68 | } | 68 | } |
69 | 69 | ||
70 | if ( l->comment().isEmpty() ) { | 70 | if ( l->comment().isEmpty() ) { |
71 | d->comment->hide(); | 71 | d->comment->hide(); |
72 | d->commentLabel->hide(); | 72 | d->commentLabel->hide(); |
73 | } else { | 73 | } else { |
74 | d->comment->setText( l->comment() ); | 74 | d->comment->setText( l->comment() ); |
75 | } | 75 | } |
76 | 76 | ||
77 | connect(d->beam,SIGNAL(clicked()),this,SLOT(beamLnk())); | 77 | connect(d->beam,SIGNAL(clicked()),this,SLOT(beamLnk())); |
78 | if ( lnk->type().contains('/') ) { // A document? (#### better predicate needed) | 78 | if ( lnk->type().contains('/') ) { // A document? (#### better predicate needed) |
79 | connect(d->unlink,SIGNAL(clicked()),this,SLOT(unlinkLnk())); | 79 | connect(d->unlink,SIGNAL(clicked()),this,SLOT(unlinkLnk())); |
80 | connect(d->duplicate,SIGNAL(clicked()),this,SLOT(duplicateLnk())); | 80 | connect(d->duplicate,SIGNAL(clicked()),this,SLOT(duplicateLnk())); |
81 | connect(d->delicon,SIGNAL(clicked()),this,SLOT(unlinkIcon())); | 81 | connect(d->delicon,SIGNAL(clicked()),this,SLOT(unlinkIcon())); |
82 | 82 | ||
83 | d->docname->setReadOnly( FALSE ); | 83 | d->docname->setReadOnly( FALSE ); |
84 | d->preload->hide(); | 84 | d->preload->hide(); |
85 | d->spacer->hide(); | 85 | d->spacer->hide(); |
86 | 86 | ||
87 | // ### THIS MUST GO, FIX WIERD BUG in QLAYOUT | 87 | // ### THIS MUST GO, FIX WIERD BUG in QLAYOUT |
88 | d->categoryEdit->kludge(); | 88 | d->categoryEdit->kludge(); |
89 | 89 | ||
90 | d->categoryEdit->setCategories( lnk->categories(), | 90 | d->categoryEdit->setCategories( lnk->categories(), |
91 | "Document View", | 91 | "Document View", |
92 | tr("Document View") ); | 92 | tr("Document View") ); |
93 | setupLocations(); | 93 | setupLocations(); |
94 | } else { | 94 | } else { |
95 | d->unlink->hide(); | 95 | d->unlink->hide(); |
96 | d->duplicate->hide(); | 96 | d->duplicate->hide(); |
97 | d->beam->hide(); | 97 | d->beam->hide(); |
98 | d->hline->hide(); | 98 | d->hline->hide(); |
99 | d->locationLabel->hide(); | 99 | d->locationLabel->hide(); |
100 | d->locationCombo->hide(); | 100 | d->locationCombo->hide(); |
101 | 101 | ||
102 | // Can't edit categories, since the app .desktop files are global, | 102 | // Can't edit categories, since the app .desktop files are global, |
103 | // possibly read-only. | 103 | // possibly read-only. |
104 | d->categoryEdit->hide(); | 104 | d->categoryEdit->hide(); |
105 | 105 | ||
106 | d->docname->setReadOnly( TRUE ); | 106 | d->docname->setReadOnly( TRUE ); |
107 | 107 | ||
108 | if ( l->property("CanFastload") == "0" ) | 108 | if ( l->property("CanFastload") == "0" ) |
109 | d->preload->hide(); | 109 | d->preload->hide(); |
110 | 110 | ||
111 | Config cfg("Launcher"); | 111 | Config cfg("Launcher"); |
112 | cfg.setGroup("Preload"); | 112 | cfg.setGroup("Preload"); |
113 | QStringList apps = cfg.readListEntry("Apps",','); | 113 | QStringList apps = cfg.readListEntry("Apps",','); |
114 | d->preload->setChecked( apps.contains(l->exec()) ); | 114 | d->preload->setChecked( apps.contains(l->exec()) ); |
115 | if ( Global::isBuiltinCommand(lnk->exec()) ) | 115 | if ( Global::isBuiltinCommand(lnk->exec()) ) |
116 | d->preload->hide(); // builtins are always fast | 116 | d->preload->hide(); // builtins are always fast |
117 | 117 | ||
118 | currentLocation = 0; // apps not movable (yet) | 118 | currentLocation = 0; // apps not movable (yet) |
119 | } | 119 | } |
120 | setCaption( l->file()); | 120 | setCaption( l->file()); |
121 | } | 121 | } |
122 | 122 | ||
123 | LnkProperties::~LnkProperties() | 123 | LnkProperties::~LnkProperties() |
124 | { | 124 | { |
125 | } | 125 | } |
126 | 126 | ||
127 | void LnkProperties::unlinkLnk() | 127 | void LnkProperties::unlinkLnk() |
128 | { | 128 | { |
129 | if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) { | 129 | if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) { |
130 | if ( QFile::exists(lnk->file()) ) | 130 | if ( QFile::exists(lnk->file()) ) |
131 | lnk->removeFiles(); | 131 | lnk->removeFiles(); |
132 | else | 132 | else |
133 | QMessageBox::warning( this, tr("Delete"), tr("File does not exist.") ); | 133 | QMessageBox::warning( this, tr("Delete"), tr("File does not exist.") ); |
134 | if ( QFile::exists(lnk->file()) ) { | 134 | if ( QFile::exists(lnk->file()) ) { |
135 | QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") ); | 135 | QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") ); |
136 | } else { | 136 | } else { |
137 | reject(); | 137 | reject(); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
143 | /* | 143 | /* |
144 | * remove only the link from documents, not also the file | 144 | * remove only the link from documents, not also the file |
145 | */ | 145 | */ |
146 | void LnkProperties::unlinkIcon() | 146 | void LnkProperties::unlinkIcon() |
147 | { | 147 | { |
148 | if ( QPEMessageBox::confirmDelete( this, tr("Delete Icon and leave file"), lnk->name() ) ) { | 148 | if ( QPEMessageBox::confirmDelete( this, tr("Delete Icon and leave file"), lnk->name() ) ) { |
149 | lnk->removeLinkFile(); | 149 | lnk->removeLinkFile(); |
150 | if ( QFile::exists(lnk->linkFile()) ) { | 150 | if ( QFile::exists(lnk->linkFile()) ) { |
151 | QMessageBox::warning( this, tr("Delete"), tr("Icon deletion failed.") ); | 151 | QMessageBox::warning( this, tr("Delete"), tr("Icon deletion failed.") ); |
152 | } else { | 152 | } else { |
153 | reject(); | 153 | reject(); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void LnkProperties::setupLocations() | 158 | void LnkProperties::setupLocations() |
159 | { | 159 | { |
160 | QFileInfo fi( lnk->file() ); | 160 | QFileInfo fi( lnk->file() ); |
161 | fileSize = fi.size(); | 161 | fileSize = fi.size(); |
162 | StorageInfo storage; | 162 | StorageInfo storage; |
163 | const QList<FileSystem> &fs = storage.fileSystems(); | 163 | const QList<FileSystem> &fs = storage.fileSystems(); |
164 | QListIterator<FileSystem> it ( fs ); | 164 | QListIterator<FileSystem> it ( fs ); |
165 | QString s; | 165 | QString s; |
166 | QString homeDir = getenv("HOME"); | 166 | QString homeDir = getenv("HOME"); |
167 | QString hardDiskHome; | 167 | QString hardDiskHome; |
168 | QString hardDiskPath; | 168 | QString hardDiskPath; |
169 | int index = 0; | 169 | int index = 0; |
170 | currentLocation = -1; | 170 | currentLocation = -1; |
171 | for ( ; it.current(); ++it ) { | 171 | for ( ; it.current(); ++it ) { |
172 | // we add 10k to the file size so we are sure we can also save the desktop file | 172 | // we add 10k to the file size so we are sure we can also save the desktop file |
173 | if ( (*it)->availBlocks() * (*it)->blockSize() > fileSize + 10000 ) { | 173 | if ( (*it)->availBlocks() * (*it)->blockSize() > fileSize + 10000 ) { |
174 | if ( (*it)->isRemovable() || | 174 | if ( (*it)->isRemovable() || |
175 | (*it)->disk() == "/dev/mtdblock1" || | 175 | (*it)->disk() == "/dev/mtdblock1" || |
176 | (*it)->disk() == "/dev/mtdblock/1" || (*it)->disk().left(13) == "/dev/mtdblock" ) { | 176 | (*it)->disk() == "/dev/mtdblock/1" || (*it)->disk().left(13) == "/dev/mtdblock" || |
177 | (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | ||
177 | d->locationCombo->insertItem( (*it)->name(), index ); | 178 | d->locationCombo->insertItem( (*it)->name(), index ); |
178 | locations.append( ((*it)->isRemovable() ? (*it)->path() : homeDir) ); | 179 | locations.append( ((*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ? (*it)->path() : homeDir) ); |
179 | if ( lnk->file().contains( (*it)->path() ) ) { | 180 | if ( lnk->file().contains( (*it)->path() ) ) { |
180 | d->locationCombo->setCurrentItem( index ); | 181 | d->locationCombo->setCurrentItem( index ); |
181 | currentLocation = index; | 182 | currentLocation = index; |
182 | } | 183 | } |
183 | index++; | 184 | index++; |
184 | } else if ( (*it)->name().contains( "Hard Disk") && | 185 | } else if ( (*it)->name().contains( tr("Hard Disk") ) && |
185 | homeDir.contains( (*it)->path() ) && | 186 | homeDir.contains( (*it)->path() ) && |
186 | (*it)->path().length() > hardDiskHome.length() ) { | 187 | (*it)->path().length() > hardDiskHome.length() ) { |
187 | hardDiskHome = (*it)->name(); | 188 | hardDiskHome = (*it)->name(); |
188 | hardDiskPath = (*it)->path(); | 189 | hardDiskPath = (*it)->path(); |
189 | } | 190 | } |
190 | } | 191 | } |
191 | } | 192 | } |
192 | if ( !hardDiskHome.isEmpty() ) { | 193 | if ( !hardDiskHome.isEmpty() ) { |
193 | d->locationCombo->insertItem( hardDiskHome ); | 194 | d->locationCombo->insertItem( hardDiskHome ); |
194 | locations.append( hardDiskPath ); | 195 | locations.append( hardDiskPath ); |
195 | if ( currentLocation == -1 ) { // assume it's the hard disk | 196 | if ( currentLocation == -1 ) { // assume it's the hard disk |
196 | d->locationCombo->setCurrentItem( index ); | 197 | d->locationCombo->setCurrentItem( index ); |
197 | currentLocation = index; | 198 | currentLocation = index; |
198 | } | 199 | } |
199 | } | 200 | } |
200 | } | 201 | } |
201 | 202 | ||
202 | void LnkProperties::duplicateLnk() | 203 | void LnkProperties::duplicateLnk() |
203 | { | 204 | { |
204 | // The duplicate takes the new properties. | 205 | // The duplicate takes the new properties. |
205 | DocLnk newdoc( *((DocLnk *)lnk) ); | 206 | DocLnk newdoc( *((DocLnk *)lnk) ); |
206 | if ( d->docname->text() == lnk->name() ) | 207 | if ( d->docname->text() == lnk->name() ) |
207 | newdoc.setName(tr("Copy of ")+d->docname->text()); | 208 | newdoc.setName(tr("Copy of ")+d->docname->text()); |
208 | else | 209 | else |
209 | newdoc.setName(d->docname->text()); | 210 | newdoc.setName(d->docname->text()); |
210 | 211 | ||
211 | if ( !copyFile( newdoc ) ) { | 212 | if ( !copyFile( newdoc ) ) { |
212 | QMessageBox::warning( this, tr("Duplicate"), tr("File copy failed.") ); | 213 | QMessageBox::warning( this, tr("Duplicate"), tr("File copy failed.") ); |
213 | return; | 214 | return; |
214 | } | 215 | } |
215 | reject(); | 216 | reject(); |
216 | } | 217 | } |
217 | 218 | ||
218 | bool LnkProperties::moveLnk() | 219 | bool LnkProperties::moveLnk() |
219 | { | 220 | { |
220 | DocLnk newdoc( *((DocLnk *)lnk) ); | 221 | DocLnk newdoc( *((DocLnk *)lnk) ); |
221 | newdoc.setName(d->docname->text()); | 222 | newdoc.setName(d->docname->text()); |
222 | 223 | ||
223 | if ( !copyFile( newdoc ) ) { | 224 | if ( !copyFile( newdoc ) ) { |
224 | QMessageBox::warning( this, tr("Details"), tr("Moving Document failed.") ); | 225 | QMessageBox::warning( this, tr("Details"), tr("Moving Document failed.") ); |
225 | return FALSE; | 226 | return FALSE; |
226 | } | 227 | } |
227 | // remove old lnk | 228 | // remove old lnk |
228 | lnk->removeFiles(); | 229 | lnk->removeFiles(); |
229 | 230 | ||
230 | return TRUE; | 231 | return TRUE; |
231 | } | 232 | } |
232 | 233 | ||
233 | void LnkProperties::beamLnk() | 234 | void LnkProperties::beamLnk() |
234 | { | 235 | { |
235 | Ir ir; | 236 | Ir ir; |
236 | DocLnk doc( *((DocLnk *)lnk) ); | 237 | DocLnk doc( *((DocLnk *)lnk) ); |
237 | ir.send( doc, doc.comment() ); | 238 | ir.send( doc, doc.comment() ); |
238 | } | 239 | } |
239 | 240 | ||
240 | bool LnkProperties::copyFile( DocLnk &newdoc ) | 241 | bool LnkProperties::copyFile( DocLnk &newdoc ) |
241 | { | 242 | { |
242 | const char *linkExtn = ".desktop"; | 243 | const char *linkExtn = ".desktop"; |
243 | QString fileExtn; | 244 | QString fileExtn; |
244 | int extnPos = lnk->file().findRev( '.' ); | 245 | int extnPos = lnk->file().findRev( '.' ); |
245 | if ( extnPos > 0 ) | 246 | if ( extnPos > 0 ) |
246 | fileExtn = lnk->file().mid( extnPos ); | 247 | fileExtn = lnk->file().mid( extnPos ); |
247 | 248 | ||
248 | QString safename = newdoc.name(); | 249 | QString safename = newdoc.name(); |
249 | safename.replace(QRegExp("/"),"_"); | 250 | safename.replace(QRegExp("/"),"_"); |
250 | 251 | ||
251 | QString fn = locations[ d->locationCombo->currentItem() ] | 252 | QString fn = locations[ d->locationCombo->currentItem() ] |
252 | + "/Documents/" + newdoc.type() + "/" + safename; | 253 | + "/Documents/" + newdoc.type() + "/" + safename; |
253 | if ( QFile::exists(fn + fileExtn) || QFile::exists(fn + linkExtn) ) { | 254 | if ( QFile::exists(fn + fileExtn) || QFile::exists(fn + linkExtn) ) { |
254 | int n=1; | 255 | int n=1; |
255 | QString nn = fn + "_" + QString::number(n); | 256 | QString nn = fn + "_" + QString::number(n); |
256 | while ( QFile::exists(nn+fileExtn) || QFile::exists(nn+linkExtn) ) { | 257 | while ( QFile::exists(nn+fileExtn) || QFile::exists(nn+linkExtn) ) { |
257 | n++; | 258 | n++; |
258 | nn = fn + "_" + QString::number(n); | 259 | nn = fn + "_" + QString::number(n); |
259 | } | 260 | } |
260 | fn = nn; | 261 | fn = nn; |
261 | } | 262 | } |
262 | newdoc.setFile( fn + fileExtn ); | 263 | newdoc.setFile( fn + fileExtn ); |
263 | newdoc.setLinkFile( fn + linkExtn ); | 264 | newdoc.setLinkFile( fn + linkExtn ); |
264 | 265 | ||
265 | // Copy file | 266 | // Copy file |
266 | FileManager fm; | 267 | FileManager fm; |
267 | if ( !fm.copyFile( *lnk, newdoc ) ) | 268 | if ( !fm.copyFile( *lnk, newdoc ) ) |
268 | return FALSE; | 269 | return FALSE; |
269 | return TRUE; | 270 | return TRUE; |
270 | } | 271 | } |
271 | 272 | ||
272 | void LnkProperties::done(int ok) | 273 | void LnkProperties::done(int ok) |
273 | { | 274 | { |
274 | if ( ok ) { | 275 | if ( ok ) { |
275 | bool changed=FALSE; | 276 | bool changed=FALSE; |
276 | if ( lnk->name() != d->docname->text() ) { | 277 | if ( lnk->name() != d->docname->text() ) { |
277 | lnk->setName(d->docname->text()); | 278 | lnk->setName(d->docname->text()); |
278 | changed=TRUE; | 279 | changed=TRUE; |
279 | } | 280 | } |
280 | if ( d->categoryEdit->isVisible() ) { | 281 | if ( d->categoryEdit->isVisible() ) { |
281 | QArray<int> tmp = d->categoryEdit->newCategories(); | 282 | QArray<int> tmp = d->categoryEdit->newCategories(); |
282 | if ( lnk->categories() != tmp ) { | 283 | if ( lnk->categories() != tmp ) { |
283 | lnk->setCategories( tmp ); | 284 | lnk->setCategories( tmp ); |
284 | changed = TRUE; | 285 | changed = TRUE; |
285 | } | 286 | } |
286 | } | 287 | } |
287 | if ( d->preload->isHidden() && d->locationCombo->currentItem() != currentLocation ) { | 288 | if ( d->preload->isHidden() && d->locationCombo->currentItem() != currentLocation ) { |
288 | moveLnk(); | 289 | moveLnk(); |
289 | } else if ( changed ) { | 290 | } else if ( changed ) { |
290 | lnk->writeLink(); | 291 | lnk->writeLink(); |
291 | } | 292 | } |
292 | 293 | ||
293 | if ( !d->preload->isHidden() ) { | 294 | if ( !d->preload->isHidden() ) { |
294 | Config cfg("Launcher"); | 295 | Config cfg("Launcher"); |
295 | cfg.setGroup("Preload"); | 296 | cfg.setGroup("Preload"); |
296 | QStringList apps = cfg.readListEntry("Apps",','); | 297 | QStringList apps = cfg.readListEntry("Apps",','); |
297 | QString exe = lnk->exec(); | 298 | QString exe = lnk->exec(); |
298 | if ( apps.contains(exe) != d->preload->isChecked() ) { | 299 | if ( apps.contains(exe) != d->preload->isChecked() ) { |
299 | if ( d->preload->isChecked() ) { | 300 | if ( d->preload->isChecked() ) { |
300 | apps.append(exe); | 301 | apps.append(exe); |
301 | QCopEnvelope e("QPE/Application/"+exe.local8Bit(), | 302 | QCopEnvelope e("QPE/Application/"+exe.local8Bit(), |
302 | "enablePreload()"); | 303 | "enablePreload()"); |
303 | } else { | 304 | } else { |
304 | apps.remove(exe); | 305 | apps.remove(exe); |
305 | QCopEnvelope e("QPE/Application/"+exe.local8Bit(), | 306 | QCopEnvelope e("QPE/Application/"+exe.local8Bit(), |
306 | "quitIfInvisible()"); | 307 | "quitIfInvisible()"); |
307 | } | 308 | } |
308 | cfg.writeEntry("Apps",apps,','); | 309 | cfg.writeEntry("Apps",apps,','); |
309 | } | 310 | } |
310 | } | 311 | } |
311 | } | 312 | } |
312 | QDialog::done( ok ); | 313 | QDialog::done( ok ); |
313 | } | 314 | } |
314 | 315 | ||
diff --git a/library/storage.cpp b/library/storage.cpp index 2d996fa..13639fe 100644 --- a/library/storage.cpp +++ b/library/storage.cpp | |||
@@ -1,196 +1,196 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> | 2 | ** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Qtopia Environment. | 5 | ** This file is part of Qtopia Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #include <qpe/storage.h> | 22 | #include <qpe/storage.h> |
23 | #ifdef QT_QWS_CUSTOM | 23 | #ifdef QT_QWS_CUSTOM |
24 | #include <qpe/custom.h> | 24 | #include <qpe/custom.h> |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qcopchannel_qws.h> | 29 | #include <qcopchannel_qws.h> |
30 | 30 | ||
31 | #include <stdio.h> | 31 | #include <stdio.h> |
32 | 32 | ||
33 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 33 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
34 | #include <sys/vfs.h> | 34 | #include <sys/vfs.h> |
35 | #include <mntent.h> | 35 | #include <mntent.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <qstringlist.h> | 38 | #include <qstringlist.h> |
39 | 39 | ||
40 | static bool isCF(const QString& m) | 40 | static bool isCF(const QString& m) |
41 | { | 41 | { |
42 | FILE* f = fopen("/var/run/stab", "r"); | 42 | FILE* f = fopen("/var/run/stab", "r"); |
43 | if (!f) f = fopen("/var/state/pcmcia/stab", "r"); | 43 | if (!f) f = fopen("/var/state/pcmcia/stab", "r"); |
44 | if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); | 44 | if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); |
45 | if ( f ) { | 45 | if ( f ) { |
46 | char line[1024]; | 46 | char line[1024]; |
47 | char devtype[80]; | 47 | char devtype[80]; |
48 | char devname[80]; | 48 | char devname[80]; |
49 | while ( fgets( line, 1024, f ) ) { | 49 | while ( fgets( line, 1024, f ) ) { |
50 | // 0 ide ide-cs 0 hda 3 0 | 50 | // 0 ide ide-cs 0 hda 3 0 |
51 | if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) | 51 | if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) |
52 | { | 52 | { |
53 | if ( QString(devtype) == "ide" && m.find(devname)>0 ) { | 53 | if ( QString(devtype) == "ide" && m.find(devname)>0 ) { |
54 | fclose(f); | 54 | fclose(f); |
55 | return TRUE; | 55 | return TRUE; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | } | 58 | } |
59 | fclose(f); | 59 | fclose(f); |
60 | } | 60 | } |
61 | return FALSE; | 61 | return FALSE; |
62 | } | 62 | } |
63 | 63 | ||
64 | StorageInfo::StorageInfo( QObject *parent ) | 64 | StorageInfo::StorageInfo( QObject *parent ) |
65 | : QObject( parent ) | 65 | : QObject( parent ) |
66 | { | 66 | { |
67 | mFileSystems.setAutoDelete( TRUE ); | 67 | mFileSystems.setAutoDelete( TRUE ); |
68 | channel = new QCopChannel( "QPE/Card", this ); | 68 | channel = new QCopChannel( "QPE/Card", this ); |
69 | connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), | 69 | connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), |
70 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); | 70 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); |
71 | update(); | 71 | update(); |
72 | } | 72 | } |
73 | 73 | ||
74 | const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) | 74 | const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) |
75 | { | 75 | { |
76 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { | 76 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { |
77 | if ( filename.startsWith( (*i)->path() ) ) | 77 | if ( filename.startsWith( (*i)->path() ) ) |
78 | return (*i); | 78 | return (*i); |
79 | } | 79 | } |
80 | return 0; | 80 | return 0; |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) | 84 | void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) |
85 | { | 85 | { |
86 | if ( msg == "mtabChanged()" ) | 86 | if ( msg == "mtabChanged()" ) |
87 | update(); | 87 | update(); |
88 | } | 88 | } |
89 | // cause of the lack of a d pointer we need | 89 | // cause of the lack of a d pointer we need |
90 | // to store informations in a config file :( | 90 | // to store informations in a config file :( |
91 | void StorageInfo::update() | 91 | void StorageInfo::update() |
92 | { | 92 | { |
93 | //qDebug("StorageInfo::updating"); | 93 | //qDebug("StorageInfo::updating"); |
94 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 94 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
95 | struct mntent *me; | 95 | struct mntent *me; |
96 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 96 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
97 | 97 | ||
98 | QStringList curdisks; | 98 | QStringList curdisks; |
99 | QStringList curopts; | 99 | QStringList curopts; |
100 | QStringList curfs; | 100 | QStringList curfs; |
101 | bool rebuild = FALSE; | 101 | bool rebuild = FALSE; |
102 | int n=0; | 102 | int n=0; |
103 | if ( mntfp ) { | 103 | if ( mntfp ) { |
104 | while ( (me = getmntent( mntfp )) != 0 ) { | 104 | while ( (me = getmntent( mntfp )) != 0 ) { |
105 | QString fs = me->mnt_fsname; | 105 | QString fs = me->mnt_fsname; |
106 | if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" | 106 | if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" |
107 | || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" | 107 | || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" |
108 | || fs.left(8)=="/dev/ram" || fs.left(5)=="tmpfs" ) | 108 | || fs.left(5)=="tmpfs" ) |
109 | { | 109 | { |
110 | n++; | 110 | n++; |
111 | curdisks.append(fs); | 111 | curdisks.append(fs); |
112 | curopts.append( me->mnt_opts ); | 112 | curopts.append( me->mnt_opts ); |
113 | //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); | 113 | //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); |
114 | curfs.append( me->mnt_dir ); | 114 | curfs.append( me->mnt_dir ); |
115 | bool found = FALSE; | 115 | bool found = FALSE; |
116 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { | 116 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { |
117 | if ( (*i)->disk() == fs ) { | 117 | if ( (*i)->disk() == fs ) { |
118 | found = TRUE; | 118 | found = TRUE; |
119 | break; | 119 | break; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | if ( !found ) | 122 | if ( !found ) |
123 | rebuild = TRUE; | 123 | rebuild = TRUE; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | endmntent( mntfp ); | 126 | endmntent( mntfp ); |
127 | } | 127 | } |
128 | if ( rebuild || n != (int)mFileSystems.count() ) { | 128 | if ( rebuild || n != (int)mFileSystems.count() ) { |
129 | mFileSystems.clear(); | 129 | mFileSystems.clear(); |
130 | QStringList::ConstIterator it=curdisks.begin(); | 130 | QStringList::ConstIterator it=curdisks.begin(); |
131 | QStringList::ConstIterator fsit=curfs.begin(); | 131 | QStringList::ConstIterator fsit=curfs.begin(); |
132 | QStringList::ConstIterator optsIt=curopts.begin(); | 132 | QStringList::ConstIterator optsIt=curopts.begin(); |
133 | for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { | 133 | for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { |
134 | QString opts = *optsIt; | 134 | QString opts = *optsIt; |
135 | 135 | ||
136 | QString disk = *it; | 136 | QString disk = *it; |
137 | QString humanname; | 137 | QString humanname; |
138 | bool removable = FALSE; | 138 | bool removable = FALSE; |
139 | if ( isCF(disk) ) { | 139 | if ( isCF(disk) ) { |
140 | humanname = tr("CF Card"); | 140 | humanname = tr("CF Card"); |
141 | removable = TRUE; | 141 | removable = TRUE; |
142 | } else if ( disk == "/dev/hda1" ) { | 142 | } else if ( disk == "/dev/hda1" ) { |
143 | humanname = tr("Hard Disk"); | 143 | humanname = tr("Hard Disk"); |
144 | } else if ( disk.left(9) == "/dev/mmcd" ) { | 144 | } else if ( disk.left(9) == "/dev/mmcd" ) { |
145 | humanname = tr("SD Card"); | 145 | humanname = tr("SD Card"); |
146 | removable = TRUE; | 146 | removable = TRUE; |
147 | } else if ( disk.left(7) == "/dev/hd" ) | 147 | } else if ( disk.left(7) == "/dev/hd" ) |
148 | humanname = tr("Hard Disk") + " " + humanname.mid(7); | 148 | humanname = tr("Hard Disk") + " " + disk.mid(7); |
149 | else if ( disk.left(7) == "/dev/sd" ) | 149 | else if ( disk.left(7) == "/dev/sd" ) |
150 | humanname = tr("SCSI Hard Disk") + " " + humanname.mid(7); | 150 | humanname = tr("SCSI Hard Disk") + " " + disk.mid(7); |
151 | else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs | 151 | else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs |
152 | humanname = tr("Ram FS") + " " + humanname.mid(14); | 152 | humanname = tr("Internal Memory"); |
153 | else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) | 153 | else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) |
154 | humanname = tr("Internal Storage"); | 154 | humanname = tr("Internal Storage"); |
155 | else if ( disk.left(14) == "/dev/mtdblock/" ) | 155 | else if ( disk.left(14) == "/dev/mtdblock/" ) |
156 | humanname = tr("Internal Storage") + " " + humanname.mid(14); | 156 | humanname = tr("Internal Storage") + " " + disk.mid(14); |
157 | else if ( disk.left(13) == "/dev/mtdblock" ) | 157 | else if ( disk.left(13) == "/dev/mtdblock" ) |
158 | humanname = tr("Internal Storage") + " " + humanname.mid(13); | 158 | humanname = tr("Internal Storage") + " " + disk.mid(13); |
159 | else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs | 159 | else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs |
160 | humanname = tr("Ram FS") + " " + humanname.mid(5); | 160 | humanname = tr("Internal Memory"); |
161 | FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); | 161 | FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); |
162 | mFileSystems.append( fs ); | 162 | mFileSystems.append( fs ); |
163 | } | 163 | } |
164 | emit disksChanged(); | 164 | emit disksChanged(); |
165 | } else { | 165 | } else { |
166 | // just update them | 166 | // just update them |
167 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) | 167 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) |
168 | i.current()->update(); | 168 | i.current()->update(); |
169 | } | 169 | } |
170 | #endif | 170 | #endif |
171 | } | 171 | } |
172 | 172 | ||
173 | //--------------------------------------------------------------------------- | 173 | //--------------------------------------------------------------------------- |
174 | 174 | ||
175 | FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) | 175 | FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) |
176 | : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) | 176 | : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) |
177 | { | 177 | { |
178 | update(); | 178 | update(); |
179 | } | 179 | } |
180 | 180 | ||
181 | void FileSystem::update() | 181 | void FileSystem::update() |
182 | { | 182 | { |
183 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 183 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
184 | struct statfs fs; | 184 | struct statfs fs; |
185 | if ( !statfs( fspath.latin1(), &fs ) ) { | 185 | if ( !statfs( fspath.latin1(), &fs ) ) { |
186 | blkSize = fs.f_bsize; | 186 | blkSize = fs.f_bsize; |
187 | totalBlks = fs.f_blocks; | 187 | totalBlks = fs.f_blocks; |
188 | availBlks = fs.f_bavail; | 188 | availBlks = fs.f_bavail; |
189 | } else { | 189 | } else { |
190 | blkSize = 0; | 190 | blkSize = 0; |
191 | totalBlks = 0; | 191 | totalBlks = 0; |
192 | availBlks = 0; | 192 | availBlks = 0; |
193 | } | 193 | } |
194 | #endif | 194 | #endif |
195 | } | 195 | } |
196 | 196 | ||