postoperation::postoperation(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::postoperation)
{
    ui->setupUi(this);

    //
    ui->pbPost->setFocusPolicy(Qt::NoFocus);//设置按钮无焦点
    ui->pbSearch->setFocusPolicy(Qt::NoFocus);//设置按钮无焦点
    ui->pbReturn->setFocusPolicy(Qt::NoFocus);//设置按钮无焦点
    ui->pbsendfile->setFocusPolicy(Qt::NoFocus);//设置按钮无焦点

    //IP
    localIpStr = getIp();
    ui->label_ipaddress->setText(localIpStr);

    //
    loadSize = 4*1024;
    totalBytes = 0;
    bytesWritten = 0;
    bytesToWrite = 0;
    tcpClient = new QTcpSocket(this);
    connect(tcpClient,SIGNAL(connected()),this,SLOT(startTransfer()));
    //当连接服务器成功时,发出connected()信号,我们开始传送文件
    connect(tcpClient,SIGNAL(bytesWritten(qint64)),this,SLOT(updateClientProgress(qint64)));
    //当有数据发送成功时,我们更新进度条
    connect(tcpClient,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(displayError(QAbstractSocket::SocketError)));

}
Ejemplo n.º 2
0
void Transfer::initTransfer()
{
    mState = TransferModel::InProgress;
    emit dataChanged({TransferModel::StateRole});

    startTransfer();
}
Ejemplo n.º 3
0
Error SynopsisUSB::transfer(const FileSystemMessage *msg,
                            USBMessage *usb)
{
    DEBUG("");

    switch (usb->state)
    {
        case USBMessage::Setup:
            startTransfer(0, msg, usb);
            break;

        case USBMessage::Data:
            break;

        case USBMessage::Status:
            break;

        default:
            break;
    }

    usb->state = USBMessage::Success;

    USBDescriptor::Device desc;
    desc.vendorId = 111;
    desc.productId = 222;

    VMCopy(msg->from, API::Write, (Address) &desc, usb->buffer, usb->size);
    return ESUCCESS;
}
Ejemplo n.º 4
0
void pix_videoDarwin :: setupCapture()
{
    stopTransfer();
    SGSetChannelUsage(m_vc, 0);

    if (m_record) {
        SGSetDataOutput(m_sg,&theFSSpec,seqGrabToDisk);
        switch(m_record){

        case 1:
            SGSetChannelPlayFlags(m_vc, channelPlayAllData);
            SGSetChannelUsage(m_vc, seqGrabRecord | seqGrabPlayDuringRecord);
            post("record full preview");
            break;
        case 2:
            SGSetChannelUsage(m_vc, seqGrabRecord | seqGrabPlayDuringRecord);
            post("record some preview");
            break;
        case 3:
            SGSetChannelUsage(m_vc, seqGrabRecord);
            post("record no preview");
            break;
        default:
            SGSetChannelUsage(m_vc, seqGrabRecord);
        }
    }
    else {
        SGSetChannelUsage(m_vc, seqGrabPreview);
    }
    SGUpdate(m_sg,0);

    startTransfer();
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    // Get the port we will listen on
    QInputDialog options;
    options.setLabelText("Enter port for listening:");
    options.setTextValue("12349");
    options.exec();

    MainWindow window;
    Server server(options.textValue());
    Client client;

    window.connect(&server, SIGNAL(messageRecieved(QString,QString)),
                    &window, SLOT(displayNewMessage(QString,QString)));

    window.connect(&window, SIGNAL(connectToChanged(QString,QString)),
                   &client, SLOT(connectTo(QString,QString)));

    window.connect(&window, SIGNAL(sendMessage(QString)),
                   &client, SLOT(startTransfer(QString)));

    window.show();
    window.resize(480,320);
    window.setWindowTitle(window.windowTitle() + " (listen port: " + options.textValue() + ")");
    
    return a.exec();
}
Ejemplo n.º 6
0
void GuiBehind::sendText()
{
    // Get text to send
    QString text = textSnippet();
    if (text == "") return;

    // Send text
    startTransfer(text);
}
Ejemplo n.º 7
0
pissTransmissionTask::pissTransmissionTask(QVector<OutputQueue *> *oq, pissNetworkEnvironment* environment){
    frameCounter = 0;
    transmissionTimer = new QTimer();
    this->oq = oq;
    this->environment = environment;
    this->socketTransmission = new QTcpSocket();
    this->connect(this->socketTransmission, SIGNAL(connected()), this, SLOT(startTransfer()));
    this->connect(this->transmissionTimer, SIGNAL(timeout()), this, SLOT(transfer()));
}
Ejemplo n.º 8
0
Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
{
    clientProgressBar = new QProgressBar;
    clientStatusLabel = new QLabel(tr("Client ready"));
    serverProgressBar = new QProgressBar;
    serverStatusLabel = new QLabel(tr("Server ready"));

#ifdef Q_OS_SYMBIAN
    QMenu *menu = new QMenu(this);

    QAction *optionsAction = new QAction(tr("Options"), this);
    optionsAction->setSoftKeyRole(QAction::PositiveSoftKey);
    optionsAction->setMenu(menu);
    addAction(optionsAction);

    startAction = menu->addAction(tr("Start"), this, SLOT(start()));

    quitAction = new QAction(tr("Exit"), this);
    quitAction->setSoftKeyRole(QAction::NegativeSoftKey);
    addAction(quitAction);

    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
#else
    startButton = new QPushButton(tr("&Start"));
    quitButton = new QPushButton(tr("&Quit"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(startButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);

    connect(startButton, SIGNAL(clicked()), this, SLOT(start()));
    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
#endif
    connect(&tcpServer, SIGNAL(newConnection()),
            this, SLOT(acceptConnection()));
    connect(&tcpClient, SIGNAL(connected()), this, SLOT(startTransfer()));
    connect(&tcpClient, SIGNAL(bytesWritten(qint64)),
            this, SLOT(updateClientProgress(qint64)));
    connect(&tcpClient, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(displayError(QAbstractSocket::SocketError)));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(clientProgressBar);
    mainLayout->addWidget(clientStatusLabel);
    mainLayout->addWidget(serverProgressBar);
    mainLayout->addWidget(serverStatusLabel);
    mainLayout->addStretch(1);
    mainLayout->addSpacing(10);
#ifndef Q_OS_SYMBIAN
    mainLayout->addWidget(buttonBox);
#endif
    setLayout(mainLayout);

    setWindowTitle(tr("Loopback"));
}
Ejemplo n.º 9
0
void GuiBehind::sendSomeFiles()
{
    // Show file selection dialog
    QStringList files = QFileDialog::getOpenFileNames(mView, "Send some files");
    if (files.count() == 0) return;

    // Send files
    QStringList toSend = files;
    startTransfer(toSend);
}
Ejemplo n.º 10
0
Archivo: dmx.c Proyecto: mmpbel/Artnet
void DMX_unitTest (void, UINT val)
{
    UINT i;

    for (i=1; i<(MAX_DMX_SLOTS + 1); i++)
    {
        DMX_channelData[i] = val;
    }
    // kickstart DMX
    startTransfer(DMX_channelData, sizeof(DMX_channelData));
}
Ejemplo n.º 11
0
void GuiBehind::sendFolder()
{
    // Show folder selection dialog
    QString dirname = QFileDialog::getExistingDirectory(mView, "Change folder", ".",
                      QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
    if (dirname == "") return;

    // Send files
    QStringList toSend;
    toSend.append(dirname);
    startTransfer(toSend);
}
Ejemplo n.º 12
0
/**
 * @brief Client::Client create the backend of a client for a baisc chat interaction
 * @param parent parent object, default null
 */
Client::Client(QObject *parent, QString uName) : QObject(parent)
{
    Utility::debugEnable();

    clientSocket = new QTcpSocket(this);
    username = uName;

    qDebug() << "Creating New QTcp Socket" << &clientSocket;
    connect(clientSocket, SIGNAL(connected()), this, SLOT(startTransfer()));
    connect(clientSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this, SLOT(clientChange(QAbstractSocket::SocketState)));
    connect(clientSocket, SIGNAL(readyRead()), this, SLOT(echo()));
}
void FileTransferJob::doStart()
{
    description(this, i18n("Receiving file over KDE Connect"),
        QPair<QString, QString>(i18nc("File transfer origin", "From"), mFrom)
    );

    if (mDestination.isLocalFile() && QFile::exists(mDestination.toLocalFile())) {
        setError(2);
        setErrorText(i18n("Filename already present"));
        emitResult();
    }

    startTransfer();
}
Ejemplo n.º 14
0
void GuiBehind::sendDroppedFiles(QStringList *files)
{
    if (files->count() == 0) return;

    // Check if there's no selected buddy
    // (but there must be only one buddy in the buddy list)
    if (overlayState() == "")
    {
        if (mBuddiesList.rowCount() != 3) return;
        showSendPage(mBuddiesList.fistBuddyIp());
    }

    // Send files
    QStringList toSend = *files;
    startTransfer(toSend);
}
Ejemplo n.º 15
0
void GuiBehind::sendClipboardText()
{
    // Get text to send
    QString text = mClipboard->text();
#ifndef Q_WS_S60
    if (text == "") return;
#else
    if (text == "") {
        setMessagePageTitle("Send");
        setMessagePageText("No text appears to be in the clipboard right now!");
        setMessagePageBackState("send");
        emit gotoMessagePage();
        return;
    }
#endif

    // Send text
    startTransfer(text);
}
Ejemplo n.º 16
0
/////////////////////////////////////////////////////////
// dimenMess
//
/////////////////////////////////////////////////////////
void pix_videoDarwin :: dimenMess(int x, int y, int leftmargin, int rightmargin,
    int topmargin, int bottommargin)
{
    if (x > 0 ){
        m_vidXSize = (int)x;
    }else{
        m_vidXSize = 320;
    }
    if (y > 0){
        m_vidYSize = (int)y;
    }else{
        m_vidYSize = 240;
    }
    stopTransfer();
    resetSeqGrabber();
    startTransfer();
    post("height %d width %d",m_vidYSize,m_vidXSize);
//  m_pixBlock.image.xsize = m_vidXSize;
//  m_pixBlock.image.ysize = m_vidYSize;

}
int postoperation::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: send(); break;
        case 1: startTransfer(); break;
        case 2: displayError((*reinterpret_cast< QAbstractSocket::SocketError(*)>(_a[1]))); break;
        case 3: updateClientProgress((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 4: on_pbReturn_clicked(); break;
        case 5: on_pbPost_clicked(); break;
        case 6: on_pbSearch_clicked(); break;
        case 7: on_pbsendfile_clicked(); break;
        default: ;
        }
        _id -= 8;
    }
    return _id;
}
Ejemplo n.º 18
0
/////////////////////////////////////////////////////////
// colorspaceMess
//
/////////////////////////////////////////////////////////
void pix_videoDarwin :: csMess(int format)
{
    m_colorspace = format;
    if (format == GL_RGBA) {
     post("colorspace is GL_RGBA %d",m_colorspace);
    } else if (format == GL_BGRA_EXT) {
      post("colorspace is GL_RGBA %d",m_colorspace);
    } else if (format == GL_YCBCR_422_GEM) {
      post("colorspace is YUV %d",m_colorspace);
    } else if (format == GL_LUMINANCE) {
        post("'Gray' not yet supported...using YUV");
        format=GL_YCBCR_422_GEM;
    } else {
      error("colorspace is unknown %d", m_colorspace);
      return;
    }

    stopTransfer();
    resetSeqGrabber();
    startTransfer();
}
Ejemplo n.º 19
0
sendwidget::sendwidget(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::sendwidget),
    totalBytes(0),
    bytesWritten(0),
    bytesToWrite(0),
    loadSize(4*1024)

{
    ui->setupUi(this);
    tcpClient = new QTcpSocket(this);
    connect(ui->BT_openFile, SIGNAL(clicked(bool)), this, SLOT(BT_openFile_clicked()));
    connect(ui->BT_sendFile, SIGNAL(clicked(bool)), this, SLOT(BT_sendFile_clicked()));

    connect(tcpClient, SIGNAL(connected()), this, SLOT(startTransfer()));
    connect(tcpClient, SIGNAL(bytesWritten(qint64)), this, SLOT(updateClinetProgress(qint64)));
    connect(tcpClient, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));

    ui->BT_sendFile->setEnabled(false);
    ui->progressBar->reset();

}
Ejemplo n.º 20
0
Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
{
    clientProgressBar = new QProgressBar;
    clientStatusLabel = new QLabel(tr("Client ready"));
    serverProgressBar = new QProgressBar;
    serverStatusLabel = new QLabel(tr("Server ready"));

    startButton = new QPushButton(tr("&Start"));
    quitButton = new QPushButton(tr("&Quit"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(startButton, QDialogButtonBox::ActionRole);
    buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);

    connect(startButton, SIGNAL(clicked()), this, SLOT(start()));
    connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
    connect(&tcpServer, SIGNAL(newConnection()),
            this, SLOT(acceptConnection()));
    connect(&tcpClient, SIGNAL(connected()), this, SLOT(startTransfer()));
    connect(&tcpClient, SIGNAL(bytesWritten(qint64)),
            this, SLOT(updateClientProgress(qint64)));
    connect(&tcpClient, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(displayError(QAbstractSocket::SocketError)));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(clientProgressBar);
    mainLayout->addWidget(clientStatusLabel);
    mainLayout->addWidget(serverProgressBar);
    mainLayout->addWidget(serverStatusLabel);
    mainLayout->addStretch(1);
    mainLayout->addSpacing(10);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

    setWindowTitle(tr("Loopback"));
}
Ejemplo n.º 21
0
// PS3 Connect
int serverConnect(const char *server_remote_address, const char *server_port, MoveStateDeferred *move_state_deferred) {
  int rc, last_error;
  unsigned int tsa_len;
  struct sockaddr_in service, transfer;
  struct addrinfo *result = NULL, *addrptr = NULL, hints;
  char remote_address[100], port[6];
  tsa_len = sizeof(transfer);

  if (s_connected) {
    return MOVE_CLIENT_OK;

  }

  // Save deferred reference
  s_move_state_deferred = move_state_deferred;

  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_protocol = IPPROTO_TCP;

  service.sin_family = AF_INET;
  service.sin_port = 0;
  service.sin_addr.s_addr = htonl(INADDR_ANY);
  memset(service.sin_zero, '\0', sizeof(service.sin_zero));

  strncpy(remote_address, server_remote_address, sizeof(remote_address));
  remote_address[sizeof(remote_address) - 1] = '\0';

  strncpy(port, server_port, sizeof(port));
  port[sizeof(port) - 1] = '\0';

  if (getaddrinfo(remote_address, port, &hints, &result)) {
    return errno;

  }

  // Create transfer socket
  if ((s_transfer_sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
    freeaddrinfo(result);
    return errno;

  }

  // Attempt to connect to an address until one succeeds
  for (addrptr = result; addrptr != NULL; addrptr = addrptr->ai_next) {

    if ((s_control_sockdf = socket(addrptr->ai_family, addrptr->ai_socktype, addrptr->ai_protocol)) == -1) {
      freeaddrinfo(result);
      return errno;

    }

    // Connect to server
    if (connect(s_control_sockdf, addrptr->ai_addr, (int)addrptr->ai_addrlen) == -1) {
      close(s_control_sockdf);
      s_control_sockdf = -1;
      continue;

    }
    break;

  }

  freeaddrinfo(result);

  if (-1 == s_control_sockdf) {
    last_error = errno;
    close(s_transfer_sockfd);
    return last_error;

  }

  // Update internal state after all sockets successfully created
  s_connected = TRUE;

  // Initialize socket file descriptors for select
  FD_ZERO(&s_fd_read);
  FD_ZERO(&s_fd_except);
  FD_SET(s_transfer_sockfd, &s_fd_read);
  FD_SET(s_transfer_sockfd, &s_fd_except);

  // Bind transfer Socket
  if (bind(s_transfer_sockfd, (struct sockaddr *)&service, sizeof(service)) == -1) {
    last_error = errno;
    serverDisconnect();
    return last_error;

  }

  // Change transfer socket mode to non-blocking
  int flags = fcntl(s_transfer_sockfd, F_GETFL, 0);

  if (-1 == fcntl(s_transfer_sockfd, F_SETFL, O_NONBLOCK|flags)) {
    last_error = errno;
    serverDisconnect();
    return last_error;

  }

  // Get transfer socket port
  if (getsockname(s_transfer_sockfd, (struct sockaddr *)&transfer, &tsa_len)) {
    last_error = errno;
    serverDisconnect();
    return last_error;

  }

  // Start UpdateMoveServer thread
  if ((rc = startTransfer())) {
    serverDisconnect();
    return rc;

  }

  // Send initialization request
  if ((rc = sendRequestPacket(MOVE_CLIENT_REQUEST_INIT, ntohs(transfer.sin_port)))) {
    serverDisconnect();
    return rc;

  }

  return MOVE_CLIENT_OK;

}
Ejemplo n.º 22
0
static int pdp_ieee1394_open(t_pdp_ieee1394 *x, t_symbol *name)
{
  x->x_devicename = name->s_name;

  if(x->x_haveVideo){
    verbose(1, "Stream already going on. Doing some clean-up...");
    stopTransfer(x);
  }

  /*
  All of the errors in this method return -1 anyhow, so fd should be 0 to allow
  successful open if everything goes ok.

  Ico Bukvic [email protected] 2-18-07
  */
  int fd = 0; 
  struct dv1394_init init = {
    DV1394_API_VERSION, // api version 
    0x63,              // isochronous transmission channel
    N_BUF,             // number of frames in ringbuffer
    (x->x_norm==NTSC)?DV1394_NTSC:DV1394_PAL,         // PAL or NTSC
    //DV1394_PAL,         // PAL or NTSC
    0, 0 , 0                // default packet rate
  };

  x->x_framesize=(x->x_norm==NTSC)?DV1394_NTSC_FRAME_SIZE:DV1394_PAL_FRAME_SIZE;
  //x->x_framesize=DV1394_PAL_FRAME_SIZE;

  if(x->x_devicename){
    if ((fd = open(x->x_devicename, O_RDWR)) < 0) {
        perror(x->x_devicename);
        return -1;
    }
  } else {
    signed char devnum=(x->x_devicenum<0)?0:(signed char)x->x_devicenum;
    char buf[256];
    buf[255]=0;buf[32]=0;buf[33]=0;
    if (devnum<0)devnum=0;
    snprintf(buf, 32, "/dev/ieee1394/dv/host%d/%s/in", devnum, (x->x_norm==NTSC)?"NTSC":"PAL");
    //snprintf(buf, 32, "/dev/ieee1394/dv/host%d/%s/in", devnum, "PAL");
    if ((fd = open(buf, O_RDWR)) < 0)    {
      snprintf(buf, 32, "/dev/dv1394/%d", devnum);
      if ((fd = open(buf, O_RDWR)) < 0) {
	if ((fd=open("/dev/dv1394", O_RDWR)) < 0)    {
	  perror(buf);
	  return -1;
	}
      }
    }
  }
  if (ioctl(fd, DV1394_INIT, &init) < 0)    {
    perror("initializing");
    close(fd);
    return -1;
  }
  
  x->x_mmapbuf = (unsigned char *) mmap( NULL, N_BUF*x->x_framesize,
				       PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  if(x->x_mmapbuf == MAP_FAILED) {
    perror("mmap frame buffers");
    close(fd);
    return -1;
  }
  
  if(ioctl(fd, DV1394_START_RECEIVE, NULL)) {
    perror("dv1394 START_RECEIVE ioctl");
    close(fd);
    return -1;
  }
  /*Extra verbosity never hurt anyone...

  Ico Bukvic [email protected] 2-18-07
  */
  post("DV4L: Successfully opened...");
  startTransfer(x);
  x->dvfd=fd;

  return 1;
	
}
Ejemplo n.º 23
0
Archivo: dmx.c Proyecto: mmpbel/Artnet
/**
@brief  Send DMX general packet.

@return none.
*/
static void sendDmxData (void)
{
    DMX_channelData[0] = DMX_START_CODE;
    rxRequest = 0;
    startTransfer(DMX_channelData, sizeof(DMX_channelData));
}
Ejemplo n.º 24
0
Archivo: dmx.c Proyecto: mmpbel/Artnet
/**
@brief  start DMX answer

@return none.
*/
void DMX_sendAnswer (UINT8 *buf, UINT size)
{
    rxRequest = 0;
    startTransfer(buf, size);
}
Ejemplo n.º 25
0
Archivo: dmx.c Proyecto: mmpbel/Artnet
/**
@brief  start RDM transfer

@return none.
*/
void DMX_sendRdm (UINT8 *buf, UINT size)
{
    rxRequest = buf;
    startTransfer(buf, size);
}