TreeContactListModel::TreeContactListModel(const QStringList &headers, QObject *parent)
	: QAbstractItemModel(parent), m_notification_layer(0)
{
	ensure_contact_list_empty();
	QString nil_group( QChar(0) );
	m_nil_group=nil_group;
	m_time_screen_shot = -2000;
	m_icon_timer = new QTimer(this);
	m_icon_timer->setInterval(500);
	connect(m_icon_timer, SIGNAL(timeout()), this, SLOT(onTimerTimeout()));
	m_icon_timer->start();
	m_show_special_status=false;
	m_status_to_tr.insert("online",tr("Online"));
	m_status_to_tr.insert("ffc",tr("Free for chat"));
	m_status_to_tr.insert("away",tr("Away"));
	m_status_to_tr.insert("na",tr("Not available"));
	m_status_to_tr.insert("occupied",tr("Occupied"));
	m_status_to_tr.insert("dnd",tr("Do not disturb"));
	m_status_to_tr.insert("invisible",tr("Invisible"));
	m_status_to_tr.insert("offline",tr("Offline"));
	m_status_to_tr.insert("athome",tr("At home"));
	m_status_to_tr.insert("atwork",tr("At work"));
	m_status_to_tr.insert("lunch",tr("Having lunch"));
	m_status_to_tr.insert("evil",tr("Evil"));
	m_status_to_tr.insert("depression",tr("Depression"));
	m_status_to_tr.insert("noauth",tr("Without authorization"));
}
Esempio n. 2
0
TreeContactListModel::TreeContactListModel(const QStringList &headers, QObject *parent)
    : QAbstractItemModel(parent)
{
  QString nil_group("");
  nil_group.append(QChar(0));
  m_nil_group=nil_group;
  m_root_item = new TreeItem(headers[0]);
  m_icon_timer = new QTimer(this);
  m_icon_timer->setInterval(500);
  m_icon_timer->setObjectName("qutIM::TreeContactListModel::iconTimer");
  connect(m_icon_timer, SIGNAL(timeout()), this, SLOT(onTimerTimeout()));
  //m_icon_timer->start();
  m_show_special_status=false;
  m_status_to_tr.insert("online",tr("Online"));
  m_status_to_tr.insert("ffc",tr("Free for chat"));
  m_status_to_tr.insert("away",tr("Away"));
  m_status_to_tr.insert("na",tr("Not available"));
  m_status_to_tr.insert("occupied",tr("Occupied"));
  m_status_to_tr.insert("dnd",tr("Do not disturb"));
  m_status_to_tr.insert("invisible",tr("Invisible"));
  m_status_to_tr.insert("offline",tr("Offline"));
  m_status_to_tr.insert("athome",tr("At home"));
  m_status_to_tr.insert("atwork",tr("At work"));
  m_status_to_tr.insert("lunch",tr("Having lunch"));
  m_status_to_tr.insert("evil",tr("Evil"));
  m_status_to_tr.insert("depression","Depression");
  m_status_to_tr.insert("noauth",tr("Without authorization"));
}
Esempio n. 3
0
NATRON_NAMESPACE_ENTER

FileDownloader::FileDownloader(const QUrl& imageUrl,
                               bool useNetworkCache,
                               QObject *parent)
    : QObject(parent)
    , m_reply(0)
    , m_WebCtrl(new QNetworkAccessManager)
    , m_DownloadedData(new QByteArray)
    , m_timer( new QTimer() )
{
    m_timer->setInterval(NATRON_FILE_DOWNLOAD_HEARBEAT_TIMEOUT_MS);
    QObject::connect( m_timer.get(), SIGNAL(timeout()), this, SLOT(onTimerTimeout()) );

    connect( m_WebCtrl.get(), SIGNAL(finished(QNetworkReply*)),
             SLOT(fileDownloaded(QNetworkReply*)) );

    QNetworkRequest request(imageUrl);
    if (!useNetworkCache) {
        request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
    }

    m_reply = m_WebCtrl->get(request);
    m_timer->start();
    QObject::connect( m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SIGNAL(error()) );
    QObject::connect( m_reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(onDownloadProgress(qint64,qint64)) );
}
void SerialPort::connects()
{
    connect(serial, SIGNAL(readyRead()), this, SLOT(lineReceived()));
    connect(serial, SIGNAL(error(QSerialPort::SerialPortError)),
            this, SLOT(serialError(QSerialPort::SerialPortError)));

    connect(timer, SIGNAL(timeout()), this, SLOT(onTimerTimeout()));
}
/*! Constructs BaseInteraction
  */
