Logo Search packages:      
Sourcecode: ultracopier version File versions  Download package

void UIcon::dataincommingUI (  ) [private, slot]

Data is incomming.

Todo:
keep copy id for send reply when copy is finished
Todo:
do multiple client management

Definition at line 858 of file UIcon.cpp.

References listDataClient, parseTheCleanedTrame(), and TimeOutQLocalSocket.

Referenced by newConnexionUI().

{
      DEBUGCONSOLE(90,"UIcon::dataincomming","start");
      // 1 : we get packets from client
      
      //Which client send the message (Search of the QLocalSocket of client)
      QLocalSocket *socket = qobject_cast<QLocalSocket *>(sender());
      if (socket == 0) // If not found
      {
            DEBUGCONSOLE(10,"UIcon::dataincomming","bad socket");
            return;
      }
      
      QStringList argumentsUltracopier;
      composedData tempComposed;
      tempComposed.idSocket=NULL;
      int index=-1;
      for (int i=0;i<listDataClient.size(); ++i) {
            if(listDataClient.at(i).idSocket==socket)
                  index=i;
      }
      DEBUGCONSOLE(90,"UIcon::dataincomming","socket->bytesAvailable() "+QString::number(socket->bytesAvailable()));
      if(index!=-1)
      {
            listDataClient[index].data.append(socket->readAll());
            DEBUGCONSOLE(90,"UIcon::dataincomming","Query recomposed with this size: "+QString::number(listDataClient.at(index).data.size()));
            if(listDataClient.at(index).data.size()==listDataClient.at(index).size)
            {
                  DEBUGCONSOLE(50,"UIcon::dataincomming","QByteArray reconstruction finished");
                  parseTheCleanedTrame(listDataClient.at(index).data,socket,listDataClient.at(index).copyId);
                  listDataClient.removeAt(index);
                  if(listDataClient.size()<=0)
                        TimeOutQLocalSocket.stop();
            }
            else
            {
                  TimeOutQLocalSocket.start();
                  DEBUGCONSOLE(90,"UIcon::dataincomming","Need wait to recomposite: "+QString::number(listDataClient.at(index).data.size())+", targeted: "+QString::number(listDataClient.at(index).size));
                  return;
            }
      }
      else
      {
            DEBUGCONSOLE(90,"UIcon::dataincomming","tempComposed index not found, create new entry");
            // If all is ok we get the message
            QDataStream in(socket);
            in.setVersion(QDataStream::Qt_4_4);

            quint32 sizeMessage=0;
            if (socket->bytesAvailable() < (int)sizeof(quint32)*3) // We have not receveive all the message
            {
                  socket->readAll();
                  DEBUGCONSOLE(10,"UIcon::dataincomming","wrong size for set the message size");
                  return;
            }
            in >> sizeMessage; // Store the size of the message
            quint32 sizeToDrop=sizeof(quint32)*2;//drop the first sizeof(quint32)*2 from data, for drop size && id
            if(sizeMessage<sizeToDrop)
            {
                  socket->readAll();
                  DEBUGCONSOLE(90,"UIcon::dataincomming","sizeMessage: "+QString::number(sizeMessage)+", because it's requiered: after the recomposition: (quint32) query id, (quint32) protocole version");
                  QMessageBox::warning(NULL,"Warning","The minimal size is not present at the first checking");
                  return;
            }

            /// \todo keep copy id for send reply when copy is finished
            /// \todo do multiple client management


            // Check if all the message size is the same as the size given
            if((socket->bytesAvailable()+sizeof(quint32)) < sizeMessage) // If not all get then stop it
            {
                  tempComposed.idSocket=socket;
                  tempComposed.size=sizeMessage-sizeToDrop;
                  in >> tempComposed.copyId;//store the copy id
                  tempComposed.data.append(socket->readAll());
                  listDataClient.append(tempComposed);
                  TimeOutQLocalSocket.start();
                  DEBUGCONSOLE(90,"UIcon::dataincomming","Need wait to recomposite: "+QString::number(tempComposed.data.size())+", targeted: "+QString::number(tempComposed.size));
                  DEBUGCONSOLE(90,"UIcon::dataincomming","tempComposed.data: "+QString(tempComposed.data.toHex()));
                  return;
            }
            DEBUGCONSOLE(90,"UIcon::dataincomming","socket->bytesAvailable(): "+QString::number(socket->bytesAvailable())+", for total of: "+QString::number(socket->bytesAvailable()+sizeof(quint32)));

            // Get the full message
            quint32 copyId=0;
            in >> copyId;//store the copy id
            parseTheCleanedTrame(socket->readAll(),socket,copyId);
      }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index