-rw-r--r-- | libopie2/opiecore/oconfig.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/ofilenotify.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/opluginloader.h | 3 |
3 files changed, 6 insertions, 1 deletions
diff --git a/libopie2/opiecore/oconfig.cpp b/libopie2/opiecore/oconfig.cpp index 05d8070..6b57729 100644 --- a/libopie2/opiecore/oconfig.cpp +++ b/libopie2/opiecore/oconfig.cpp | |||
@@ -1,205 +1,207 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | Inspired by the config classes from the KDE Project which are | 5 | Inspired by the config classes from the KDE Project which are |
6 | =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> | 6 | =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> |
7 | .=l. | 7 | .=l. |
8 | .>+-= | 8 | .>+-= |
9 | _;:, .> :=|. This program is free software; you can | 9 | _;:, .> :=|. This program is free software; you can |
10 | .> <`_, > . <= redistribute it and/or modify it under | 10 | .> <`_, > . <= redistribute it and/or modify it under |
11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
12 | .="- .-=="i, .._ License as published by the Free Software | 12 | .="- .-=="i, .._ License as published by the Free Software |
13 | - . .-<_> .<> Foundation; either version 2 of the License, | 13 | - . .-<_> .<> Foundation; either version 2 of the License, |
14 | ._= =} : or (at your option) any later version. | 14 | ._= =} : or (at your option) any later version. |
15 | .%`+i> _;_. | 15 | .%`+i> _;_. |
16 | .i_,=:_. -<s. This program is distributed in the hope that | 16 | .i_,=:_. -<s. This program is distributed in the hope that |
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
18 | : .. .:, . . . without even the implied warranty of | 18 | : .. .:, . . . without even the implied warranty of |
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
21 | ..}^=.= = ; Library General Public License for more | 21 | ..}^=.= = ; Library General Public License for more |
22 | ++= -. .` .: details. | 22 | ++= -. .` .: details. |
23 | : = ...= . :.=- | 23 | : = ...= . :.=- |
24 | -. .:....=;==+<; You should have received a copy of the GNU | 24 | -. .:....=;==+<; You should have received a copy of the GNU |
25 | -_. . . )=. = Library General Public License along with | 25 | -_. . . )=. = Library General Public License along with |
26 | -- :-=` this library; see the file COPYING.LIB. | 26 | -- :-=` this library; see the file COPYING.LIB. |
27 | If not, write to the Free Software Foundation, | 27 | If not, write to the Free Software Foundation, |
28 | Inc., 59 Temple Place - Suite 330, | 28 | Inc., 59 Temple Place - Suite 330, |
29 | Boston, MA 02111-1307, USA. | 29 | Boston, MA 02111-1307, USA. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | 33 | ||
34 | #include <qfont.h> | 34 | #include <qfont.h> |
35 | #include <qcolor.h> | 35 | #include <qcolor.h> |
36 | 36 | ||
37 | /* OPIE */ | 37 | /* OPIE */ |
38 | 38 | ||
39 | #include <opie2/oconfig.h> | 39 | #include <opie2/oconfig.h> |
40 | 40 | ||
41 | using namespace Opie::Core; | 41 | using namespace Opie::Core; |
42 | 42 | ||
43 | OConfig::OConfig( const QString &name, Domain domain ) | 43 | OConfig::OConfig( const QString &name, Domain domain ) |
44 | :Config( name, domain ) | 44 | :Config( name, domain ) |
45 | { | 45 | { |
46 | qDebug( "OConfig::OConfig()" ); | 46 | qDebug( "OConfig::OConfig()" ); |
47 | } | 47 | } |
48 | 48 | ||
49 | OConfig::~OConfig() | 49 | OConfig::~OConfig() |
50 | { | 50 | { |
51 | qDebug( "OConfig::~OConfig()" ); | 51 | qDebug( "OConfig::~OConfig()" ); |
52 | } | 52 | } |
53 | 53 | ||
54 | QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const | 54 | QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const |
55 | { | 55 | { |
56 | QColor aRetColor; | 56 | QColor aRetColor; |
57 | int nRed = 0, nGreen = 0, nBlue = 0; | 57 | int nRed = 0, nGreen = 0, nBlue = 0; |
58 | 58 | ||
59 | QString aValue = readEntry( key ); | 59 | QString aValue = readEntry( key ); |
60 | if( !aValue.isEmpty() ) | 60 | if( !aValue.isEmpty() ) |
61 | { | 61 | { |
62 | if ( aValue.at(0) == '#' ) | 62 | if ( aValue.at(0) == '#' ) |
63 | { | 63 | { |
64 | aRetColor.setNamedColor(aValue); | 64 | aRetColor.setNamedColor(aValue); |
65 | } | 65 | } |
66 | else | 66 | else |
67 | { | 67 | { |
68 | bool bOK; | 68 | bool bOK; |
69 | 69 | ||
70 | // find first part (red) | 70 | // find first part (red) |
71 | int nIndex = aValue.find( ',' ); | 71 | int nIndex = aValue.find( ',' ); |
72 | 72 | ||
73 | if( nIndex == -1 ) | 73 | if( nIndex == -1 ) |
74 | { | 74 | { |
75 | // return a sensible default -- Bernd | 75 | // return a sensible default -- Bernd |
76 | if( pDefault ) | 76 | if( pDefault ) |
77 | aRetColor = *pDefault; | 77 | aRetColor = *pDefault; |
78 | return aRetColor; | 78 | return aRetColor; |
79 | } | 79 | } |
80 | 80 | ||
81 | nRed = aValue.left( nIndex ).toInt( &bOK ); | 81 | nRed = aValue.left( nIndex ).toInt( &bOK ); |
82 | 82 | ||
83 | // find second part (green) | 83 | // find second part (green) |
84 | int nOldIndex = nIndex; | 84 | int nOldIndex = nIndex; |
85 | nIndex = aValue.find( ',', nOldIndex+1 ); | 85 | nIndex = aValue.find( ',', nOldIndex+1 ); |
86 | 86 | ||
87 | if( nIndex == -1 ) | 87 | if( nIndex == -1 ) |
88 | { | 88 | { |
89 | // return a sensible default -- Bernd | 89 | // return a sensible default -- Bernd |
90 | if( pDefault ) | 90 | if( pDefault ) |
91 | aRetColor = *pDefault; | 91 | aRetColor = *pDefault; |
92 | return aRetColor; | 92 | return aRetColor; |
93 | } | 93 | } |
94 | nGreen = aValue.mid( nOldIndex+1, | 94 | nGreen = aValue.mid( nOldIndex+1, |
95 | nIndex-nOldIndex-1 ).toInt( &bOK ); | 95 | nIndex-nOldIndex-1 ).toInt( &bOK ); |
96 | 96 | ||
97 | // find third part (blue) | 97 | // find third part (blue) |
98 | nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK ); | 98 | nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK ); |
99 | 99 | ||
100 | aRetColor.setRgb( nRed, nGreen, nBlue ); | 100 | aRetColor.setRgb( nRed, nGreen, nBlue ); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | else { | 103 | else { |
104 | 104 | ||
105 | if( pDefault ) | 105 | if( pDefault ) |
106 | aRetColor = *pDefault; | 106 | aRetColor = *pDefault; |
107 | } | 107 | } |
108 | 108 | ||
109 | return aRetColor; | 109 | return aRetColor; |
110 | } | 110 | } |
111 | 111 | ||
112 | // FIXME: The whole font handling has to be revised for Opie | 112 | // FIXME: The whole font handling has to be revised for Opie |
113 | 113 | ||
114 | QFont OConfig::readFontEntry( const QString& key, const QFont* pDefault ) const | 114 | QFont OConfig::readFontEntry( const QString& key, const QFont* pDefault ) const |
115 | { | 115 | { |
116 | Q_CONST_UNUSED( key ) | ||
117 | Q_CONST_UNUSED( pDefault ) | ||
116 | /* | 118 | /* |
117 | QFont aRetFont; | 119 | QFont aRetFont; |
118 | 120 | ||
119 | QString aValue = readEntry( key ); | 121 | QString aValue = readEntry( key ); |
120 | if( !aValue.isNull() ) { | 122 | if( !aValue.isNull() ) { |
121 | if ( aValue.contains( ',' ) > 5 ) { | 123 | if ( aValue.contains( ',' ) > 5 ) { |
122 | // KDE3 and upwards entry | 124 | // KDE3 and upwards entry |
123 | if ( !aRetFont.fromString( aValue ) && pDefault ) | 125 | if ( !aRetFont.fromString( aValue ) && pDefault ) |
124 | aRetFont = *pDefault; | 126 | aRetFont = *pDefault; |
125 | } | 127 | } |
126 | else { | 128 | else { |
127 | // backward compatibility with older font formats | 129 | // backward compatibility with older font formats |
128 | // ### remove KDE 3.1 ? | 130 | // ### remove KDE 3.1 ? |
129 | // find first part (font family) | 131 | // find first part (font family) |
130 | int nIndex = aValue.find( ',' ); | 132 | int nIndex = aValue.find( ',' ); |
131 | if( nIndex == -1 ){ | 133 | if( nIndex == -1 ){ |
132 | if( pDefault ) | 134 | if( pDefault ) |
133 | aRetFont = *pDefault; | 135 | aRetFont = *pDefault; |
134 | return aRetFont; | 136 | return aRetFont; |
135 | } | 137 | } |
136 | aRetFont.setFamily( aValue.left( nIndex ) ); | 138 | aRetFont.setFamily( aValue.left( nIndex ) ); |
137 | 139 | ||
138 | // find second part (point size) | 140 | // find second part (point size) |
139 | int nOldIndex = nIndex; | 141 | int nOldIndex = nIndex; |
140 | nIndex = aValue.find( ',', nOldIndex+1 ); | 142 | nIndex = aValue.find( ',', nOldIndex+1 ); |
141 | if( nIndex == -1 ){ | 143 | if( nIndex == -1 ){ |
142 | if( pDefault ) | 144 | if( pDefault ) |
143 | aRetFont = *pDefault; | 145 | aRetFont = *pDefault; |
144 | return aRetFont; | 146 | return aRetFont; |
145 | } | 147 | } |
146 | 148 | ||
147 | aRetFont.setPointSize( aValue.mid( nOldIndex+1, | 149 | aRetFont.setPointSize( aValue.mid( nOldIndex+1, |
148 | nIndex-nOldIndex-1 ).toInt() ); | 150 | nIndex-nOldIndex-1 ).toInt() ); |
149 | 151 | ||
150 | // find third part (style hint) | 152 | // find third part (style hint) |
151 | nOldIndex = nIndex; | 153 | nOldIndex = nIndex; |
152 | nIndex = aValue.find( ',', nOldIndex+1 ); | 154 | nIndex = aValue.find( ',', nOldIndex+1 ); |
153 | 155 | ||
154 | if( nIndex == -1 ){ | 156 | if( nIndex == -1 ){ |
155 | if( pDefault ) | 157 | if( pDefault ) |
156 | aRetFont = *pDefault; | 158 | aRetFont = *pDefault; |
157 | return aRetFont; | 159 | return aRetFont; |
158 | } | 160 | } |
159 | 161 | ||
160 | aRetFont.setStyleHint( (QFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); | 162 | aRetFont.setStyleHint( (QFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); |
161 | 163 | ||
162 | // find fourth part (char set) | 164 | // find fourth part (char set) |
163 | nOldIndex = nIndex; | 165 | nOldIndex = nIndex; |
164 | nIndex = aValue.find( ',', nOldIndex+1 ); | 166 | nIndex = aValue.find( ',', nOldIndex+1 ); |
165 | 167 | ||
166 | if( nIndex == -1 ){ | 168 | if( nIndex == -1 ){ |
167 | if( pDefault ) | 169 | if( pDefault ) |
168 | aRetFont = *pDefault; | 170 | aRetFont = *pDefault; |
169 | return aRetFont; | 171 | return aRetFont; |
170 | } | 172 | } |
171 | 173 | ||
172 | QString chStr=aValue.mid( nOldIndex+1, | 174 | QString chStr=aValue.mid( nOldIndex+1, |
173 | nIndex-nOldIndex-1 ); | 175 | nIndex-nOldIndex-1 ); |
174 | // find fifth part (weight) | 176 | // find fifth part (weight) |
175 | nOldIndex = nIndex; | 177 | nOldIndex = nIndex; |
176 | nIndex = aValue.find( ',', nOldIndex+1 ); | 178 | nIndex = aValue.find( ',', nOldIndex+1 ); |
177 | 179 | ||
178 | if( nIndex == -1 ){ | 180 | if( nIndex == -1 ){ |
179 | if( pDefault ) | 181 | if( pDefault ) |
180 | aRetFont = *pDefault; | 182 | aRetFont = *pDefault; |
181 | return aRetFont; | 183 | return aRetFont; |
182 | } | 184 | } |
183 | 185 | ||
184 | aRetFont.setWeight( aValue.mid( nOldIndex+1, | 186 | aRetFont.setWeight( aValue.mid( nOldIndex+1, |
185 | nIndex-nOldIndex-1 ).toUInt() ); | 187 | nIndex-nOldIndex-1 ).toUInt() ); |
186 | 188 | ||
187 | // find sixth part (font bits) | 189 | // find sixth part (font bits) |
188 | uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt(); | 190 | uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt(); |
189 | 191 | ||
190 | aRetFont.setItalic( nFontBits & 0x01 ); | 192 | aRetFont.setItalic( nFontBits & 0x01 ); |
191 | aRetFont.setUnderline( nFontBits & 0x02 ); | 193 | aRetFont.setUnderline( nFontBits & 0x02 ); |
192 | aRetFont.setStrikeOut( nFontBits & 0x04 ); | 194 | aRetFont.setStrikeOut( nFontBits & 0x04 ); |
193 | aRetFont.setFixedPitch( nFontBits & 0x08 ); | 195 | aRetFont.setFixedPitch( nFontBits & 0x08 ); |
194 | aRetFont.setRawMode( nFontBits & 0x20 ); | 196 | aRetFont.setRawMode( nFontBits & 0x20 ); |
195 | } | 197 | } |
196 | } | 198 | } |
197 | else | 199 | else |
198 | { | 200 | { |
199 | if( pDefault ) | 201 | if( pDefault ) |
200 | aRetFont = *pDefault; | 202 | aRetFont = *pDefault; |
201 | } | 203 | } |
202 | return aRetFont; | 204 | return aRetFont; |
203 | */ | 205 | */ |
204 | return QFont("Helvetica",10); | 206 | return QFont("Helvetica",10); |
205 | } | 207 | } |
diff --git a/libopie2/opiecore/ofilenotify.cpp b/libopie2/opiecore/ofilenotify.cpp index b576c4f..2a9bb8c 100644 --- a/libopie2/opiecore/ofilenotify.cpp +++ b/libopie2/opiecore/ofilenotify.cpp | |||
@@ -60,261 +60,263 @@ OFileNotification::OFileNotification( QObject* parent, const char* name ) | |||
60 | 60 | ||
61 | OFileNotification::~OFileNotification() | 61 | OFileNotification::~OFileNotification() |
62 | { | 62 | { |
63 | qDebug( "OFileNotification::~OFileNotification()" ); | 63 | qDebug( "OFileNotification::~OFileNotification()" ); |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
67 | bool OFileNotification::isActive() const | 67 | bool OFileNotification::isActive() const |
68 | { | 68 | { |
69 | return _active; | 69 | return _active; |
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | int OFileNotification::start( const QString& path, bool sshot, OFileNotificationType type ) | 73 | int OFileNotification::start( const QString& path, bool sshot, OFileNotificationType type ) |
74 | { | 74 | { |
75 | _path = QString::null; | 75 | _path = QString::null; |
76 | _fd = 0; | 76 | _fd = 0; |
77 | if ( _active ) stop(); | 77 | if ( _active ) stop(); |
78 | QString dirpath; | 78 | QString dirpath; |
79 | 79 | ||
80 | // check if path exists and whether it is a file or a directory, if it exists at all | 80 | // check if path exists and whether it is a file or a directory, if it exists at all |
81 | int result = ::stat( (const char*) path, &_stat ); | 81 | int result = ::stat( (const char*) path, &_stat ); |
82 | if ( !(type & Create) && result == -1 ) | 82 | if ( !(type & Create) && result == -1 ) |
83 | { | 83 | { |
84 | qWarning( "OFileNotification::start(): Can't stat '%s': %s.", (const char*) path, strerror( errno ) ); | 84 | qWarning( "OFileNotification::start(): Can't stat '%s': %s.", (const char*) path, strerror( errno ) ); |
85 | return -1; | 85 | return -1; |
86 | } | 86 | } |
87 | 87 | ||
88 | // if it is not a directory, we need to find out in which directory the file is | 88 | // if it is not a directory, we need to find out in which directory the file is |
89 | bool isDirectory = S_ISDIR( _stat.st_mode ); | 89 | bool isDirectory = S_ISDIR( _stat.st_mode ); |
90 | if ( !isDirectory ) | 90 | if ( !isDirectory ) |
91 | { | 91 | { |
92 | int slashpos; | 92 | int slashpos; |
93 | slashpos = path.findRev( '/' ); | 93 | slashpos = path.findRev( '/' ); |
94 | if ( slashpos > 0 ) | 94 | if ( slashpos > 0 ) |
95 | { | 95 | { |
96 | _path = path; | 96 | _path = path; |
97 | dirpath = path.left( slashpos ); | 97 | dirpath = path.left( slashpos ); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | else /* isDirectory */ | 100 | else /* isDirectory */ |
101 | { | 101 | { |
102 | qWarning( "FIXME FIXME FIXME = Directory Notification Not Yet Implemented!" ); | 102 | qWarning( "FIXME FIXME FIXME = Directory Notification Not Yet Implemented!" ); |
103 | _path = path; | 103 | _path = path; |
104 | dirpath = path; | 104 | dirpath = path; |
105 | assert( 0 ); | 105 | assert( 0 ); |
106 | } | 106 | } |
107 | 107 | ||
108 | int fd = ::open( (const char*) dirpath, O_RDONLY ); | 108 | int fd = ::open( (const char*) dirpath, O_RDONLY ); |
109 | if ( fd != -1 ) | 109 | if ( fd != -1 ) |
110 | { | 110 | { |
111 | if ( notification_list.isEmpty() ) | 111 | if ( notification_list.isEmpty() ) |
112 | { | 112 | { |
113 | OFileNotification::registerSignalHandler(); | 113 | OFileNotification::registerSignalHandler(); |
114 | } | 114 | } |
115 | 115 | ||
116 | result = ::fcntl( fd, F_SETSIG, SIGRTMIN ); | 116 | result = ::fcntl( fd, F_SETSIG, SIGRTMIN ); |
117 | if ( result == -1 ) | 117 | if ( result == -1 ) |
118 | { | 118 | { |
119 | qWarning( "OFileNotification::start(): Can't subscribe to '%s': %s.", (const char*) dirpath, strerror( errno ) ); | 119 | qWarning( "OFileNotification::start(): Can't subscribe to '%s': %s.", (const char*) dirpath, strerror( errno ) ); |
120 | return -1; | 120 | return -1; |
121 | } | 121 | } |
122 | if ( !sshot ) type = static_cast<OFileNotificationType>( (int) type | (int) Multi ); | 122 | if ( !sshot ) type = static_cast<OFileNotificationType>( (int) type | (int) Multi ); |
123 | result = ::fcntl( fd, F_NOTIFY, type ); | 123 | result = ::fcntl( fd, F_NOTIFY, type ); |
124 | if ( result == -1 ) | 124 | if ( result == -1 ) |
125 | { | 125 | { |
126 | qWarning( "OFileNotification::start(): Can't subscribe to '%s': %s.", (const char*) dirpath, strerror( errno ) ); | 126 | qWarning( "OFileNotification::start(): Can't subscribe to '%s': %s.", (const char*) dirpath, strerror( errno ) ); |
127 | return -1; | 127 | return -1; |
128 | } | 128 | } |
129 | qDebug( "OFileNotification::start(): Subscribed for changes to %s (fd = %d, mask = 0x%0x)", (const char*) dirpath, fd, type ); | 129 | qDebug( "OFileNotification::start(): Subscribed for changes to %s (fd = %d, mask = 0x%0x)", (const char*) dirpath, fd, type ); |
130 | notification_list.insert( fd, this ); | 130 | notification_list.insert( fd, this ); |
131 | _type = type; | 131 | _type = type; |
132 | _fd = fd; | 132 | _fd = fd; |
133 | _active = true; | 133 | _active = true; |
134 | ::memset( &_stat, 0, sizeof _stat ); | 134 | ::memset( &_stat, 0, sizeof _stat ); |
135 | ::stat( _path, &_stat ); | 135 | ::stat( _path, &_stat ); |
136 | return fd; | 136 | return fd; |
137 | } | 137 | } |
138 | else | 138 | else |
139 | { | 139 | { |
140 | qWarning( "OFileNotification::start(): Error with path '%s': %s.", (const char*) dirpath, strerror( errno ) ); | 140 | qWarning( "OFileNotification::start(): Error with path '%s': %s.", (const char*) dirpath, strerror( errno ) ); |
141 | return -1; | 141 | return -1; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void OFileNotification::stop() | 146 | void OFileNotification::stop() |
147 | { | 147 | { |
148 | if ( !_active ) return; | 148 | if ( !_active ) return; |
149 | 149 | ||
150 | int result = ::fcntl( _fd, F_NOTIFY, 0 ); | 150 | int result = ::fcntl( _fd, F_NOTIFY, 0 ); |
151 | if ( result == -1 ) | 151 | if ( result == -1 ) |
152 | { | 152 | { |
153 | qWarning( "OFileNotification::stop(): Can't remove subscription to '%s': %s.", (const char*) _path, strerror( errno ) ); | 153 | qWarning( "OFileNotification::stop(): Can't remove subscription to '%s': %s.", (const char*) _path, strerror( errno ) ); |
154 | } | 154 | } |
155 | else | 155 | else |
156 | { | 156 | { |
157 | ::close( _fd ); | 157 | ::close( _fd ); |
158 | _type = Single; | 158 | _type = Single; |
159 | _path = QString::null; | 159 | _path = QString::null; |
160 | _fd = 0; | 160 | _fd = 0; |
161 | _active = false; | 161 | _active = false; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | OFileNotificationType OFileNotification::type() const | 166 | OFileNotificationType OFileNotification::type() const |
167 | { | 167 | { |
168 | return _type; | 168 | return _type; |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | QString OFileNotification::path() const | 172 | QString OFileNotification::path() const |
173 | { | 173 | { |
174 | return _path; | 174 | return _path; |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | int OFileNotification::fileno() const | 178 | int OFileNotification::fileno() const |
179 | { | 179 | { |
180 | return _fd; | 180 | return _fd; |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | bool OFileNotification::activate() | 184 | bool OFileNotification::activate() |
185 | { | 185 | { |
186 | if ( hasChanged() ) | 186 | if ( hasChanged() ) |
187 | { | 187 | { |
188 | emit triggered(); | 188 | emit triggered(); |
189 | _signal.activate(); | 189 | _signal.activate(); |
190 | return true; | 190 | return true; |
191 | } | 191 | } |
192 | else | 192 | else |
193 | return false; | 193 | return false; |
194 | } | 194 | } |
195 | 195 | ||
196 | 196 | ||
197 | bool OFileNotification::hasChanged() | 197 | bool OFileNotification::hasChanged() |
198 | { | 198 | { |
199 | bool c = false; | 199 | bool c = false; |
200 | 200 | ||
201 | struct stat newstat; | 201 | struct stat newstat; |
202 | ::memset( &newstat, 0, sizeof newstat ); | 202 | ::memset( &newstat, 0, sizeof newstat ); |
203 | int result = ::stat( _path, &newstat ); // may fail if file has been renamed or deleted. that doesn't matter :) | 203 | int result = ::stat( _path, &newstat ); // may fail if file has been renamed or deleted. that doesn't matter :) |
204 | 204 | ||
205 | qDebug( "result of newstat call is %d (%s=%d)", result, result == -1 ? strerror( errno ) : "success", errno ); | 205 | qDebug( "result of newstat call is %d (%s=%d)", result, result == -1 ? strerror( errno ) : "success", errno ); |
206 | qDebug( "stat.atime = %0lx, newstat.atime = %0lx", (long)_stat.st_atime, (long)newstat.st_atime ); | 206 | qDebug( "stat.atime = %0lx, newstat.atime = %0lx", (long)_stat.st_atime, (long)newstat.st_atime ); |
207 | qDebug( "stat.mtime = %0lx, newstat.mtime = %0lx", (long)_stat.st_mtime, (long)newstat.st_mtime ); | 207 | qDebug( "stat.mtime = %0lx, newstat.mtime = %0lx", (long)_stat.st_mtime, (long)newstat.st_mtime ); |
208 | qDebug( "stat.ctime = %0lx, newstat.ctime = %0lx", (long)_stat.st_ctime, (long)newstat.st_ctime ); | 208 | qDebug( "stat.ctime = %0lx, newstat.ctime = %0lx", (long)_stat.st_ctime, (long)newstat.st_ctime ); |
209 | 209 | ||
210 | if ( !c && (_type & Create) && | 210 | if ( !c && (_type & Create) && |
211 | (long)_stat.st_atime == 0 && (long)_stat.st_mtime == 0 && (long)_stat.st_ctime == 0 && | 211 | (long)_stat.st_atime == 0 && (long)_stat.st_mtime == 0 && (long)_stat.st_ctime == 0 && |
212 | (long)newstat.st_atime > 0 && (long)newstat.st_mtime > 0 && (long)newstat.st_ctime > 0) | 212 | (long)newstat.st_atime > 0 && (long)newstat.st_mtime > 0 && (long)newstat.st_ctime > 0) |
213 | { | 213 | { |
214 | qDebug( "OFileNotification::hasChanged(): file has been created" ); | 214 | qDebug( "OFileNotification::hasChanged(): file has been created" ); |
215 | c = true; | 215 | c = true; |
216 | } | 216 | } |
217 | if ( !c && (_type & (Delete|Rename)) && (long)newstat.st_atime == 0 && (long)newstat.st_mtime == 0 && (long)newstat.st_ctime == 0) | 217 | if ( !c && (_type & (Delete|Rename)) && (long)newstat.st_atime == 0 && (long)newstat.st_mtime == 0 && (long)newstat.st_ctime == 0) |
218 | { | 218 | { |
219 | qDebug( "OFileNotification::hasChanged(): file has been deleted or renamed" ); | 219 | qDebug( "OFileNotification::hasChanged(): file has been deleted or renamed" ); |
220 | c = true; | 220 | c = true; |
221 | } | 221 | } |
222 | if ( !c && (_type & Access) && (long)_stat.st_atime < (long)newstat.st_atime ) | 222 | if ( !c && (_type & Access) && (long)_stat.st_atime < (long)newstat.st_atime ) |
223 | { | 223 | { |
224 | qDebug( "OFileNotification::hasChanged(): atime changed" ); | 224 | qDebug( "OFileNotification::hasChanged(): atime changed" ); |
225 | c = true; | 225 | c = true; |
226 | } | 226 | } |
227 | if ( !c && (_type & Modify) && (long)_stat.st_mtime < (long)newstat.st_mtime ) | 227 | if ( !c && (_type & Modify) && (long)_stat.st_mtime < (long)newstat.st_mtime ) |
228 | { | 228 | { |
229 | qDebug( "OFileNotification::hasChanged(): mtime changed" ); | 229 | qDebug( "OFileNotification::hasChanged(): mtime changed" ); |
230 | c = true; | 230 | c = true; |
231 | } | 231 | } |
232 | if ( !c && (_type & Attrib) && (long)_stat.st_ctime < (long)newstat.st_ctime ) | 232 | if ( !c && (_type & Attrib) && (long)_stat.st_ctime < (long)newstat.st_ctime ) |
233 | { | 233 | { |
234 | qDebug( "OFileNotification::hasChanged(): ctime changed" ); | 234 | qDebug( "OFileNotification::hasChanged(): ctime changed" ); |
235 | c = true; | 235 | c = true; |
236 | } | 236 | } |
237 | 237 | ||
238 | return c; | 238 | return c; |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void OFileNotification::singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type ) | 242 | void OFileNotification::singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type ) |
243 | { | 243 | { |
244 | OFileNotification* ofn = new OFileNotification(); | 244 | OFileNotification* ofn = new OFileNotification(); |
245 | ofn->_signal.connect( receiver, member ); | 245 | ofn->_signal.connect( receiver, member ); |
246 | ofn->start( path, true, type ); | 246 | ofn->start( path, true, type ); |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | void OFileNotification::__signalHandler( int sig, siginfo_t *si, void *data ) | 250 | void OFileNotification::__signalHandler( int sig, siginfo_t *si, void *data ) |
251 | { | 251 | { |
252 | Q_UNUSED( sig ) | ||
253 | Q_UNUSED( data ) | ||
252 | qWarning( "OFileNotification::__signalHandler(): reached." ); | 254 | qWarning( "OFileNotification::__signalHandler(): reached." ); |
253 | int fd = si->si_fd; | 255 | int fd = si->si_fd; |
254 | OFileNotification* fn = notification_list[fd]; | 256 | OFileNotification* fn = notification_list[fd]; |
255 | if ( fn ) | 257 | if ( fn ) |
256 | { | 258 | { |
257 | // check if it really was the file (dnotify triggers on directory granularity, not file granularity) | 259 | // check if it really was the file (dnotify triggers on directory granularity, not file granularity) |
258 | if ( !fn->activate() ) | 260 | if ( !fn->activate() ) |
259 | { | 261 | { |
260 | qDebug( "OFileNotification::__signalHandler(): false alarm ;) Restarting the trigger (if it was single)..." ); | 262 | qDebug( "OFileNotification::__signalHandler(): false alarm ;) Restarting the trigger (if it was single)..." ); |
261 | if ( !(fn->type() & Multi ) ) | 263 | if ( !(fn->type() & Multi ) ) |
262 | { | 264 | { |
263 | int result = ::fcntl( fn->fileno(), F_NOTIFY, fn->type() ); | 265 | int result = ::fcntl( fn->fileno(), F_NOTIFY, fn->type() ); |
264 | if ( result == -1 ) | 266 | if ( result == -1 ) |
265 | { | 267 | { |
266 | qWarning( "OFileNotification::__signalHandler(): Can't restart the trigger: %s.", strerror( errno ) ); | 268 | qWarning( "OFileNotification::__signalHandler(): Can't restart the trigger: %s.", strerror( errno ) ); |
267 | } | 269 | } |
268 | } | 270 | } |
269 | return; | 271 | return; |
270 | } | 272 | } |
271 | #if 1 | 273 | #if 1 |
272 | if ( !(fn->type() & Multi) ) | 274 | if ( !(fn->type() & Multi) ) |
273 | { | 275 | { |
274 | qDebug( "OFileNotification::__signalHandler(): '%d' was singleShot. Removing from list.", fd ); | 276 | qDebug( "OFileNotification::__signalHandler(): '%d' was singleShot. Removing from list.", fd ); |
275 | notification_list.remove( fd ); | 277 | notification_list.remove( fd ); |
276 | if ( notification_list.isEmpty() ) | 278 | if ( notification_list.isEmpty() ) |
277 | { | 279 | { |
278 | OFileNotification::unregisterSignalHandler(); | 280 | OFileNotification::unregisterSignalHandler(); |
279 | } | 281 | } |
280 | } | 282 | } |
281 | #endif | 283 | #endif |
282 | } | 284 | } |
283 | else | 285 | else |
284 | { | 286 | { |
285 | qWarning( "OFileNotification::__signalHandler(): D'oh! Called without fd in notification_list. Race condition?" ); | 287 | qWarning( "OFileNotification::__signalHandler(): D'oh! Called without fd in notification_list. Race condition?" ); |
286 | } | 288 | } |
287 | } | 289 | } |
288 | 290 | ||
289 | 291 | ||
290 | bool OFileNotification::registerSignalHandler() | 292 | bool OFileNotification::registerSignalHandler() |
291 | { | 293 | { |
292 | struct sigaction act; | 294 | struct sigaction act; |
293 | act.sa_sigaction = OFileNotification::__signalHandler; | 295 | act.sa_sigaction = OFileNotification::__signalHandler; |
294 | ::sigemptyset( &act.sa_mask ); | 296 | ::sigemptyset( &act.sa_mask ); |
295 | act.sa_flags = SA_SIGINFO; | 297 | act.sa_flags = SA_SIGINFO; |
296 | if ( ::sigaction( SIGRTMIN, &act, NULL ) == -1 ) | 298 | if ( ::sigaction( SIGRTMIN, &act, NULL ) == -1 ) |
297 | { | 299 | { |
298 | qWarning( "OFileNotification::registerSignalHandler(): couldn't register signal handler: %s", strerror( errno ) ); | 300 | qWarning( "OFileNotification::registerSignalHandler(): couldn't register signal handler: %s", strerror( errno ) ); |
299 | return false; | 301 | return false; |
300 | } | 302 | } |
301 | qDebug( "OFileNotification::registerSignalHandler(): done" ); | 303 | qDebug( "OFileNotification::registerSignalHandler(): done" ); |
302 | return true; | 304 | return true; |
303 | } | 305 | } |
304 | 306 | ||
305 | 307 | ||
306 | void OFileNotification::unregisterSignalHandler() | 308 | void OFileNotification::unregisterSignalHandler() |
307 | { | 309 | { |
308 | struct sigaction act; | 310 | struct sigaction act; |
309 | act.sa_sigaction = ( void (*)(int, siginfo_t*, void*) ) SIG_DFL; | 311 | act.sa_sigaction = ( void (*)(int, siginfo_t*, void*) ) SIG_DFL; |
310 | ::sigemptyset( &act.sa_mask ); | 312 | ::sigemptyset( &act.sa_mask ); |
311 | if ( ::sigaction( SIGRTMIN, &act, NULL ) == -1 ) | 313 | if ( ::sigaction( SIGRTMIN, &act, NULL ) == -1 ) |
312 | { | 314 | { |
313 | qWarning( "OFileNotification::unregisterSignalHandler(): couldn't deregister signal handler: %s", strerror( errno ) ); | 315 | qWarning( "OFileNotification::unregisterSignalHandler(): couldn't deregister signal handler: %s", strerror( errno ) ); |
314 | } | 316 | } |
315 | qDebug( "OFileNotification::unregisterSignalHandler(): done" ); | 317 | qDebug( "OFileNotification::unregisterSignalHandler(): done" ); |
316 | } | 318 | } |
317 | 319 | ||
318 | 320 | ||
319 | } | 321 | } |
320 | } | 322 | } |
diff --git a/libopie2/opiecore/opluginloader.h b/libopie2/opiecore/opluginloader.h index d97f586..ee47733 100644 --- a/libopie2/opiecore/opluginloader.h +++ b/libopie2/opiecore/opluginloader.h | |||
@@ -1,205 +1,206 @@ | |||
1 | /* | 1 | /* |
2 | * LGPLv2 or later | 2 | * LGPLv2 or later |
3 | * zecke@handhelds.org | 3 | * zecke@handhelds.org |
4 | */ | 4 | */ |
5 | #ifndef ODP_CORE_OPLUGIN_LOADER_H | 5 | #ifndef ODP_CORE_OPLUGIN_LOADER_H |
6 | #define ODP_CORE_OPLUGIN_LOADER_H | 6 | #define ODP_CORE_OPLUGIN_LOADER_H |
7 | 7 | ||
8 | #include <qpe/qlibrary.h> | 8 | #include <qpe/qlibrary.h> |
9 | 9 | ||
10 | #include <qptrdict.h> | 10 | #include <qptrdict.h> |
11 | #include <qstringlist.h> | 11 | #include <qstringlist.h> |
12 | 12 | ||
13 | namespace Opie { | 13 | namespace Opie { |
14 | namespace Core { | 14 | namespace Core { |
15 | class OConfig; | 15 | class OConfig; |
16 | namespace Internal { | 16 | namespace Internal { |
17 | class OPluginLibraryHolder; | 17 | class OPluginLibraryHolder; |
18 | } | 18 | } |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * \brief A small item representing the Plugin Information | 21 | * \brief A small item representing the Plugin Information |
22 | * This class contains the information about a Plugin. It contains | 22 | * This class contains the information about a Plugin. It contains |
23 | * a translated name if available to the system, a config key, | 23 | * a translated name if available to the system, a config key, |
24 | * and the path location. | 24 | * and the path location. |
25 | * | 25 | * |
26 | * @since 1.2 | 26 | * @since 1.2 |
27 | * | 27 | * |
28 | */ | 28 | */ |
29 | class OPluginItem { | 29 | class OPluginItem { |
30 | public: | 30 | public: |
31 | typedef QValueList<OPluginItem> List; | 31 | typedef QValueList<OPluginItem> List; |
32 | OPluginItem(); | 32 | OPluginItem(); |
33 | OPluginItem( const QString& name, const QString& path, bool enabled = true, int pos = -1 ); | 33 | OPluginItem( const QString& name, const QString& path, bool enabled = true, int pos = -1 ); |
34 | ~OPluginItem(); | 34 | ~OPluginItem(); |
35 | 35 | ||
36 | bool isEmpty()const; | 36 | bool isEmpty()const; |
37 | 37 | ||
38 | bool operator==( const OPluginItem& )const; | 38 | bool operator==( const OPluginItem& )const; |
39 | bool operator!=( const OPluginItem& )const; | 39 | bool operator!=( const OPluginItem& )const; |
40 | 40 | ||
41 | 41 | ||
42 | QString name()const; | 42 | QString name()const; |
43 | QString path()const; | 43 | QString path()const; |
44 | bool isEnabled()const; | 44 | bool isEnabled()const; |
45 | int position()const; | 45 | int position()const; |
46 | 46 | ||
47 | void setName( const QString& ); | 47 | void setName( const QString& ); |
48 | void setPath( const QString& ); | 48 | void setPath( const QString& ); |
49 | void setEnabled( bool ); | 49 | void setEnabled( bool ); |
50 | void setPosition( int ); | 50 | void setPosition( int ); |
51 | 51 | ||
52 | private: | 52 | private: |
53 | QString m_name; | 53 | QString m_name; |
54 | QString m_path; | 54 | QString m_path; |
55 | bool m_enabled : 1; | 55 | bool m_enabled : 1; |
56 | int m_pos; | 56 | int m_pos; |
57 | struct Private; | 57 | struct Private; |
58 | Private *d; | 58 | Private *d; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * \brief A generic class to easily load and manage plugins | 62 | * \brief A generic class to easily load and manage plugins |
63 | * | 63 | * |
64 | * This is the generic non sepcialised loader for plugins. Normally | 64 | * This is the generic non sepcialised loader for plugins. Normally |
65 | * you would prefer using the OPluginLoader directly. This class | 65 | * you would prefer using the OPluginLoader directly. This class |
66 | * exists to minimize the application binary size due the usage | 66 | * exists to minimize the application binary size due the usage |
67 | * of templates in the specialized API | 67 | * of templates in the specialized API. |
68 | * | ||
68 | * | 69 | * |
69 | * @since 1.2 | 70 | * @since 1.2 |
70 | * @see OPluginLoader | 71 | * @see OPluginLoader |
71 | */ | 72 | */ |
72 | class OGenericPluginLoader { | 73 | class OGenericPluginLoader { |
73 | public: | 74 | public: |
74 | typedef OPluginItem::List List; | 75 | typedef OPluginItem::List List; |
75 | OGenericPluginLoader( const QString &name, bool isSorted = false ); | 76 | OGenericPluginLoader( const QString &name, bool isSorted = false ); |
76 | virtual ~OGenericPluginLoader(); | 77 | virtual ~OGenericPluginLoader(); |
77 | 78 | ||
78 | void setAutoDelete( bool ); | 79 | void setAutoDelete( bool ); |
79 | bool autoDelete()const; | 80 | bool autoDelete()const; |
80 | void clear(); | 81 | void clear(); |
81 | 82 | ||
82 | QString name()const; | 83 | QString name()const; |
83 | bool isSorted()const; | 84 | bool isSorted()const; |
84 | bool isInSafeMode()const; | 85 | bool isInSafeMode()const; |
85 | 86 | ||
86 | 87 | ||
87 | List allAvailable(bool sorted = false )const; | 88 | List allAvailable(bool sorted = false )const; |
88 | List filtered(bool sorted = false )const; | 89 | List filtered(bool sorted = false )const; |
89 | 90 | ||
90 | 91 | ||
91 | virtual QUnknownInterface* load( const OPluginItem& item, const QUuid& ); | 92 | virtual QUnknownInterface* load( const OPluginItem& item, const QUuid& ); |
92 | virtual void unload( QUnknownInterface* ); | 93 | virtual void unload( QUnknownInterface* ); |
93 | 94 | ||
94 | protected: | 95 | protected: |
95 | friend class OPluginManager; // we need the static unlibify | 96 | friend class OPluginManager; // we need the static unlibify |
96 | void readConfig(); | 97 | void readConfig(); |
97 | virtual List plugins( const QString& dir, bool sorted, bool disabled )const; | 98 | virtual List plugins( const QString& dir, bool sorted, bool disabled )const; |
98 | void setPluginDirs( const QStringList& ); | 99 | void setPluginDirs( const QStringList& ); |
99 | void setPluginDir( const QString& ); | 100 | void setPluginDir( const QString& ); |
100 | void setSafeMode(const QString& app = QString::null, bool b = false); | 101 | void setSafeMode(const QString& app = QString::null, bool b = false); |
101 | static QString unlibify( const QString& str ); | 102 | static QString unlibify( const QString& str ); |
102 | private: | 103 | private: |
103 | QStringList languageList(); | 104 | QStringList languageList(); |
104 | void installTranslators(const QString& type); | 105 | void installTranslators(const QString& type); |
105 | QString m_dir; | 106 | QString m_dir; |
106 | QStringList m_plugDirs; | 107 | QStringList m_plugDirs; |
107 | QStringList m_languages; | 108 | QStringList m_languages; |
108 | bool m_autoDelete : 1; | 109 | bool m_autoDelete : 1; |
109 | bool m_isSafeMode : 1; | 110 | bool m_isSafeMode : 1; |
110 | bool m_isSorted : 1; | 111 | bool m_isSorted : 1; |
111 | QPtrDict<QLibrary> m_library; | 112 | QPtrDict<QLibrary> m_library; |
112 | 113 | ||
113 | struct Private; | 114 | struct Private; |
114 | Private* d; | 115 | Private* d; |
115 | }; | 116 | }; |
116 | 117 | ||
117 | /** | 118 | /** |
118 | * \brief The class to load your QCOM+ plugins | 119 | * \brief The class to load your QCOM+ plugins |
119 | * | 120 | * |
120 | * This class takes care of activation and even the order | 121 | * This class takes care of activation and even the order |
121 | * if you need it. It is normally good to place a .directory file | 122 | * if you need it. It is normally good to place a .directory file |
122 | * into your plugin directory if you need order of activation. | 123 | * into your plugin directory if you need order of activation. |
123 | * | 124 | * |
124 | * You'll create the OPluginLoader and then use it to load the filtered | 125 | * You'll create the OPluginLoader and then use it to load the filtered |
125 | * plugins. | 126 | * plugins. |
126 | * | 127 | * |
127 | * There is also a GUI for the configuration and a Manager to write the | 128 | * There is also a GUI for the configuration and a Manager to write the |
128 | * mentioned .directory file | 129 | * mentioned .directory file |
129 | * | 130 | * |
130 | * On crash the safe mode is activated for the next run. You can then decide | 131 | * On crash the safe mode is activated for the next run. You can then decide |
131 | * if you want to load plugins or come up with the Configuration on | 132 | * if you want to load plugins or come up with the Configuration on |
132 | * next start yourself then. | 133 | * next start yourself then. |
133 | * | 134 | * |
134 | * @since 1.2 | 135 | * @since 1.2 |
135 | */ | 136 | */ |
136 | class OPluginLoader : public OGenericPluginLoader { | 137 | class OPluginLoader : public OGenericPluginLoader { |
137 | public: | 138 | public: |
138 | OPluginLoader( const QString& name, bool sorted = false ); | 139 | OPluginLoader( const QString& name, bool sorted = false ); |
139 | virtual ~OPluginLoader(); | 140 | virtual ~OPluginLoader(); |
140 | 141 | ||
141 | template<class IFace> | 142 | template<class IFace> |
142 | IFace* load( const OPluginItem& item, const QUuid& ); | 143 | IFace* load( const OPluginItem& item, const QUuid& ); |
143 | }; | 144 | }; |
144 | 145 | ||
145 | /** | 146 | /** |
146 | * \brief A class to manage order and activation of plugins | 147 | * \brief A class to manage order and activation of plugins |
147 | * | 148 | * |
148 | * Manage order and activation. This is used by the Opie::Ui::OPluginConfig | 149 | * Manage order and activation. This is used by the Opie::Ui::OPluginConfig |
149 | * This class controls the activation and order of plugins depending | 150 | * This class controls the activation and order of plugins depending |
150 | * on the OPluginLoader you supply. | 151 | * on the OPluginLoader you supply. |
151 | * You must call load() and save after construnction an instance | 152 | * You must call load() and save after construnction an instance |
152 | * | 153 | * |
153 | * @see Opie::Ui::OPluginConfig | 154 | * @see Opie::Ui::OPluginConfig |
154 | * | 155 | * |
155 | */ | 156 | */ |
156 | class OPluginManager { | 157 | class OPluginManager { |
157 | public: | 158 | public: |
158 | typedef QValueList<OPluginManager*> List; | 159 | typedef QValueList<OPluginManager*> List; |
159 | OPluginManager( OGenericPluginLoader* ); | 160 | OPluginManager( OGenericPluginLoader* ); |
160 | OPluginManager( const QString& name, const OPluginItem::List&, bool isSorted = false ); | 161 | OPluginManager( const QString& name, const OPluginItem::List&, bool isSorted = false ); |
161 | virtual ~OPluginManager(); | 162 | virtual ~OPluginManager(); |
162 | 163 | ||
163 | OPluginItem crashedPlugin()const; | 164 | OPluginItem crashedPlugin()const; |
164 | 165 | ||
165 | OPluginItem::List managedPlugins()const; | 166 | OPluginItem::List managedPlugins()const; |
166 | 167 | ||
167 | void setPosition( const OPluginItem& ); | 168 | void setPosition( const OPluginItem& ); |
168 | void enable( const OPluginItem& ); | 169 | void enable( const OPluginItem& ); |
169 | void disable( const OPluginItem& ); | 170 | void disable( const OPluginItem& ); |
170 | void setEnabled( const OPluginItem&, bool = true); | 171 | void setEnabled( const OPluginItem&, bool = true); |
171 | 172 | ||
172 | virtual void load(); | 173 | virtual void load(); |
173 | virtual void save(); | 174 | virtual void save(); |
174 | 175 | ||
175 | protected: | 176 | protected: |
176 | QString configName()const; | 177 | QString configName()const; |
177 | void replace( const OPluginItem& ); | 178 | void replace( const OPluginItem& ); |
178 | private: | 179 | private: |
179 | OGenericPluginLoader *m_loader; | 180 | OGenericPluginLoader *m_loader; |
180 | QString m_cfgName; | 181 | QString m_cfgName; |
181 | OPluginItem::List m_plugins; | 182 | OPluginItem::List m_plugins; |
182 | OPluginItem m_crashed; | 183 | OPluginItem m_crashed; |
183 | bool m_isSorted : 1; | 184 | bool m_isSorted : 1; |
184 | }; | 185 | }; |
185 | 186 | ||
186 | 187 | ||
187 | /** | 188 | /** |
188 | * This is a template method allowing you to safely cast | 189 | * This is a template method allowing you to safely cast |
189 | * your load function | 190 | * your load function |
190 | * | 191 | * |
191 | * \code | 192 | * \code |
192 | * MyTypePlugin *plug = load->load<MyTypePlugin>( item, IID_MyPlugin ); | 193 | * MyTypePlugin *plug = load->load<MyTypePlugin>( item, IID_MyPlugin ); |
193 | * \endcode | 194 | * \endcode |
194 | * | 195 | * |
195 | */ | 196 | */ |
196 | template<class IFace> | 197 | template<class IFace> |
197 | IFace* OPluginLoader::load( const OPluginItem& item, const QUuid& uid ) { | 198 | IFace* OPluginLoader::load( const OPluginItem& item, const QUuid& uid ) { |
198 | return static_cast<IFace*>( OGenericPluginLoader::load( item, uid ) ); | 199 | return static_cast<IFace*>( OGenericPluginLoader::load( item, uid ) ); |
199 | } | 200 | } |
200 | 201 | ||
201 | } | 202 | } |
202 | } | 203 | } |
203 | 204 | ||
204 | 205 | ||
205 | #endif | 206 | #endif |