BaseInteraction::BaseInteraction(MPMapView* theView) :
    FeatureSnapInteraction(theView),
    m_snapEnabled(true)
{
    m_idletimer = new QTimer(this);
    m_idletimer->setInterval(IDLE_TIMEOUT);
    m_idletimer->setSingleShot(true);
    connect(m_idletimer, SIGNAL(timeout()), this, SLOT(onTimerTimeout()));
    setDontSelectVirtual(true);
}
int MoodBox::SingleShotTimerObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: onTimerTimeout(); break;
        default: ;
        }
        _id -= 1;
    }
    return _id;
}
int MoodBox::RevolverRecieverManager::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = SingleShotTimerObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: channelsChanged(); break;
        case 1: onTimerTimeout(); break;
        case 2: onContactListChanged(); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
Esempio n. 8
0
XDCC::XDCC( QIrc * bot, QString dest, QString filename )
{
	parent_irc = bot;
	server = new QTcpServer( this );
	socket = 0;
	if( !server->listen(QHostAddress::Any, 5990) )
	{
		parent_irc->warning( tr( "can't lister on port 5990" ) );
		deleteLater();
		return;
	}
	
	connect( server, SIGNAL( newConnection() ), this, SLOT( onConnexion() ) );
	connect( server, SIGNAL( destroyed( QObject * ) ), this, SLOT( onDeletion( QObject * ) ) );
	fichier = QFileInfo( filename );
	parent_irc->send( dest, QString( "DCC SEND \"%1\" %2 %3 %4" ).arg( fichier.fileName() ).arg( parent_irc->ip() ).arg( 5990 ).arg( fichier.size() ) );
	QTimer::singleShot( 10000, this, SLOT( onTimerTimeout() ) );
}
int MoodBox::MessageReceiver::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = RandomRetryTimerObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: messageReceived((*reinterpret_cast< MessageFile*(*)>(_a[1]))); break;
        case 1: onTimerTimeout(); break;
        case 2: onGetNotifications((*reinterpret_cast< QList<Notification>(*)>(_a[1]))); break;
        case 3: onGetNewArtMessage((*reinterpret_cast< const ArtMessage(*)>(_a[1]))); break;
        case 4: onGetNewChannelMessage((*reinterpret_cast< const ChannelMessage(*)>(_a[1])),(*reinterpret_cast< qint32(*)>(_a[2]))); break;
        case 5: onChannelsChanged(); break;
        default: ;
        }
        _id -= 6;
    }
    return _id;
}
int MoodBox::GetNextMessageRequest::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = RandomRetryTimerObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: gotNextArtMessage((*reinterpret_cast< const ArtMessage(*)>(_a[1]))); break;
        case 1: gotNextChannelMessage((*reinterpret_cast< const ChannelMessage(*)>(_a[1])),(*reinterpret_cast< qint32(*)>(_a[2]))); break;
        case 2: onTimerTimeout(); break;
        case 3: onGetNextArtMessageResult((*reinterpret_cast< QVariant(*)>(_a[1])),(*reinterpret_cast< Fault(*)>(_a[2])),(*reinterpret_cast< ArtMessage(*)>(_a[3]))); break;
        case 4: onGetNextChannelMessageUrlResult((*reinterpret_cast< QVariant(*)>(_a[1])),(*reinterpret_cast< Fault(*)>(_a[2])),(*reinterpret_cast< ChannelMessageUrl(*)>(_a[3]))); break;
        case 5: onGetNetworkReply((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 6;
    }
    return _id;
}
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    , serialPort(NULL)
{
    ui->setupUi(this);

    pollingTimer = new QTimer(this);
    pollingTimer->setSingleShot(false);
    pollingTimer->setTimerType(Qt::PreciseTimer);

    pollingTimer->setInterval(DEFAULT_POLLING_TIME);

    QObject::connect(pollingTimer, SIGNAL(timeout()), this, SLOT(onTimerTimeout()));

    pollingTimer->start();

    ui->pollingTimeEdit->setText(QString::number(DEFAULT_POLLING_TIME));

    statusLabel = new QLabel("Serial port closed", this);
    ui->statusbar->addWidget(statusLabel, 0);
}
int guMainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: abortInspectProcess(); break;
        case 1: show(); break;
        case 2: onGetSoapResponse(); break;
        case 3: testWebService(); break;
        case 4: loadCover((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 5: onCopyMD5ToClipboard(); break;
        case 6: onOpenCurrentEbook(); break;
        case 7: onSetLibraryForAllBooks(); break;
        case 8: onSetLibraryIssueForAllBooks(); break;
        case 9: onSetPeriodicalForAllBooks(); break;
        case 10: onSetTitleForAllBooks(); break;
        case 11: onSetAuthorsForAllBooks(); break;
        case 12: onSetSeriesForAllBooks(); break;
        case 13: onSetPublisherForAllBooks(); break;
        case 14: onSetSityForAllBooks(); break;
        case 15: onSetUdcForAllBooks(); break;
        case 16: onSetPubYearForAllBooks(); break;
        case 17: onSetBbcForAllBooks(); break;
        case 18: onSetLanguageForAllBooks(); break;
        case 19: onSetOrientationForAllBooks(); break;
        case 20: onSetScanDpiForAllBooks(); break;
        case 21: onSetColorScanForAllBooks(); break;
        case 22: onSetCleanScanForAllBooks(); break;
        case 23: { QString _r = getParamValue((*reinterpret_cast< QDomDocument*(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 24: onSetCategoryForAllBooks(); break;
        case 25: onSetCommentaryForAllBooks(); break;
        case 26: onAbortInspectProcess(); break;
        case 27: onAllEbooksUploaded(); break;
        case 28: onShowAbout(); break;
        case 29: onHelp(); break;
        case 30: initBaseSettings(); break;
        case 31: initSearchFilesSettings(); break;
        case 32: processCheckDublicateReply((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 33: processFillBibliographyReply((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 34: processLoadCoverReply((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 35: onCurrentFileChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break;
        case 36: onFilesTreeDoubleClicked((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 37: onAddNewEbook((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< ebook(*)>(_a[2]))); break;
        case 38: onDublicateFinded(); break;
        case 39: onInspectFinished(); break;
        case 40: onStartProcess(); break;
        case 41: onEndProcess(); break;
        case 42: onTimerTimeout(); break;
        case 43: onCurrentCategoryChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break;
        case 44: onCurrentCategoryChangedFillStr((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break;
        case 45: clearEditFields(); break;
        case 46: onInspectFolder(); break;
        case 47: onGetBiblioInfo(); break;
        case 48: onUploadToServer(); break;
        case 49: onFileListRight(); break;
        case 50: onFileListLeft(); break;
        case 51: onGetBiblioForCurrentEbook(); break;
        case 52: setGuiEditForCurrentItem(); break;
        case 53: onSaveChangesForBook(); break;
        case 54: onUploadEbookProgress((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 55: onUploadEbookFinished((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 56: onShowSettingsDialog(); break;
        case 57: onIsbnFieldChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 58: onIsbnsListItemActivated(); break;
        case 59: onAddIsbn(); break;
        case 60: onRemoveIsbn(); break;
        case 61: onAddIsbnToEbook((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 62: onRemoveIsbnFromEbook((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 63: onCommentaryTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 64: onTitleTextChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 65: onAuthorsTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 66: onSeriesTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 67: onPublisherTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 68: onUdcTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 69: onBbcTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 70: onPubYearTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 71: onPageNumTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 72: onIssueTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 73: onVolumeTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 74: onLanguageTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 75: onDescriptionTextChanged(); break;
        case 76: onSityTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 77: onPeriodicalTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 78: onCategoryTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 79: onOrientationIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 80: onBiblioTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 81: onDpiTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 82: onDvdNumTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 83: onColorScanStateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 84: onClearScanStateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 85: onSelectAllToUploadToogled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 86: onSubjectIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 87: onToogleShowDublicates((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 88: onToogleShowUploaded((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 89: onToogleShowWithISBN((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 90: onToogleShowWithBibliography((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 91;
    }
    return _id;
}
Esempio n. 13
0
void
Downloader::onDownloadFinished()
{
    QNetworkReply::NetworkError videoError;
    QNetworkReply::NetworkError soundError;

    bool finished = false;


    if (_videoNetworkReply != NULL)
    {
        videoError = _videoNetworkReply->error();
    }
    else
    {
        videoError = QNetworkReply::NoError;
    }


    if (_soundNetworkReply != NULL)
    {
        soundError = _soundNetworkReply->error();
    }
    else
    {
        soundError = QNetworkReply::NoError;
    }


    if (_videoNetworkReply != NULL && _soundNetworkReply != NULL)
    {
        bool videoFinished = _videoNetworkReply->isFinished();
        bool soundFinished = _soundNetworkReply->isFinished();

        finished = videoFinished && soundFinished;
    }
    else if (_videoNetworkReply != NULL)
    {
        finished = _videoNetworkReply->isFinished();
    }
    else
    {
        finished = _soundNetworkReply->isFinished();
    }


    if (finished)
    {
        if (soundError == QNetworkReply::OperationCanceledError &&
            _videoNetworkReply == NULL)
        {
            videoError = QNetworkReply::OperationCanceledError;
        }

        if (videoError == QNetworkReply::OperationCanceledError ||
            soundError == QNetworkReply::OperationCanceledError)
        {
            // User has canceled downloading

            goto Cleanup;
        }
        else if (videoError || soundError)
        {
            // Some kind of error occurred on both downloaders. Examine it.

            goto ErrorProcedure;
        }
        else
        {
            // It's possible that the downloaders finish without an error but
            // with no data downloaded. I've noticed that the video is still
            // available for download. This may happen if the video website has
            // issued a redirect. Check this and take action accordingly.

            if (_soundNetworkReply != NULL && _soundBytesReceived == 0)
            {
                if (redirect(_soundNetworkReply)) {
                    return;
                }

                qDebug() << QString("Invalid sound data from %1")
                            .arg(_soundNetworkReply->url().toString());

                goto ErrorProcedure;
            }

            if (_videoNetworkReply != NULL && _videoBytesReceived == 0)
            {
                if (redirect(_videoNetworkReply)) {
                    return;
                }

                qDebug() << QString("Invalid video data from %1")
                            .arg(_videoNetworkReply->url().toString());

                goto ErrorProcedure;
            }


            QString iargs = "-threads 1 -id3v2_version 3 -write_id3v1 1 ";

            bool hasArtist = !_download.artist.isEmpty();
            bool hasTitle = !_download.title.isEmpty();
            bool hasCoartist = !_download.coartist.isEmpty();

            if (hasArtist && hasTitle)
            {
                QString artist = _download.artist;

                if (hasCoartist) {
                    artist += " ft. " + _download.coartist;
                }

                // The filename so far contains the artist's name.
                // Write it using ID3 tags.
                // Delete " character as it will cause ffmpeg to fail.

                artist = artist.replace("\"", "");
                QString title = _download.title.replace("\"", "");

                iargs += " -metadata artist=\"" + artist + "\" ";
                iargs += " -metadata title=\"" + title + "\" ";
            }

            QString command;
            QString filename = _download.filename;
            QString extension = _download.outputFormat.extension;
            QString savePath = getOutputPath(filename, extension);
            QString ffmpeg = Utility::getFFmpegFilename();

            _download.outputFilename = savePath;


            if (_videoNetworkReply != NULL && _soundNetworkReply != NULL)
            {
                // Video service which separates sound and video stream.
                // The video was requested as both streams have been downloaded.
                // We will merge them into the final video file.

                QString vfilename = _videoFile->fileName();
                QString sfilename = _soundFile->fileName();
                QString args = "%1 -i \"%2\" -i \"%3\" %4 \"%5\"";

                command = QString(args)
                        .arg(ffmpeg)
                        .arg(vfilename)
                        .arg(sfilename)
                        .arg(iargs)
                        .arg(savePath);

                _videoFile->close();
                _soundFile->close();
            }
            else
            {
                QString filename = "";


                if (_soundNetworkReply != NULL)
                {
                    // Video service which separates sound and video stream.
                    // Only the sound was requested as only the sound stream
                    // has been downloaded. We will convert it to the final
                    // sound file.

                    filename = _soundFile->fileName();

                    _soundFile->close();
                }
                else
                {
                    // Video service which provides on video stream containing
                    // both the video and the sound streams. Call ffmpeg to
                    // convert it (or extract sound) to the requested format.

                    filename = _videoFile->fileName();

                    _videoFile->close();
                }

                command = QString("%1 -y -i \"%2\" %3 \"%4\"")
                        .arg(ffmpeg)
                        .arg(filename)
                        .arg(iargs)
                        .arg(savePath);
            }

            _convertPid = Tasks->enqueue(command);

            setStatus(Converting);
            setProgress(0, 0, 100);

            goto Cleanup;
        }
    }
    else
    {
        // One of the two downloaders (video/sound) has finished.
        // This may be normal. A common scenario is that sound has been
        // downloaded because of smaller size but video is still pending.
        // But maybe a downloader has finished because of an error.
        // Check and take action accordingly.
        if (videoError || soundError) {
            goto ErrorProcedure;
        }
    }

    return;


ErrorProcedure:

    // If at least one downloader has errored, stop the other.
    if (videoError && _soundNetworkReply != NULL) {
        _soundNetworkReply->abort();
    }

    if (soundError && _videoNetworkReply != NULL) {
        _videoNetworkReply->abort();
    }


    if (_retryCount < MAX_RETRIES)
    {
        _retryCount++;

        qDebug() << QString("Processor had an error connection. "
                            "Retrying for %1 time in %2 ms")
                            .arg(QString::number(_retryCount))
                            .arg(QString::number(RETRY_INTERVAL));

        QTimer *timer = new QTimer();

        timer->setSingleShot(true);
        timer->start(RETRY_INTERVAL);

        connect(timer,
                SIGNAL(timeout()),
                this,
                SLOT(onTimerTimeout()));

        return;
    }
    else
    {
        qDebug() << QString("Processor had an error connection. "
                            "Max retries of %1 reached")
                            .arg(MAX_RETRIES);

        setStatus(ErrorConnection);
        setProgress(0, 0, 0);

        goto Cleanup;
    }


Cleanup:
    if (_soundNetworkReply != NULL)
    {
        _soundNetworkReply->deleteLater();
        _soundNetworkReply = NULL;

        if (_soundFile->isOpen()) {
            _soundFile->close();
        }

        delete _soundFile;

        _soundFile = NULL;
    }

    if (_videoNetworkReply != NULL)
    {
        _videoNetworkReply->deleteLater();
        _videoNetworkReply = NULL;

        if (_videoFile->isOpen()) {
            _videoFile->close();
        }

        delete _videoFile;

        _videoFile = NULL;
    }
}