void fileTransferThread::parseFileList( const QByteArray &fl ) { parsedSize=0; filesParsed=0; fc=0; allSize=0; currentFile=0; QTreeWidgetItem *item; QStringList finfo; QString path = settings->profileValue( QString("filetransfer/%1").arg(rndid) ).toString(), fname; memcpy(&fc, fl.leftRef(4).constData(), 4); for(quint32 i=0; i<fc; ++i) { memcpy(&fs, fl.mid(4+i*260, 4).data(), 4); fname=fl.mid(4+i*260+4, 256); finfo<<fname<<""<<""<<""<<""<<QString("%L1 kB").arg( (float)qRound( ( (float)fs/1024 )*10 )/10 )<<path<<QString("%1").arg(fs); item = new QTreeWidgetItem(finfo); item->setIcon(0, QIcon(":offline")); // item->setCheckState(0,Qt::Checked); fileMap<<item; emit addListItem(item); allSize+=fs; finfo.clear(); } settings->removeProfileValue( QString("filetransfer/%1").arg(rndid) ); char packet[8]; quint32 tmp=FileListAck; memcpy(&packet, &tmp,4); tmp=0; memcpy(&packet[4], &tmp,4); socket->write(packet,sizeof(packet)); emit updateFilesData(fc, allSize); requestFile(); }
void fileTransferThread::sendFile( const QByteArray &f ) { cfTime = 0; cfParsed=0; if(!t->isActive()) t->start(1000); memcpy(¤tFile, f.leftRef(4).constData(), 4); QTreeWidgetItem *it = fileMap.at(currentFile); current->setFileName( it->text(6)+"/"+it->text(0) ); current->open(QIODevice::ReadOnly); do { sendFileChunk( current->read(1024) ); } while( !current->atEnd() ); socket->flush(); sendFileClose(); }