void TwitterClient::resultReceiver(QString data) { bar.hide(); qDebug() << data; QDomDocument xml; xml.setContent(data); QDomElement rsp = xml.firstChildElement("rsp"); if (rsp.isNull()) { QMessageBox::critical(NULL, tr("Error"), tr("Could not post to twitter. Wrong server response.")); emit errorHappened(); return; } QDomElement error = rsp.firstChildElement("err"); if (!error.isNull()) { /* 1002 media not found 2005 media is too big 2001 invalid action specified 2004 invalid developer key 1001 empty/invalid username/password 2002 failed to upload media 2003 failed to update status*/ QDomNode codex = error.attributes().namedItem("code"); if (!codex.isNull()) { QString code = codex.nodeValue(); if (code == "1001") { QMessageBox::critical(NULL, tr("Error"), tr("Could not post to twitter. Wrong credentials.")); emit errorHappened(); return; } else if (code == "2003") { QMessageBox::critical(NULL, tr("Error"), tr("Failed to update twitter status.")); emit errorHappened(); return; } } QMessageBox::critical(NULL, tr("Error"), tr("Could not post to twitter. Internal error.")); return; } QDomElement statusid = rsp.firstChildElement("statusid"); if (statusid.isNull()) { QMessageBox::critical(NULL, tr("Error"), tr("Could not post to twitter. Wrong server response.")); return; } QString addr("http://twitter.com/%1/status/%2"); addr = addr.arg(user, statusid.text()); QDesktopServices().openUrl(QUrl(addr)); }
void SourceAddDialog::openDataSource() { ui->BrowseButton->setEnabled(false); ui->ConnectButton->setEnabled(false); ui->URLLineEdit->setEnabled(false); ui->LayersTableWidget->setEnabled(false); ui->ButtonBox->setEnabled(false); ui->StatusProgressBar->setValue(0); ui->LayersTableWidget->setRowCount(0); ui->StatusProgressBar->setTextVisible(false); ui->StatusProgressBar->setVisible(true); ui->StatusLabel->setText(tr("Connecting to source")); setCursor(Qt::WaitCursor); QThread* WThread = new QThread; SourceWorker* Worker = new SourceWorker(m_CurrentSourceURI,mp_DataSource); Worker->moveToThread(WThread); connect(Worker, SIGNAL(finished()), this, SLOT(handleSourceFinished())); connect(Worker, SIGNAL(sourceLinked(void*)), this, SLOT(handleSourceLinked(void*))); connect(Worker, SIGNAL(layerCounted(int)), this, SLOT(handleLayerCounted(int))); connect(Worker, SIGNAL(layerFetched(int,QString,QString)), this, SLOT(handleLayerFetched(int,QString,QString))); connect(Worker, SIGNAL(errorHappened(QString)), this, SLOT(handleSourceError(QString))); connect(WThread, SIGNAL(started()), Worker, SLOT(run())); connect(Worker, SIGNAL(finished()), WThread, SLOT(quit())); connect(Worker, SIGNAL(finished()), Worker, SLOT(deleteLater())); connect(WThread, SIGNAL(finished()), WThread, SLOT(deleteLater())); WThread->start(); }
void DataServerThread::run() { m_socket = socket(AF_INET, SOCK_STREAM, 0); if(m_socket == INVALID_SOCKET) { emit errorHappened(CreateSocketError, __FILE__, __LINE__); return ; } SOCKADDR_IN serverAddr; serverAddr.sin_family = AF_INET; serverAddr.sin_addr.s_addr = htonl(INADDR_ANY); serverAddr.sin_port = htons(DataChannelPort); if(SOCKET_ERROR == bind(m_socket, (SOCKADDR*)&serverAddr, sizeof(serverAddr))) { emit errorHappened(BindError, __FILE__, __LINE__); return ; } if(SOCKET_ERROR == listen(m_socket, SOMAXCONN)) { emit errorHappened(ListenError, __FILE__, __LINE__); return ; } while(true) { SOCKET clientSocket; SOCKADDR_IN clientAddr; int clientAddrSize = sizeof(clientAddr); clientSocket = accept(m_socket, (SOCKADDR*)&clientAddr, &clientAddrSize); if(clientSocket == INVALID_SOCKET) { emit errorHappened(AcceptError, __FILE__, __LINE__); continue; } } }
void Browser::loadFinished(bool ok) { QUrl current_url(page->currentFrame()->baseUrl()); // events trottling if (current_url == this->last_url) { qDebug() << this << QString("%1, loadFinished trottled.").arg(QDateTime::currentDateTime().toTime_t()); return; } this->last_url = current_url; qDebug() << this << QString("%1, '%2', %3 ms.").arg(QDateTime::currentDateTime().toTime_t()).arg(current_url.toString()).arg(page_load_time.elapsed()); if (!ok) { emit(errorHappened(page_load_time.elapsed(), page->currentFrame()->baseUrl())); restartTest(QString("its not ok, something wrong happened! (possibly 500) URL: %1").arg(page->currentFrame()->baseUrl().toString())); return; } QWebElement document= page->currentFrame()->documentElement(); if (page->currentFrame()->baseUrl().host() != base_url.host()) { restartTest("We've got outside the test site. Restarting."); return; } QWebElementCollection collection = document.findAll("a[href]"); QWebElement link; QString link_href; if (collection.count() == 0) { restartTest("No links found on page. Restarting."); return; } // Ignoring javascript and empty links do { link = collection.at(qrand()%collection.count()); link_href = link.attribute("href"); } while ((link_href.count() == 0) || (link_href.at(0) == '#') || (link_href.contains("javascript:;"))); emit(pageLoaded(page_load_time.elapsed(), page->currentFrame()->baseUrl())); link.evaluateJavaScript("var evObj = document.createEvent('MouseEvents');evObj.initEvent( 'click', true, true );this.dispatchEvent(evObj);"); page_load_time.start(); timeout_countdown->start(); }
void DownloadFragmnet::onFinished(QNetworkReply *) { switch(reply->error()) { case QNetworkReply::NoError: { emit Finished(index,dataFragment); }break; default:{ emit errorHappened(index); }; } }
void QWurthScanner::setPortName(QString portName) { mErrorString.clear(); if (port.isOpen()) port.close(); port.setPortName(portName); port.setBaudRate(BAUD9600); port.setQueryMode(QextSerialPort::EventDriven); if (!port.open(QextSerialPort::ReadWrite)) { mErrorString = tr("Unable to open the %1 port").arg(portName); emit errorHappened(); } }
void MyXmppClient::error(QXmppClient::Error e) { QString errString; if( e == QXmppClient::SocketError ) errString = "SOCKET_ERROR"; else if( e == QXmppClient::KeepAliveError ) errString = "KEEP_ALIVE_ERROR"; else if( e == QXmppClient::XmppStreamError ) errString = "XMPP_STREAM_ERROR"; if( !errString.isNull() ) { QXmppPresence pr = xmppClient->clientPresence(); this->presenceReceived( pr ); QXmppPresence presence( QXmppPresence::Unavailable ); this->clearPresence(); xmppClient->setClientPresence( presence ); emit errorHappened(m_accountId,errString); } }
void OdroidFlashManager::requestBackupBootFile(QString boot_file_path, QString disk_path) { if(!mDiskManager->checkDiskMounted(disk_path)) { mCurrentProcess = READING_BOOT; mDiskManager->mountDisk(disk_path); return; } if(mCurrentProcess == WAITING_PROCESS) { mCurrentProcess = READING_BOOT; mDiskManager->loadBootFromDevice(disk_path); } else emit errorHappened(READING_BOOT,4,QStringLiteral("System Busy - Cannot read boot at this time.")); }
TwitterWindow::TwitterWindow(QDialog *parent) : QDialog(parent), m_ui(new Ui::TwitterWindow) { setParent(parent); m_ui->setupUi(this); twitter = QSharedPointer<TwitterClient>(new TwitterClient(parent)); textChanged(); QSettings sets; QString user = QByteArray::fromBase64(sets.value("twitteruser", QVariant("")).toByteArray()); QString pass = QByteArray::fromBase64(sets.value("twitterpass", QVariant("")).toByteArray()); m_ui->remember->setChecked(((!pass.isEmpty()) && (!user.isEmpty()))); m_ui->username->setText(user); m_ui->password->setText(pass); connect(twitter.data(), SIGNAL(errorHappened()), this, SLOT(twitterError())); }