-rw-r--r-- | libopie2/opiecore/linux/ofilenotify.cpp | 59 | ||||
-rw-r--r-- | libopie2/opiecore/linux/opcmciasystem.cpp | 125 | ||||
-rw-r--r-- | libopie2/opiecore/linux/opcmciasystem.h | 39 |
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 | |||
@@ -348,32 +348,43 @@ int ODirNotification::watch( const QString& path, bool sshot, OFileNotificationT | |||
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 | ||
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 | |||
@@ -173,7 +173,5 @@ OPcmciaSocket::OPcmciaSocket( int major, int socket, QObject* parent, const char | |||
173 | { | 173 | { |
174 | qDebug( "OPcmciaSocket::OPcmciaSocket()" ); | 174 | qDebug( "OPcmciaSocket::OPcmciaSocket()" ); |
175 | |||
176 | init(); | 175 | init(); |
177 | buildInformation(); | ||
178 | } | 176 | } |
179 | 177 | ||
@@ -212,33 +210,4 @@ OPcmciaSocket::~OPcmciaSocket() | |||
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 | { |
@@ -246,5 +215,5 @@ OPcmciaSocket::~OPcmciaSocket() | |||
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; |
@@ -267,5 +236,5 @@ OPcmciaSocket::~OPcmciaSocket() | |||
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 | { |
@@ -278,10 +247,4 @@ OPcmciaSocket::~OPcmciaSocket() | |||
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 | |||
286 | int OPcmciaSocket::number() const | 249 | int OPcmciaSocket::number() const |
287 | { | 250 | { |
@@ -296,4 +259,23 @@ QString OPcmciaSocket::identity() const | |||
296 | 259 | ||
297 | 260 | ||
261 | const 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 | |||
298 | bool OPcmciaSocket::isUnsupported() const | 280 | bool OPcmciaSocket::isUnsupported() const |
299 | { | 281 | { |
@@ -304,5 +286,5 @@ bool OPcmciaSocket::isUnsupported() const | |||
304 | bool OPcmciaSocket::isEmpty() const | 286 | bool OPcmciaSocket::isEmpty() const |
305 | { | 287 | { |
306 | return ( strcmp( name(), "empty" ) == 0 ); | 288 | return ! status() && ( Occupied || OccupiedCardBus ); |
307 | } | 289 | } |
308 | 290 | ||
@@ -310,38 +292,58 @@ bool OPcmciaSocket::isEmpty() const | |||
310 | bool OPcmciaSocket::isSuspended() const | 292 | bool OPcmciaSocket::isSuspended() const |
311 | { | 293 | { |
312 | //FIXME | 294 | return status() && Suspended; |
313 | return false; | ||
314 | } | 295 | } |
315 | 296 | ||
297 | |||
316 | bool OPcmciaSocket::eject() | 298 | bool OPcmciaSocket::eject() |
317 | { | 299 | { |
318 | return command( "eject" ); | 300 | return ::ioctl( _fd, DS_EJECT_CARD ); |
319 | } | 301 | } |
320 | 302 | ||
303 | |||
321 | bool OPcmciaSocket::insert() | 304 | bool OPcmciaSocket::insert() |
322 | { | 305 | { |
323 | return command( "insert" ); | 306 | return ::ioctl( _fd, DS_INSERT_CARD ); |
324 | } | 307 | } |
325 | 308 | ||
309 | |||
326 | bool OPcmciaSocket::suspend() | 310 | bool OPcmciaSocket::suspend() |
327 | { | 311 | { |
328 | return command( "suspend" ); | 312 | return ::ioctl( _fd, DS_SUSPEND_CARD ); |
329 | } | 313 | } |
330 | 314 | ||
315 | |||
331 | bool OPcmciaSocket::resume() | 316 | bool OPcmciaSocket::resume() |
332 | { | 317 | { |
333 | return command( "resume"); | 318 | return ::ioctl( _fd, DS_RESUME_CARD ); |
334 | } | 319 | } |
335 | 320 | ||
321 | |||
336 | bool OPcmciaSocket::reset() | 322 | bool OPcmciaSocket::reset() |
337 | { | 323 | { |
338 | return command( "reset"); | 324 | return ::ioctl( _fd, DS_RESET_CARD ); |
339 | } | 325 | } |
340 | 326 | ||
341 | const QStringList& OPcmciaSocket::productIdentity() const | 327 | |
328 | QStringList 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 |
347 | const QPair& OPcmciaSocket::manufacturerIdentity() const | 349 | const QPair& OPcmciaSocket::manufacturerIdentity() const |
@@ -351,2 +353,27 @@ const QPair& OPcmciaSocket::manufacturerIdentity() const | |||
351 | #endif | 353 | #endif |
352 | 354 | ||
355 | |||
356 | QString 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 | |||
@@ -110,4 +110,22 @@ class 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: |
@@ -126,8 +144,12 @@ class OPcmciaSocket : public QObject | |||
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 | */ |
@@ -169,5 +191,5 @@ class OPcmciaSocket : public QObject | |||
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 |
@@ -176,18 +198,17 @@ class OPcmciaSocket : public QObject | |||
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: |