crabs_usbmgr-1.0.3 ©2004-2006 - Christophe CAZAJUS (crabs-mettre_le_signe_at-crabs-world.com)
1 /* 2 **============================================================================= 3 ** crabs_usbmgr-1.0.3 : Universal Serial Bus MaNaGer 4 ** Copyright (C) 2004-2006 : Christophe CAZAJUS (crabs-mettre_le_signe_at-crabs-world.com) 5 ** 6 ** Ce source fait partie d'un projet logiciel libre. Vous pouvez le distribuer 7 ** et/ou le modifier en respectant les termes de la GNU General Public License 8 ** version 2 ou (suite a votre propre choix) une version ulterieure. 9 ** 10 ** Ce programme est distribue dans l'espoir qu'il puisse etre utile, mais 11 ** sans aucune garantie, meme si il est associe a un produit qui vous en 12 ** propose une. Conformez-vous a la GNU General Public License pour avoir 13 ** plus de precisions. 14 ** 15 ** L'auteur ne peut etre tenu responsable de l'utilisation faite des 16 ** composantes associees a ce projet (en partie ou dans leur totalite). 17 ** 18 ** Une copie du fichier de la GNU GPL est fournie dans le repertoire DOC 19 ** de ce projet sous le nom gnu_gpl.txt 20 ** 21 **============================================================================= 22 */ 23 #include "qusbmgr.QH" 24 #include <qapplication.h> 25 #include <qlistbox.h> 26 #include <qpushbutton.h> 27 #include <qlayout.h> 28 #include <qstring.h> 29 #include <qtimer.h> 30 #include <qcursor.h> 31 32 #include <sys/types.h> 33 #include <errno.h> 34 #include <stdio.h> 35 #include <unistd.h> 36 37 #include <syssock.h> 38 #include <usbstruct.h> 39 40 void QUsbMgr::loadListe() 41 { 42 char err [1024] ; 43 USBSTRUCT_ACTION a ; 44 USBSTRUCT_STATUS st ; 45 int sock ; 46 QString l ; 47 48 QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ) ; 49 qt_timer->stop() ; 50 qlb_liste->clear() ; 51 sock = serv_connect( svr, TCP_SERV, err ) ; 52 if ( sock == -1 ) 53 { qDebug( "%s\n", err ) ; goto fin ; } 54 55 a.cmd = LISTE ; 56 if ( sock_write( sock, &a, sizeof(USBSTRUCT_ACTION) ) == -1 ) 57 { 58 qDebug( "sock_write():%s", strerror( errno ) ) ; 59 ::close( sock ) ; goto fin ; 60 } 61 while ( 1 ) 62 { 63 if ( sock_read( sock, &a, sizeof(USBSTRUCT_ACTION) ) == -1 ) 64 { 65 qDebug( "sock_write():%s", strerror( errno ) ) ; 66 ::close( sock ) ; goto fin ; 67 } 68 if ( a.cmd == FIN ) break ; 69 l.sprintf( "%s (%s)", a.mnt, a.name ) ; 70 qlb_liste->insertItem( l ) ; 71 } 72 if ( sock_read( sock, &st, sizeof(USBSTRUCT_STATUS) ) == -1 ) 73 { 74 qDebug( "sock_read():%s", strerror( errno ) ) ; 75 ::close( sock ) ; goto fin ; 76 } 77 ::close( sock ) ; 78 fin: 79 QApplication::restoreOverrideCursor() ; 80 qlb_liste->setCurrentItem( 0 ) ; 81 qt_timer->start( 15000 ) ; 82 } 83
Date de génération : 22/09/2011 21:48