summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2005-05-31 14:34:02 (UTC)
committer mickeyl <mickeyl>2005-05-31 14:34:02 (UTC)
commit6d2273fb22e10474ae26dd249fa2836e100ffdaf (patch) (unidiff)
tree52ff0e10b629dab847077a8b3afcd3f8c0d1b830 /libopie2
parent930f91069c505082a33e43ce5fdca019531a4b5e (diff)
downloadopie-6d2273fb22e10474ae26dd249fa2836e100ffdaf.zip
opie-6d2273fb22e10474ae26dd249fa2836e100ffdaf.tar.gz
opie-6d2273fb22e10474ae26dd249fa2836e100ffdaf.tar.bz2
misc. opcmciasystem improvements
start implementing recursve dirlocks in ODirNotification
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/linux/ofilenotify.cpp59
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.cpp125
-rw-r--r--libopie2/opiecore/linux/opcmciasystem.h39
3 files changed, 141 insertions, 82 deletions
diff --git a/libopie2/opiecore/linux/ofilenotify.cpp b/libopie2/opiecore/linux/ofilenotify.cpp
index 36ec6bf..3096f7e 100644
--- a/libopie2/opiecore/linux/ofilenotify.cpp
+++ b/libopie2/opiecore/linux/ofilenotify.cpp
@@ -347,34 +347,45 @@ int ODirNotification::watch( const QString& path, bool sshot, OFileNotificationT
347{ 347{
348 qDebug( "ODirNotification::watch( %s, %d, 0x%08x, %d )", (const char*) path, sshot, type, recurse ); 348 qDebug( "ODirNotification::watch( %s, %d, 0x%08x, %d )", (const char*) path, sshot, type, recurse );
349 349
350 if ( recurse == 0 ) 350 OFileNotification* fn = new OFileNotification( this, "ODirNotification delegate" );
351 int result = fn->startWatching( path, sshot, type );
352 if ( result != -1 )
351 { 353 {
352 OFileNotification* fn = new OFileNotification( this, "ODirNotification delegate" ); 354 connect( fn, SIGNAL( triggered( const QString&, unsigned int, const QString& ) ), this, SIGNAL( triggered( const QString&, unsigned int, const QString& ) ) );
353 int result = fn->startWatching( path, sshot, type ); 355 connect( fn, SIGNAL( accessed( const QString& ) ), this, SIGNAL( accessed( const QString& ) ) );
354 if ( result != -1 ) 356 connect( fn, SIGNAL( modified( const QString& ) ), this, SIGNAL( modified( const QString& ) ) );
357 connect( fn, SIGNAL( attributed( const QString& ) ), this, SIGNAL( attributed( const QString& ) ) );
358 connect( fn, SIGNAL( closed( const QString&, bool ) ), this, SIGNAL( closed( const QString&, bool ) ) );
359 connect( fn, SIGNAL( opened( const QString& ) ), this, SIGNAL( opened( const QString& ) ) );
360 connect( fn, SIGNAL( movedTo( const QString&, const QString& ) ), this, SIGNAL( movedTo( const QString&, const QString& ) ) );
361 connect( fn, SIGNAL( movedFrom( const QString&, const QString& ) ), this, SIGNAL( movedFrom( const QString&, const QString& ) ) );
362 connect( fn, SIGNAL( deletedSubdir( const QString&, const QString& ) ), this, SIGNAL( deletedSubdir( const QString&, const QString& ) ) );
363 connect( fn, SIGNAL( deletedFile( const QString&, const QString& ) ), this, SIGNAL( deletedFile( const QString&, const QString& ) ) );;
364 connect( fn, SIGNAL( createdSubdir( const QString&, const QString& ) ), this, SIGNAL( createdSubdir( const QString&, const QString& ) ) );
365 connect( fn, SIGNAL( createdFile( const QString&, const QString& ) ), this, SIGNAL( createdFile( const QString&, const QString& ) ) );
366 connect( fn, SIGNAL( deleted( const QString& ) ), this, SIGNAL( deleted( const QString& ) ) );
367 connect( fn, SIGNAL( unmounted( const QString& ) ), this, SIGNAL( unmounted( const QString& ) ) );
368
369 if ( recurse )
355 { 370 {
356 connect( fn, SIGNAL( triggered( const QString&, unsigned int, const QString& ) ), this, SIGNAL( triggered( const QString&, unsigned int, const QString& ) ) ); 371 QDir directory( path );
357 connect( fn, SIGNAL( accessed( const QString& ) ), this, SIGNAL( accessed( const QString& ) ) ); 372 QStringList subdirs = directory.entryList( QDir::Dirs );
358 connect( fn, SIGNAL( modified( const QString& ) ), this, SIGNAL( modified( const QString& ) ) ); 373
359 connect( fn, SIGNAL( attributed( const QString& ) ), this, SIGNAL( attributed( const QString& ) ) ); 374 for ( QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it )
360 connect( fn, SIGNAL( closed( const QString&, bool ) ), this, SIGNAL( closed( const QString&, bool ) ) ); 375 {
361 connect( fn, SIGNAL( opened( const QString& ) ), this, SIGNAL( opened( const QString& ) ) ); 376 if ( (*it) == "." || (*it) == ".." ) continue;
362 connect( fn, SIGNAL( movedTo( const QString&, const QString& ) ), this, SIGNAL( movedTo( const QString&, const QString& ) ) ); 377 QString subpath = QString( "%1/%2" ).arg( path ).arg( *it );
363 connect( fn, SIGNAL( movedFrom( const QString&, const QString& ) ), this, SIGNAL( movedFrom( const QString&, const QString& ) ) ); 378 int subresult = watch( subpath, sshot, type, recurse-1 );
364 connect( fn, SIGNAL( deletedSubdir( const QString&, const QString& ) ), this, SIGNAL( deletedSubdir( const QString&, const QString& ) ) ); 379 if ( subresult == -1 )
365 connect( fn, SIGNAL( deletedFile( const QString&, const QString& ) ), this, SIGNAL( deletedFile( const QString&, const QString& ) ) );; 380 {
366 connect( fn, SIGNAL( createdSubdir( const QString&, const QString& ) ), this, SIGNAL( createdSubdir( const QString&, const QString& ) ) ); 381 qDebug( "ODirNotification::watch(): subresult for '%s' was -1. Interrupting", (const char*) (*it) );
367 connect( fn, SIGNAL( createdFile( const QString&, const QString& ) ), this, SIGNAL( createdFile( const QString&, const QString& ) ) ); 382 return -1;
368 connect( fn, SIGNAL( deleted( const QString& ) ), this, SIGNAL( deleted( const QString& ) ) ); 383 }
369 connect( fn, SIGNAL( unmounted( const QString& ) ), this, SIGNAL( unmounted( const QString& ) ) ); 384 }
370 } 385 }
371 return result; 386//connect( fn, SIGNAL( triggered( const QString&, unsigned int, const QString& ) ), this, SIGNAL( triggered( const QString&, unsigned int, const QString& ) ) );
372 }
373 else
374 {
375
376 return 1;
377 } 387 }
388 else return -1;
378} 389}
379 390
380 391
diff --git a/libopie2/opiecore/linux/opcmciasystem.cpp b/libopie2/opiecore/linux/opcmciasystem.cpp
index 0f7ff46..929e289 100644
--- a/libopie2/opiecore/linux/opcmciasystem.cpp
+++ b/libopie2/opiecore/linux/opcmciasystem.cpp
@@ -172,9 +172,7 @@ OPcmciaSocket::OPcmciaSocket( int major, int socket, QObject* parent, const char
172 :QObject( parent, name ), _major( major ), _socket( socket ) 172 :QObject( parent, name ), _major( major ), _socket( socket )
173{ 173{
174 qDebug( "OPcmciaSocket::OPcmciaSocket()" ); 174 qDebug( "OPcmciaSocket::OPcmciaSocket()" );
175
176 init(); 175 init();
177 buildInformation();
178} 176}
179 177
180 178
@@ -211,41 +209,12 @@ OPcmciaSocket::~OPcmciaSocket()
211 } 209 }
212} 210}
213 211
214/* internal */ void OPcmciaSocket::buildInformation()
215{
216 cistpl_vers_1_t *vers = &_ioctlarg.tuple_parse.parse.version_1;
217 cistpl_manfid_t *manfid = &_ioctlarg.tuple_parse.parse.manfid;
218 cistpl_funcid_t *funcid = &_ioctlarg.tuple_parse.parse.funcid;
219 config_info_t config;
220
221 if ( getTuple( CISTPL_VERS_1 ) )
222 {
223 for ( int i = 0; i < CISTPL_VERS_1_MAX_PROD_STRINGS; ++i )
224 {
225 qDebug( " PRODID = '%s'", vers->str+vers->ofs[i] );
226 _productId += vers->str+vers->ofs[i];
227 }
228 }
229 /*
230 for (i = 0; i < 4; i++)
231 printf("PRODID_%d=\"%s\"\n", i+1,
232 (i < vers->ns) ? vers->str+vers->ofs[i] : "");
233 *manfid = (cistpl_manfid_t) { 0, 0 };
234 get_tuple(fd, CISTPL_MANFID, &arg);
235 printf("MANFID=%04x,%04x\n", manfid->manf, manfid->card);
236 *funcid = (cistpl_funcid_t) { 0xff, 0xff };
237 get_tuple(fd, CISTPL_FUNCID, &arg);
238 printf("FUNCID=%d\n", funcid->func);
239 config.Function = config.ConfigBase = 0;
240 */
241}
242
243/* internal */ void OPcmciaSocket::cleanup() 212/* internal */ void OPcmciaSocket::cleanup()
244{ 213{
245 // close control socket 214 // close control socket
246} 215}
247 216
248/* internal */ bool OPcmciaSocket::getTuple( cisdata_t tuple ) 217/* internal */ bool OPcmciaSocket::getTuple( cisdata_t tuple ) const
249{ 218{
250 _ioctlarg.tuple.DesiredTuple = tuple; 219 _ioctlarg.tuple.DesiredTuple = tuple;
251 _ioctlarg.tuple.Attributes = TUPLE_RETURN_COMMON; 220 _ioctlarg.tuple.Attributes = TUPLE_RETURN_COMMON;
@@ -266,7 +235,7 @@ OPcmciaSocket::~OPcmciaSocket()
266 return false; 235 return false;
267 } 236 }
268 237
269 result = ::ioctl(_fd, DS_PARSE_TUPLE, &_ioctlarg); 238 result = ::ioctl( _fd, DS_PARSE_TUPLE, &_ioctlarg );
270 if ( result != 0 ) 239 if ( result != 0 )
271 { 240 {
272 qWarning( "OPcmciaSocket::getTuple() - DS_PARSE_TUPLE failed (%s)", strerror( errno ) ); 241 qWarning( "OPcmciaSocket::getTuple() - DS_PARSE_TUPLE failed (%s)", strerror( errno ) );
@@ -277,12 +246,6 @@ OPcmciaSocket::~OPcmciaSocket()
277} 246}
278 247
279 248
280/* internal */ bool OPcmciaSocket::command( const QString& cmd )
281{
282 QString cmdline = QString().sprintf( "cardctl %s %d &", (const char*) cmd, _socket );
283 ::system( (const char*) cmdline );
284}
285
286int OPcmciaSocket::number() const 249int OPcmciaSocket::number() const
287{ 250{
288 return _socket; 251 return _socket;
@@ -295,6 +258,25 @@ QString OPcmciaSocket::identity() const
295} 258}
296 259
297 260
261const OPcmciaSocket::OPcmciaSocketCardStatus OPcmciaSocket::status() const
262{
263 cs_status_t cs_status;
264 cs_status.Function = 0;
265 int result = ::ioctl( _fd, DS_GET_STATUS, &cs_status );
266 if ( result != 0 )
267 {
268 qWarning( "OPcmciaSocket::status() - DS_GET_STATUS failed (%s)", strerror( errno ) );
269 return Unknown;
270 }
271 else
272 {
273 qDebug( " card status = 0x%08x", cs_status.CardState );
274 qDebug( " socket status = 0x%08x", cs_status.SocketState );
275 return (OPcmciaSocket::OPcmciaSocketCardStatus) (cs_status.CardState + cs_status.SocketState);
276 }
277}
278
279
298bool OPcmciaSocket::isUnsupported() const 280bool OPcmciaSocket::isUnsupported() const
299{ 281{
300 return ( strcmp( name(), "unsupported card" ) == 0 ); 282 return ( strcmp( name(), "unsupported card" ) == 0 );
@@ -303,46 +285,66 @@ bool OPcmciaSocket::isUnsupported() const
303 285
304bool OPcmciaSocket::isEmpty() const 286bool OPcmciaSocket::isEmpty() const
305{ 287{
306 return ( strcmp( name(), "empty" ) == 0 ); 288 return ! status() && ( Occupied || OccupiedCardBus );
307} 289}
308 290
309 291
310bool OPcmciaSocket::isSuspended() const 292bool OPcmciaSocket::isSuspended() const
311{ 293{
312 //FIXME 294 return status() && Suspended;
313 return false;
314} 295}
315 296
297
316bool OPcmciaSocket::eject() 298bool OPcmciaSocket::eject()
317{ 299{
318 return command( "eject" ); 300 return ::ioctl( _fd, DS_EJECT_CARD );
319} 301}
320 302
303
321bool OPcmciaSocket::insert() 304bool OPcmciaSocket::insert()
322{ 305{
323 return command( "insert" ); 306 return ::ioctl( _fd, DS_INSERT_CARD );
324} 307}
325 308
309
326bool OPcmciaSocket::suspend() 310bool OPcmciaSocket::suspend()
327{ 311{
328 return command( "suspend" ); 312 return ::ioctl( _fd, DS_SUSPEND_CARD );
329} 313}
330 314
315
331bool OPcmciaSocket::resume() 316bool OPcmciaSocket::resume()
332{ 317{
333 return command( "resume"); 318 return ::ioctl( _fd, DS_RESUME_CARD );
334} 319}
335 320
321
336bool OPcmciaSocket::reset() 322bool OPcmciaSocket::reset()
337{ 323{
338 return command( "reset"); 324 return ::ioctl( _fd, DS_RESET_CARD );
339} 325}
340 326
341const QStringList& OPcmciaSocket::productIdentity() const 327
328QStringList OPcmciaSocket::productIdentity() const
342{ 329{
343 return _productId; 330 QStringList list;
331 cistpl_vers_1_t *vers = &_ioctlarg.tuple_parse.parse.version_1;
332 if ( getTuple( CISTPL_VERS_1 ) )
333 {
334 for ( int i = 0; i < CISTPL_VERS_1_MAX_PROD_STRINGS; ++i )
335 {
336 qDebug( " PRODID = '%s'", vers->str+vers->ofs[i] );
337 list += vers->str+vers->ofs[i];
338 }
339 }
340 else
341 {
342 list += "<unknown>";
343 }
344 return list;
344} 345}
345 346
347
346#if 0 348#if 0
347const QPair& OPcmciaSocket::manufacturerIdentity() const 349const QPair& OPcmciaSocket::manufacturerIdentity() const
348{ 350{
@@ -350,3 +352,28 @@ const QPair& OPcmciaSocket::manufacturerIdentity() const
350} 352}
351#endif 353#endif
352 354
355
356QString OPcmciaSocket::function() const
357{
358 cistpl_funcid_t *funcid = &_ioctlarg.tuple_parse.parse.funcid;
359 if ( getTuple( CISTPL_FUNCID ) )
360 {
361 switch ( funcid->func )
362 {
363 case 0: return "Multifunction"; break;
364 case 1: return "Memory"; break;
365 case 2: return "Serial"; break;
366 case 3: return "Parallel"; break;
367 case 4: return "Fixed Disk"; break;
368 case 5: return "Video"; break;
369 case 6: return "Network"; break;
370 case 7: return "AIMS"; break;
371 case 8: return "SCSI"; break;
372 default: return "<unknown>"; break;
373 }
374 }
375 else
376 {
377 return "<unknown>";
378 }
379}
diff --git a/libopie2/opiecore/linux/opcmciasystem.h b/libopie2/opiecore/linux/opcmciasystem.h
index ef34964..ac6c1de 100644
--- a/libopie2/opiecore/linux/opcmciasystem.h
+++ b/libopie2/opiecore/linux/opcmciasystem.h
@@ -109,6 +109,24 @@ class OPcmciaSystem : public QObject
109class OPcmciaSocket : public QObject 109class OPcmciaSocket : public QObject
110{ 110{
111 Q_OBJECT 111 Q_OBJECT
112 public:
113
114 enum OPcmciaSocketCardStatus
115 {
116 Unknown = 0,
117 Occupied = CS_EVENT_CARD_DETECT,
118 OccupiedCardBus = CS_EVENT_CB_DETECT,
119 WriteProtected = CS_EVENT_WRITE_PROTECT,
120 BatteryLow = CS_EVENT_BATTERY_LOW,
121 BatteryDead = CS_EVENT_BATTERY_DEAD,
122 Ready = CS_EVENT_READY_CHANGE,
123 Suspended = CS_EVENT_PM_SUSPEND,
124 Attention = CS_EVENT_REQUEST_ATTENTION,
125 InsertionInProgress = CS_EVENT_CARD_INSERTION,
126 RemovalInProgress = CS_EVENT_CARD_REMOVAL,
127 ThreeVolts = CS_EVENT_3VCARD,
128 SupportsVoltage = CS_EVENT_XVCARD,
129 };
112 130
113 public: 131 public:
114 /** 132 /**
@@ -125,10 +143,14 @@ class OPcmciaSocket : public QObject
125 */ 143 */
126 int number() const; 144 int number() const;
127 /** 145 /**
128 * @returns the identification string of the card in this socket, or "<Empty Socket>" 146 * @returns the card managers idea of the cards' identy, or "<Empty Socket>"
129 */ 147 */
130 QString identity() const; 148 QString identity() const;
131 /** 149 /**
150 * @returns the socket status
151 */
152 const OPcmciaSocketCardStatus status() const;
153 /**
132 * @returns true, if the card is unsupported by the cardmgr 154 * @returns true, if the card is unsupported by the cardmgr
133 */ 155 */
134 bool isUnsupported() const; 156 bool isUnsupported() const;
@@ -168,27 +190,26 @@ class OPcmciaSocket : public QObject
168 /** 190 /**
169 * @returns a list of product IDs 191 * @returns a list of product IDs
170 */ 192 */
171 const QStringList& productIdentity() const; 193 QStringList productIdentity() const;
172 /** 194 /**
173 * @returns the manufacturer ID pair 195 * @returns the manufacturer ID pair
174 */ 196 */
175#if 0 197#if 0
176 const QPair& manufacturerIdentity() const; 198 const QPair& manufacturerIdentity() const;
177#endif 199#endif
178 200 /**
179 private: 201 * @returns the function string
180 QStringList _productId; 202 */
203 QString function() const;
181 204
182 private: 205 private:
183 void init(); 206 void init();
184 void buildInformation();
185 void cleanup(); 207 void cleanup();
186 bool command( const QString& cmd ); 208 bool getTuple( cisdata_t tuple ) const;
187 bool getTuple( cisdata_t tuple );
188 int _major; 209 int _major;
189 int _socket; 210 int _socket;
190 int _fd; 211 int _fd;
191 ds_ioctl_arg_t _ioctlarg; 212 mutable ds_ioctl_arg_t _ioctlarg;
192 213
193 private: 214 private:
194 class Private; 215 class Private;