summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oconfig.cpp2
-rw-r--r--libopie2/opiecore/ofilenotify.cpp2
-rw-r--r--libopie2/opiecore/opluginloader.h3
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
@@ -68,96 +68,98 @@ QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) con
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
114QFont OConfig::readFontEntry( const QString& key, const QFont* pDefault ) const 114QFont 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;
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
@@ -204,96 +204,98 @@ bool OFileNotification::hasChanged()
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
242void OFileNotification::singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type ) 242void 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
250void OFileNotification::__signalHandler( int sig, siginfo_t *si, void *data ) 250void 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
290bool OFileNotification::registerSignalHandler() 292bool 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;
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
@@ -19,97 +19,98 @@ class OPluginLibraryHolder;
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 */
29class OPluginItem { 29class OPluginItem {
30public: 30public:
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
52private: 52private:
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 */
72class OGenericPluginLoader { 73class OGenericPluginLoader {
73public: 74public:
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
94protected: 95protected:
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 );
102private: 103private:
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};