author | zecke <zecke> | 2002-03-24 19:31:32 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-24 19:31:32 (UTC) |
commit | eb813af4c1e301c8ba015627a1da04f8199a3be2 (patch) (unidiff) | |
tree | 7f23f61c2d8c58655fc98798b7f1b4aec75b5ff3 | |
parent | 4802684dd785274be50b472c87e315da0e325449 (diff) | |
download | opie-eb813af4c1e301c8ba015627a1da04f8199a3be2.zip opie-eb813af4c1e301c8ba015627a1da04f8199a3be2.tar.gz opie-eb813af4c1e301c8ba015627a1da04f8199a3be2.tar.bz2 |
Here is the second chunk of bits to make things a bit more fast
-rw-r--r-- | library/global.cpp | 35 | ||||
-rw-r--r-- | library/global.h | 8 | ||||
-rw-r--r-- | library/storage.cpp | 5 |
3 files changed, 42 insertions, 6 deletions
diff --git a/library/global.cpp b/library/global.cpp index dd15eb7..5a28595 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -1,178 +1,200 @@ | |||
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 | #define QTOPIA_INTERNAL_LANGLIST | 20 | #define QTOPIA_INTERNAL_LANGLIST |
21 | #include <qpe/qpedebug.h> | 21 | #include <qpe/qpedebug.h> |
22 | #include <qpe/global.h> | 22 | #include <qpe/global.h> |
23 | #include <qpe/qdawg.h> | 23 | #include <qpe/qdawg.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/storage.h> | 26 | #include <qpe/storage.h> |
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 28 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
29 | #include "qpe/qcopenvelope_qws.h" | 29 | #include "qpe/qcopenvelope_qws.h" |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <qmap.h> | 35 | #include <qmap.h> |
36 | #include <qdict.h> | 36 | #include <qdict.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qmessagebox.h> | 38 | #include <qmessagebox.h> |
39 | #include <qregexp.h> | 39 | #include <qregexp.h> |
40 | 40 | ||
41 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | #include <sys/stat.h> | 42 | #include <sys/stat.h> |
43 | #include <sys/wait.h> | 43 | #include <sys/wait.h> |
44 | #include <sys/types.h> | 44 | #include <sys/types.h> |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <unistd.h> | 46 | #include <unistd.h> |
47 | 47 | ||
48 | #include <qwindowsystem_qws.h> // for qwsServer | 48 | #include <qwindowsystem_qws.h> // for qwsServer |
49 | #include <qdatetime.h> | 49 | #include <qdatetime.h> |
50 | 50 | ||
51 | #include <qfile.h> | ||
52 | |||
53 | namespace { | ||
54 | // checks if the storage should be searched | ||
55 | bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke | ||
56 | QFile file(path ); | ||
57 | if(!file.open(IO_ReadOnly ) ) | ||
58 | return true; | ||
59 | |||
60 | QByteArray array = file.readAll(); | ||
61 | QStringList list = QStringList::split('\n', QString( array ) ); | ||
62 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ | ||
63 | if( (*it).startsWith("autocheck = 0" ) ){ | ||
64 | return true; | ||
65 | }else if( (*it).startsWith("autocheck = 1" ) ){ | ||
66 | return false; | ||
67 | } | ||
68 | } | ||
69 | return true; | ||
70 | } | ||
71 | } | ||
72 | |||
51 | //#include "quickexec_p.h" | 73 | //#include "quickexec_p.h" |
52 | 74 | ||
53 | class Emitter : public QObject { | 75 | class Emitter : public QObject { |
54 | Q_OBJECT | 76 | Q_OBJECT |
55 | public: | 77 | public: |
56 | Emitter( QWidget* receiver, const QString& document ) | 78 | Emitter( QWidget* receiver, const QString& document ) |
57 | { | 79 | { |
58 | connect(this, SIGNAL(setDocument(const QString&)), | 80 | connect(this, SIGNAL(setDocument(const QString&)), |
59 | receiver, SLOT(setDocument(const QString&))); | 81 | receiver, SLOT(setDocument(const QString&))); |
60 | emit setDocument(document); | 82 | emit setDocument(document); |
61 | disconnect(this, SIGNAL(setDocument(const QString&)), | 83 | disconnect(this, SIGNAL(setDocument(const QString&)), |
62 | receiver, SLOT(setDocument(const QString&))); | 84 | receiver, SLOT(setDocument(const QString&))); |
63 | } | 85 | } |
64 | 86 | ||
65 | signals: | 87 | signals: |
66 | void setDocument(const QString&); | 88 | void setDocument(const QString&); |
67 | }; | 89 | }; |
68 | 90 | ||
69 | 91 | ||
70 | class StartingAppList : public QObject { | 92 | class StartingAppList : public QObject { |
71 | Q_OBJECT | 93 | Q_OBJECT |
72 | public: | 94 | public: |
73 | static void add( const QString& name ); | 95 | static void add( const QString& name ); |
74 | static bool isStarting( const QString name ); | 96 | static bool isStarting( const QString name ); |
75 | private slots: | 97 | private slots: |
76 | void handleNewChannel( const QString &); | 98 | void handleNewChannel( const QString &); |
77 | private: | 99 | private: |
78 | StartingAppList( QObject *parent=0, const char* name=0 ) ; | 100 | StartingAppList( QObject *parent=0, const char* name=0 ) ; |
79 | 101 | ||
80 | QDict<QTime> dict; | 102 | QDict<QTime> dict; |
81 | static StartingAppList *appl; | 103 | static StartingAppList *appl; |
82 | }; | 104 | }; |
83 | 105 | ||
84 | StartingAppList* StartingAppList::appl = 0; | 106 | StartingAppList* StartingAppList::appl = 0; |
85 | 107 | ||
86 | StartingAppList::StartingAppList( QObject *parent, const char* name ) | 108 | StartingAppList::StartingAppList( QObject *parent, const char* name ) |
87 | :QObject( parent, name ) | 109 | :QObject( parent, name ) |
88 | { | 110 | { |
89 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) | 111 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) |
90 | connect( qwsServer, SIGNAL( newChannel(const QString&)), | 112 | connect( qwsServer, SIGNAL( newChannel(const QString&)), |
91 | this, SLOT( handleNewChannel(const QString&)) ); | 113 | this, SLOT( handleNewChannel(const QString&)) ); |
92 | dict.setAutoDelete( TRUE ); | 114 | dict.setAutoDelete( TRUE ); |
93 | #endif | 115 | #endif |
94 | } | 116 | } |
95 | 117 | ||
96 | void StartingAppList::add( const QString& name ) | 118 | void StartingAppList::add( const QString& name ) |
97 | { | 119 | { |
98 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) | 120 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) |
99 | if ( !appl ) | 121 | if ( !appl ) |
100 | appl = new StartingAppList; | 122 | appl = new StartingAppList; |
101 | QTime *t = new QTime; | 123 | QTime *t = new QTime; |
102 | t->start(); | 124 | t->start(); |
103 | appl->dict.insert( "QPE/Application/" + name, t ); | 125 | appl->dict.insert( "QPE/Application/" + name, t ); |
104 | #endif | 126 | #endif |
105 | } | 127 | } |
106 | 128 | ||
107 | bool StartingAppList::isStarting( const QString name ) | 129 | bool StartingAppList::isStarting( const QString name ) |
108 | { | 130 | { |
109 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) | 131 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) |
110 | if ( appl ) { | 132 | if ( appl ) { |
111 | QTime *t = appl->dict.find( "QPE/Application/" + name ); | 133 | QTime *t = appl->dict.find( "QPE/Application/" + name ); |
112 | if ( !t ) | 134 | if ( !t ) |
113 | return FALSE; | 135 | return FALSE; |
114 | if ( t->elapsed() > 10000 ) { | 136 | if ( t->elapsed() > 10000 ) { |
115 | // timeout in case of crash or something | 137 | // timeout in case of crash or something |
116 | appl->dict.remove( "QPE/Application/" + name ); | 138 | appl->dict.remove( "QPE/Application/" + name ); |
117 | return FALSE; | 139 | return FALSE; |
118 | } | 140 | } |
119 | return TRUE; | 141 | return TRUE; |
120 | } | 142 | } |
121 | #endif | 143 | #endif |
122 | return FALSE; | 144 | return FALSE; |
123 | } | 145 | } |
124 | 146 | ||
125 | void StartingAppList::handleNewChannel( const QString & name ) | 147 | void StartingAppList::handleNewChannel( const QString & name ) |
126 | { | 148 | { |
127 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) | 149 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) |
128 | dict.remove( name ); | 150 | dict.remove( name ); |
129 | #endif | 151 | #endif |
130 | } | 152 | } |
131 | 153 | ||
132 | static bool docDirCreated = FALSE; | 154 | static bool docDirCreated = FALSE; |
133 | static QDawg* fixed_dawg = 0; | 155 | static QDawg* fixed_dawg = 0; |
134 | static QDict<QDawg> *named_dawg = 0; | 156 | static QDict<QDawg> *named_dawg = 0; |
135 | 157 | ||
136 | static QString qpeDir() | 158 | static QString qpeDir() |
137 | { | 159 | { |
138 | QString dir = getenv("OPIEDIR"); | 160 | QString dir = getenv("OPIEDIR"); |
139 | if ( dir.isEmpty() ) dir = ".."; | 161 | if ( dir.isEmpty() ) dir = ".."; |
140 | return dir; | 162 | return dir; |
141 | } | 163 | } |
142 | 164 | ||
143 | static QString dictDir() | 165 | static QString dictDir() |
144 | { | 166 | { |
145 | return qpeDir() + "/etc/dict"; | 167 | return qpeDir() + "/etc/dict"; |
146 | } | 168 | } |
147 | 169 | ||
148 | /*! | 170 | /*! |
149 | \class Global global.h | 171 | \class Global global.h |
150 | \brief The Global class collects application-wide global functions. | 172 | \brief The Global class collects application-wide global functions. |
151 | */ | 173 | */ |
152 | 174 | ||
153 | /*! | 175 | /*! |
154 | \internal | 176 | \internal |
155 | */ | 177 | */ |
156 | Global::Global() | 178 | Global::Global() |
157 | { | 179 | { |
158 | } | 180 | } |
159 | 181 | ||
160 | /*! | 182 | /*! |
161 | Returns the unchangeable QDawg that contains general | 183 | Returns the unchangeable QDawg that contains general |
162 | words for the current locale. | 184 | words for the current locale. |
163 | 185 | ||
164 | \sa addedDawg() | 186 | \sa addedDawg() |
165 | */ | 187 | */ |
166 | const QDawg& Global::fixedDawg() | 188 | const QDawg& Global::fixedDawg() |
167 | { | 189 | { |
168 | if ( !fixed_dawg ) { | 190 | if ( !fixed_dawg ) { |
169 | if ( !docDirCreated ) | 191 | if ( !docDirCreated ) |
170 | createDocDir(); | 192 | createDocDir(); |
171 | 193 | ||
172 | fixed_dawg = new QDawg; | 194 | fixed_dawg = new QDawg; |
173 | QString dawgfilename = dictDir() + "/dawg"; | 195 | QString dawgfilename = dictDir() + "/dawg"; |
174 | QString words_lang; | 196 | QString words_lang; |
175 | QStringList langs = Global::languageList(); | 197 | QStringList langs = Global::languageList(); |
176 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 198 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
177 | QString lang = *it; | 199 | QString lang = *it; |
178 | words_lang = dictDir() + "/words." + lang; | 200 | words_lang = dictDir() + "/words." + lang; |
@@ -513,175 +535,178 @@ void Global::invoke(const QString &c) | |||
513 | ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); | 535 | ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); |
514 | ::execvp( args[0], (char * const *)args ); | 536 | ::execvp( args[0], (char * const *)args ); |
515 | _exit( -1 ); | 537 | _exit( -1 ); |
516 | } | 538 | } |
517 | } | 539 | } |
518 | StartingAppList::add( list[0] ); | 540 | StartingAppList::add( list[0] ); |
519 | #endif //QT_NO_QWS_MULTIPROCESS | 541 | #endif //QT_NO_QWS_MULTIPROCESS |
520 | } | 542 | } |
521 | 543 | ||
522 | /*! | 544 | /*! |
523 | Executes application identfied by \a c, passing \a document. | 545 | Executes application identfied by \a c, passing \a document. |
524 | 546 | ||
525 | 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 |
526 | the application's QPE/Application/<i>appname</i> channel. | 548 | the application's QPE/Application/<i>appname</i> channel. |
527 | */ | 549 | */ |
528 | void Global::execute( const QString &c, const QString& document ) | 550 | void Global::execute( const QString &c, const QString& document ) |
529 | { | 551 | { |
530 | if ( qApp->type() != QApplication::GuiServer ) { | 552 | if ( qApp->type() != QApplication::GuiServer ) { |
531 | // ask the server to do the work | 553 | // ask the server to do the work |
532 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 554 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
533 | if ( document.isNull() ) { | 555 | if ( document.isNull() ) { |
534 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 556 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
535 | e << c; | 557 | e << c; |
536 | } else { | 558 | } else { |
537 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); | 559 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); |
538 | e << c << document; | 560 | e << c << document; |
539 | } | 561 | } |
540 | #endif | 562 | #endif |
541 | return; | 563 | return; |
542 | } | 564 | } |
543 | 565 | ||
544 | // 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 |
545 | // else try and find it in the bin directory | 567 | // else try and find it in the bin directory |
546 | if (builtin) { | 568 | if (builtin) { |
547 | for (int i = 0; builtin[i].file; i++) { | 569 | for (int i = 0; builtin[i].file; i++) { |
548 | if ( builtin[i].file == c ) { | 570 | if ( builtin[i].file == c ) { |
549 | if ( running[i] ) { | 571 | if ( running[i] ) { |
550 | if ( !document.isNull() && builtin[i].documentary ) | 572 | if ( !document.isNull() && builtin[i].documentary ) |
551 | setDocument(running[i], document); | 573 | setDocument(running[i], document); |
552 | running[i]->raise(); | 574 | running[i]->raise(); |
553 | running[i]->show(); | 575 | running[i]->show(); |
554 | running[i]->setActiveWindow(); | 576 | running[i]->setActiveWindow(); |
555 | } else { | 577 | } else { |
556 | running[i] = builtin[i].func( builtin[i].maximized ); | 578 | running[i] = builtin[i].func( builtin[i].maximized ); |
557 | } | 579 | } |
558 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 580 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
559 | e << c; // that was quick ;-) | 581 | e << c; // that was quick ;-) |
560 | return; | 582 | return; |
561 | } | 583 | } |
562 | } | 584 | } |
563 | } | 585 | } |
564 | 586 | ||
565 | //Global::invoke(c, document); | 587 | //Global::invoke(c, document); |
566 | 588 | ||
567 | // Convert the command line in to a list of arguments | 589 | // Convert the command line in to a list of arguments |
568 | QStringList list = QStringList::split(QRegExp(" *"),c); | 590 | QStringList list = QStringList::split(QRegExp(" *"),c); |
569 | 591 | ||
570 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 592 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
571 | QString ap=list[0]; | 593 | QString ap=list[0]; |
572 | 594 | ||
573 | qDebug("executing %s", ap.latin1() ); | 595 | qDebug("executing %s", ap.latin1() ); |
574 | if ( ap == "suspend" ) { | 596 | if ( ap == "suspend" ) { |
575 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 597 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
576 | return; | 598 | return; |
577 | } | 599 | } |
578 | 600 | ||
579 | /* 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 |
580 | preceeding function */ | 602 | preceeding function */ |
581 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | 603 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } |
582 | if ( !document.isEmpty() ) { | 604 | if ( !document.isEmpty() ) { |
583 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); | 605 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); |
584 | env << document; | 606 | env << document; |
585 | } | 607 | } |
586 | #endif | 608 | #endif |
587 | } | 609 | } |
588 | 610 | ||
589 | /*! | 611 | /*! |
590 | Returns the string \a s with the characters backslash, ", and $ | 612 | Returns the string \a s with the characters backslash, ", and $ |
591 | quoted by a preceeding backslash. | 613 | quoted by a preceeding backslash. |
592 | */ | 614 | */ |
593 | QString Global::shellQuote(const QString& s) | 615 | QString Global::shellQuote(const QString& s) |
594 | { | 616 | { |
595 | QString r="\""; | 617 | QString r="\""; |
596 | for (int i=0; i<(int)s.length(); i++) { | 618 | for (int i=0; i<(int)s.length(); i++) { |
597 | char c = s[i].latin1(); | 619 | char c = s[i].latin1(); |
598 | switch (c) { | 620 | switch (c) { |
599 | case '\\': case '"': case '$': | 621 | case '\\': case '"': case '$': |
600 | r+="\\"; | 622 | r+="\\"; |
601 | } | 623 | } |
602 | r += s[i]; | 624 | r += s[i]; |
603 | } | 625 | } |
604 | r += "\""; | 626 | r += "\""; |
605 | return r; | 627 | return r; |
606 | } | 628 | } |
607 | 629 | ||
608 | /*! | 630 | /*! |
609 | Returns the string \a s with the characters backslash and " | 631 | Returns the string \a s with the characters backslash and " |
610 | quoted by a preceeding backslash. | 632 | quoted by a preceeding backslash. |
611 | */ | 633 | */ |
612 | QString Global::stringQuote(const QString& s) | 634 | QString Global::stringQuote(const QString& s) |
613 | { | 635 | { |
614 | QString r="\""; | 636 | QString r="\""; |
615 | for (int i=0; i<(int)s.length(); i++) { | 637 | for (int i=0; i<(int)s.length(); i++) { |
616 | char c = s[i].latin1(); | 638 | char c = s[i].latin1(); |
617 | switch (c) { | 639 | switch (c) { |
618 | case '\\': case '"': | 640 | case '\\': case '"': |
619 | r+="\\"; | 641 | r+="\\"; |
620 | } | 642 | } |
621 | r += s[i]; | 643 | r += s[i]; |
622 | } | 644 | } |
623 | r += "\""; | 645 | r += "\""; |
624 | return r; | 646 | return r; |
625 | } | 647 | } |
626 | 648 | ||
627 | /*! | 649 | /*! |
628 | Finds all documents on the system's document directories which | 650 | Finds all documents on the system's document directories which |
629 | match the filter \a mimefilter, and appends the resulting DocLnk | 651 | match the filter \a mimefilter, and appends the resulting DocLnk |
630 | objects to \a folder. | 652 | objects to \a folder. |
631 | */ | 653 | */ |
632 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) | 654 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) |
633 | { | 655 | { |
634 | QString homedocs = QString(getenv("HOME")) + "/Documents"; | 656 | QString homedocs = QString(getenv("HOME")) + "/Documents"; |
635 | DocLnkSet d(homedocs,mimefilter); | 657 | DocLnkSet d(homedocs,mimefilter); |
636 | folder->appendFrom(d); | 658 | folder->appendFrom(d); |
637 | StorageInfo storage; | 659 | StorageInfo storage; |
638 | const QList<FileSystem> &fs = storage.fileSystems(); | 660 | const QList<FileSystem> &fs = storage.fileSystems(); |
639 | QListIterator<FileSystem> it ( fs ); | 661 | QListIterator<FileSystem> it ( fs ); |
640 | for ( ; it.current(); ++it ) { | 662 | for ( ; it.current(); ++it ) { |
641 | if ( (*it)->isRemovable() ) { | 663 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
642 | QString path = (*it)->path(); | 664 | // this is a candidate look at the cf and see if we should search on it |
643 | DocLnkSet ide( path, mimefilter ); | 665 | QString path = (*it)->path(); |
644 | folder->appendFrom(ide); | 666 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) |
645 | } | 667 | continue; |
668 | DocLnkSet ide( path, mimefilter ); | ||
669 | folder->appendFrom(ide); | ||
670 | } | ||
646 | } | 671 | } |
647 | } | 672 | } |
648 | 673 | ||
649 | QStringList Global::languageList() | 674 | QStringList Global::languageList() |
650 | { | 675 | { |
651 | QString lang = getenv("LANG"); | 676 | QString lang = getenv("LANG"); |
652 | QStringList langs; | 677 | QStringList langs; |
653 | langs.append(lang); | 678 | langs.append(lang); |
654 | int i = lang.find("."); | 679 | int i = lang.find("."); |
655 | if ( i > 0 ) | 680 | if ( i > 0 ) |
656 | lang = lang.left( i ); | 681 | lang = lang.left( i ); |
657 | i = lang.find( "_" ); | 682 | i = lang.find( "_" ); |
658 | if ( i > 0 ) | 683 | if ( i > 0 ) |
659 | langs.append(lang.left(i)); | 684 | langs.append(lang.left(i)); |
660 | return langs; | 685 | return langs; |
661 | } | 686 | } |
662 | 687 | ||
663 | QStringList Global::helpPath() | 688 | QStringList Global::helpPath() |
664 | { | 689 | { |
665 | QStringList path; | 690 | QStringList path; |
666 | QStringList langs = Global::languageList(); | 691 | QStringList langs = Global::languageList(); |
667 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { | 692 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { |
668 | QString lang = *it; | 693 | QString lang = *it; |
669 | if ( !lang.isEmpty() ) | 694 | if ( !lang.isEmpty() ) |
670 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; | 695 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; |
671 | } | 696 | } |
672 | path += QPEApplication::qpeDir() + "/pics"; | 697 | path += QPEApplication::qpeDir() + "/pics"; |
673 | path += QPEApplication::qpeDir() + "/help/en/html"; | 698 | path += QPEApplication::qpeDir() + "/help/en/html"; |
674 | path += QPEApplication::qpeDir() + "/docs"; | 699 | path += QPEApplication::qpeDir() + "/docs"; |
675 | QString dir = QDir::current().canonicalPath(); | 700 | QString dir = QDir::current().canonicalPath(); |
676 | if ( dir == "/" ) | 701 | if ( dir == "/" ) |
677 | dir += "/docs"; | 702 | dir += "/docs"; |
678 | else { | 703 | else { |
679 | path += dir + "/../pics"; | 704 | path += dir + "/../pics"; |
680 | dir += "/../docs"; | 705 | dir += "/../docs"; |
681 | path += dir; | 706 | path += dir; |
682 | } | 707 | } |
683 | return path; | 708 | return path; |
684 | } | 709 | } |
685 | 710 | ||
686 | 711 | ||
687 | #include "global.moc" | 712 | #include "global.moc" |
diff --git a/library/global.h b/library/global.h index d9ff8f8..fdf8754 100644 --- a/library/global.h +++ b/library/global.h | |||
@@ -1,85 +1,93 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 4 | ** |
4 | ** This file is part of Qtopia Environment. | 5 | ** This file is part of Qtopia Environment. |
5 | ** | 6 | ** |
6 | ** 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 |
7 | ** 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 |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 10 | ** packaging of this file. |
10 | ** | 11 | ** |
11 | ** 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 |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 14 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 16 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 18 | ** not clear to you. |
18 | ** | 19 | ** |
19 | **********************************************************************/ | 20 | **********************************************************************/ |
20 | #ifndef GLOBAL_H | 21 | #ifndef GLOBAL_H |
21 | #define GLOBAL_H | 22 | #define GLOBAL_H |
22 | 23 | ||
23 | #include <qstringlist.h> | 24 | #include <qstringlist.h> |
24 | #include <qguardedptr.h> | 25 | #include <qguardedptr.h> |
25 | class QDawg; | 26 | class QDawg; |
26 | class QLabel; | 27 | class QLabel; |
27 | class QWidget; | 28 | class QWidget; |
28 | class AppLnk; | 29 | class AppLnk; |
29 | class DocLnkSet; | 30 | class DocLnkSet; |
30 | 31 | ||
31 | class Global | 32 | class Global |
32 | { | 33 | { |
33 | public: | 34 | public: |
34 | Global(); | 35 | Global(); |
35 | 36 | ||
36 | // Dictionaries | 37 | // Dictionaries |
37 | static const QDawg& fixedDawg(); | 38 | static const QDawg& fixedDawg(); |
38 | static const QDawg& addedDawg(); | 39 | static const QDawg& addedDawg(); |
39 | static const QDawg& dawg(const QString& name); | 40 | static const QDawg& dawg(const QString& name); |
40 | 41 | ||
41 | static void addWords(const QStringList& word); | 42 | static void addWords(const QStringList& word); |
42 | static void addWords(const QString& dictname, const QStringList& word); | 43 | static void addWords(const QString& dictname, const QStringList& word); |
43 | // static void removeWords(const QStringList& word); -- if someone wants it | 44 | // static void removeWords(const QStringList& word); -- if someone wants it |
44 | 45 | ||
45 | static void createDocDir(); | 46 | static void createDocDir(); |
46 | 47 | ||
47 | static void findDocuments(DocLnkSet* folder, const QString &mimefilter=QString::null); | 48 | static void findDocuments(DocLnkSet* folder, const QString &mimefilter=QString::null); |
49 | // we don't need a mimefilter. Same as above but this is fast as light speed or not ;) | ||
50 | //static void findNewDocuments( DocLnkSet* folder ); | ||
48 | 51 | ||
49 | static QString applicationFileName(const QString& appname, const QString& filename); | 52 | static QString applicationFileName(const QString& appname, const QString& filename); |
50 | 53 | ||
51 | struct Command { | 54 | struct Command { |
52 | const char *file; | 55 | const char *file; |
53 | QWidget *(*func)( bool ); | 56 | QWidget *(*func)( bool ); |
54 | bool maximized; | 57 | bool maximized; |
55 | bool documentary; | 58 | bool documentary; |
56 | }; | 59 | }; |
57 | static void setBuiltinCommands( Command* ); | 60 | static void setBuiltinCommands( Command* ); |
58 | 61 | ||
59 | static void invoke( const QString &exec); | 62 | static void invoke( const QString &exec); |
60 | static void execute( const QString &exec, const QString &document=QString::null ); | 63 | static void execute( const QString &exec, const QString &document=QString::null ); |
61 | static void setDocument( QWidget* receiver, const QString& document ); | 64 | static void setDocument( QWidget* receiver, const QString& document ); |
62 | static bool terminateBuiltin( const QString& ); | 65 | static bool terminateBuiltin( const QString& ); |
63 | static void terminate( const AppLnk* ); | 66 | static void terminate( const AppLnk* ); |
64 | 67 | ||
65 | static bool isBuiltinCommand( const QString &name ); | 68 | static bool isBuiltinCommand( const QString &name ); |
66 | 69 | ||
67 | // system messaging | 70 | // system messaging |
68 | static void applyStyle(); | 71 | static void applyStyle(); |
69 | static void statusMessage(const QString&); | 72 | static void statusMessage(const QString&); |
70 | static QWidget *shutdown( bool = FALSE ); | 73 | static QWidget *shutdown( bool = FALSE ); |
71 | static QWidget *restart( bool = FALSE ); | 74 | static QWidget *restart( bool = FALSE ); |
72 | static void hideInputMethod(); | 75 | static void hideInputMethod(); |
73 | static void showInputMethod(); | 76 | static void showInputMethod(); |
74 | 77 | ||
75 | static void writeHWClock(); | 78 | static void writeHWClock(); |
76 | 79 | ||
77 | static QString shellQuote(const QString& s); | 80 | static QString shellQuote(const QString& s); |
78 | static QString stringQuote(const QString& s); | 81 | static QString stringQuote(const QString& s); |
79 | 82 | ||
83 | #ifdef QTOPIA_INTERNAL_LANGLIST | ||
84 | static QStringList languageList(); | ||
85 | static QStringList helpPath(); | ||
86 | #endif | ||
87 | |||
80 | private: | 88 | private: |
81 | static Command* builtin; | 89 | static Command* builtin; |
82 | static QGuardedPtr<QWidget> *running; | 90 | static QGuardedPtr<QWidget> *running; |
83 | }; | 91 | }; |
84 | 92 | ||
85 | #endif | 93 | #endif |
diff --git a/library/storage.cpp b/library/storage.cpp index bd34a5f..a4c96be 100644 --- a/library/storage.cpp +++ b/library/storage.cpp | |||
@@ -1,188 +1,191 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 4 | ** |
4 | ** This file is part of Qtopia Environment. | 5 | ** This file is part of Qtopia Environment. |
5 | ** | 6 | ** |
6 | ** 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 |
7 | ** 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 |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 10 | ** packaging of this file. |
10 | ** | 11 | ** |
11 | ** 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 |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 14 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 16 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 18 | ** not clear to you. |
18 | ** | 19 | ** |
19 | **********************************************************************/ | 20 | **********************************************************************/ |
20 | 21 | ||
21 | #include <qpe/storage.h> | 22 | #include <qpe/storage.h> |
22 | #ifdef QT_QWS_CUSTOM | 23 | #ifdef QT_QWS_CUSTOM |
23 | #include <qpe/custom.h> | 24 | #include <qpe/custom.h> |
24 | #endif | 25 | #endif |
25 | 26 | ||
27 | #include <qfile.h> | ||
26 | #include <qtimer.h> | 28 | #include <qtimer.h> |
27 | #include <qcopchannel_qws.h> | 29 | #include <qcopchannel_qws.h> |
28 | 30 | ||
29 | #include <stdio.h> | 31 | #include <stdio.h> |
30 | 32 | ||
31 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 33 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
32 | #include <sys/vfs.h> | 34 | #include <sys/vfs.h> |
33 | #include <mntent.h> | 35 | #include <mntent.h> |
34 | #endif | 36 | #endif |
35 | 37 | ||
36 | #include <qstringlist.h> | 38 | #include <qstringlist.h> |
37 | 39 | ||
38 | static bool isCF(const QString& m) | 40 | static bool isCF(const QString& m) |
39 | { | 41 | { |
40 | FILE* f = fopen("/var/run/stab", "r"); | 42 | FILE* f = fopen("/var/run/stab", "r"); |
41 | if (!f) f = fopen("/var/state/pcmcia/stab", "r"); | 43 | if (!f) f = fopen("/var/state/pcmcia/stab", "r"); |
42 | if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); | 44 | if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); |
43 | if ( f ) { | 45 | if ( f ) { |
44 | char line[1024]; | 46 | char line[1024]; |
45 | char devtype[80]; | 47 | char devtype[80]; |
46 | char devname[80]; | 48 | char devname[80]; |
47 | while ( fgets( line, 1024, f ) ) { | 49 | while ( fgets( line, 1024, f ) ) { |
48 | // 0 ide ide-cs 0 hda 3 0 | 50 | // 0 ide ide-cs 0 hda 3 0 |
49 | if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) | 51 | if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) |
50 | { | 52 | { |
51 | if ( QString(devtype) == "ide" && m.find(devname)>0 ) { | 53 | if ( QString(devtype) == "ide" && m.find(devname)>0 ) { |
52 | fclose(f); | 54 | fclose(f); |
53 | return TRUE; | 55 | return TRUE; |
54 | } | 56 | } |
55 | } | 57 | } |
56 | } | 58 | } |
57 | fclose(f); | 59 | fclose(f); |
58 | } | 60 | } |
59 | return FALSE; | 61 | return FALSE; |
60 | } | 62 | } |
61 | 63 | ||
62 | StorageInfo::StorageInfo( QObject *parent ) | 64 | StorageInfo::StorageInfo( QObject *parent ) |
63 | : QObject( parent ) | 65 | : QObject( parent ) |
64 | { | 66 | { |
65 | mFileSystems.setAutoDelete( TRUE ); | 67 | mFileSystems.setAutoDelete( TRUE ); |
66 | channel = new QCopChannel( "QPE/Card", this ); | 68 | channel = new QCopChannel( "QPE/Card", this ); |
67 | connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), | 69 | connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), |
68 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); | 70 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); |
69 | update(); | 71 | update(); |
70 | } | 72 | } |
71 | 73 | ||
72 | const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) | 74 | const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) |
73 | { | 75 | { |
74 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { | 76 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { |
75 | if ( filename.startsWith( (*i)->path() ) ) | 77 | if ( filename.startsWith( (*i)->path() ) ) |
76 | return (*i); | 78 | return (*i); |
77 | } | 79 | } |
78 | return 0; | 80 | return 0; |
79 | } | 81 | } |
80 | 82 | ||
81 | 83 | ||
82 | void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) | 84 | void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) |
83 | { | 85 | { |
84 | if ( msg == "mtabChanged()" ) | 86 | if ( msg == "mtabChanged()" ) |
85 | update(); | 87 | update(); |
86 | } | 88 | } |
87 | 89 | // cause of the lack of a d pointer we need | |
90 | // to store informations in a config file :( | ||
88 | void StorageInfo::update() | 91 | void StorageInfo::update() |
89 | { | 92 | { |
90 | //qDebug("StorageInfo::updating"); | 93 | //qDebug("StorageInfo::updating"); |
91 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 94 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
92 | struct mntent *me; | 95 | struct mntent *me; |
93 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 96 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
94 | 97 | ||
95 | QStringList curdisks; | 98 | QStringList curdisks; |
96 | QStringList curopts; | 99 | QStringList curopts; |
97 | QStringList curfs; | 100 | QStringList curfs; |
98 | bool rebuild = FALSE; | 101 | bool rebuild = FALSE; |
99 | int n=0; | 102 | int n=0; |
100 | if ( mntfp ) { | 103 | if ( mntfp ) { |
101 | while ( (me = getmntent( mntfp )) != 0 ) { | 104 | while ( (me = getmntent( mntfp )) != 0 ) { |
102 | QString fs = me->mnt_fsname; | 105 | QString fs = me->mnt_fsname; |
103 | if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" | 106 | if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" |
104 | || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" ) | 107 | || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" ) |
105 | { | 108 | { |
106 | n++; | 109 | n++; |
107 | curdisks.append(fs); | 110 | curdisks.append(fs); |
108 | curopts.append( me->mnt_opts ); | 111 | curopts.append( me->mnt_opts ); |
109 | //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); | 112 | //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); |
110 | curfs.append( me->mnt_dir ); | 113 | curfs.append( me->mnt_dir ); |
111 | bool found = FALSE; | 114 | bool found = FALSE; |
112 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { | 115 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { |
113 | if ( (*i)->disk() == fs ) { | 116 | if ( (*i)->disk() == fs ) { |
114 | found = TRUE; | 117 | found = TRUE; |
115 | break; | 118 | break; |
116 | } | 119 | } |
117 | } | 120 | } |
118 | if ( !found ) | 121 | if ( !found ) |
119 | rebuild = TRUE; | 122 | rebuild = TRUE; |
120 | } | 123 | } |
121 | } | 124 | } |
122 | endmntent( mntfp ); | 125 | endmntent( mntfp ); |
123 | } | 126 | } |
124 | if ( rebuild || n != (int)mFileSystems.count() ) { | 127 | if ( rebuild || n != (int)mFileSystems.count() ) { |
125 | mFileSystems.clear(); | 128 | mFileSystems.clear(); |
126 | QStringList::ConstIterator it=curdisks.begin(); | 129 | QStringList::ConstIterator it=curdisks.begin(); |
127 | QStringList::ConstIterator fsit=curfs.begin(); | 130 | QStringList::ConstIterator fsit=curfs.begin(); |
128 | QStringList::ConstIterator optsIt=curopts.begin(); | 131 | QStringList::ConstIterator optsIt=curopts.begin(); |
129 | for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { | 132 | for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { |
130 | QString opts = *optsIt; | 133 | QString opts = *optsIt; |
131 | 134 | ||
132 | QString disk = *it; | 135 | QString disk = *it; |
133 | QString humanname; | 136 | QString humanname; |
134 | bool removable = FALSE; | 137 | bool removable = FALSE; |
135 | if ( isCF(disk) ) { | 138 | if ( isCF(disk) ) { |
136 | humanname = tr("CF Card"); | 139 | humanname = tr("CF Card"); |
137 | removable = TRUE; | 140 | removable = TRUE; |
138 | } else if ( disk == "/dev/hda1" ) { | 141 | } else if ( disk == "/dev/hda1" ) { |
139 | humanname = tr("Hard Disk"); | 142 | humanname = tr("Hard Disk"); |
140 | } else if ( disk.left(9) == "/dev/mmcd" ) { | 143 | } else if ( disk.left(9) == "/dev/mmcd" ) { |
141 | humanname = tr("SD Card"); | 144 | humanname = tr("SD Card"); |
142 | removable = TRUE; | 145 | removable = TRUE; |
143 | } else if ( disk.left(7) == "/dev/hd" ) | 146 | } else if ( disk.left(7) == "/dev/hd" ) |
144 | humanname = tr("Hard Disk") + " " + humanname.mid(7); | 147 | humanname = tr("Hard Disk") + " " + humanname.mid(7); |
145 | else if ( disk.left(7) == "/dev/sd" ) | 148 | else if ( disk.left(7) == "/dev/sd" ) |
146 | humanname = tr("SCSI Hard Disk") + " " + humanname.mid(7); | 149 | humanname = tr("SCSI Hard Disk") + " " + humanname.mid(7); |
147 | else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) | 150 | else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) |
148 | humanname = tr("Internal Storage"); | 151 | humanname = tr("Internal Storage"); |
149 | else if ( disk.left(14) == "/dev/mtdblock/" ) | 152 | else if ( disk.left(14) == "/dev/mtdblock/" ) |
150 | humanname = tr("Internal Storage") + " " + humanname.mid(14); | 153 | humanname = tr("Internal Storage") + " " + humanname.mid(14); |
151 | else if ( disk.left(13) == "/dev/mtdblock" ) | 154 | else if ( disk.left(13) == "/dev/mtdblock" ) |
152 | humanname = tr("Internal Storage") + " " + humanname.mid(13); | 155 | humanname = tr("Internal Storage") + " " + humanname.mid(13); |
153 | FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); | 156 | FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); |
154 | mFileSystems.append( fs ); | 157 | mFileSystems.append( fs ); |
155 | } | 158 | } |
156 | emit disksChanged(); | 159 | emit disksChanged(); |
157 | } else { | 160 | } else { |
158 | // just update them | 161 | // just update them |
159 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) | 162 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) |
160 | i.current()->update(); | 163 | i.current()->update(); |
161 | } | 164 | } |
162 | #endif | 165 | #endif |
163 | } | 166 | } |
164 | 167 | ||
165 | //--------------------------------------------------------------------------- | 168 | //--------------------------------------------------------------------------- |
166 | 169 | ||
167 | FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) | 170 | FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) |
168 | : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) | 171 | : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) |
169 | { | 172 | { |
170 | update(); | 173 | update(); |
171 | } | 174 | } |
172 | 175 | ||
173 | void FileSystem::update() | 176 | void FileSystem::update() |
174 | { | 177 | { |
175 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 178 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
176 | struct statfs fs; | 179 | struct statfs fs; |
177 | if ( !statfs( fspath.latin1(), &fs ) ) { | 180 | if ( !statfs( fspath.latin1(), &fs ) ) { |
178 | blkSize = fs.f_bsize; | 181 | blkSize = fs.f_bsize; |
179 | totalBlks = fs.f_blocks; | 182 | totalBlks = fs.f_blocks; |
180 | availBlks = fs.f_bavail; | 183 | availBlks = fs.f_bavail; |
181 | } else { | 184 | } else { |
182 | blkSize = 0; | 185 | blkSize = 0; |
183 | totalBlks = 0; | 186 | totalBlks = 0; |
184 | availBlks = 0; | 187 | availBlks = 0; |
185 | } | 188 | } |
186 | #endif | 189 | #endif |
187 | } | 190 | } |
188 | 191 | ||