Ejemplo n.º 1
0
void CoreConnection::checkSyncState()
{
    if (_netsToSync.isEmpty() && state() >= Synchronizing) {
        setState(Synchronized);
        setProgressText(tr("Synchronized to %1").arg(currentAccount().accountName()));
        setProgressMaximum(-1);
        emit synchronized();
    }
}
Ejemplo n.º 2
0
void CoreConnection::resetConnection(bool wantReconnect)
{
    if (_resetting)
        return;
    _resetting = true;

    _wantReconnect = wantReconnect;

    if (_authHandler) {
        disconnect(_authHandler, 0, this, 0);
        _authHandler->close();
        _authHandler->deleteLater();
        _authHandler = 0;
    }

    if (_peer) {
        disconnect(_peer, 0, this, 0);
        // peer belongs to the sigproxy and thus gets deleted by it
        _peer->close();
        _peer = 0;
    }

    _netsToSync.clear();
    _numNetsToSync = 0;

    setProgressMaximum(-1); // disable
    setState(Disconnected);
    emit lagUpdated(-1);

    emit connectionMsg(tr("Disconnected from core."));
    emit encrypted(false);
    setState(Disconnected);

    // initiate if a reconnect if appropriate
    CoreConnectionSettings s;
    if (wantReconnect && s.autoReconnect()) {
        _reconnectTimer.start();
    }

    _resetting = false;
}
Ejemplo n.º 3
0
void Logger::set_next_line() {
	QMutexLocker locker(&mutex);
	virgin_line = true;
	if (line_message.startsWith(PROGRESS_ON)) progress_on = true;
	if (line_message.startsWith(PROGRESS_OFF)) progress_on = false;
	if (line_message.startsWith(PROGRESS_HEADER)) {
		if (progress_on) {
			if (line_message.startsWith(PROGRESS_MINIMUM)) {
				int v = line_message.right(line_message.length() - line_message.lastIndexOf(":") - 2).toInt();
				process_start.start();
				emit setProgressMinimum(v);
			}
			if (line_message.startsWith(PROGRESS_MAXIMUM)) {
				int v = line_message.right(line_message.length() - line_message.lastIndexOf(":") - 2).toInt();
				emit setProgressMaximum(v);
			}
			if (line_message.startsWith(PROGRESS_VALUE)) {
				int v = line_message.right(line_message.length() - line_message.lastIndexOf(":") - 2).toInt();
				emit setProgressValue(v);
			}
			if (line_message == PROGRESS_DONE) {
				emit setProgressMinimum(0);
				emit setProgressMaximum(1);
				emit resetProgress();
				emit setProgressStatus("Done.",1000);
				setTextColor(Qt::lightGray);
				append(line_time.toString("hh:mm:ss")+": ");
				moveCursor(QTextCursor::End);
				setTextColor(Qt::black);
				float sec = (float)process_start.elapsed()/1000;
				int min = sec / 60;
				QString start_string = last_progress_status;
				if (start_string == "") start_string = "Processing time";
				if (min>0) {
					sec = sec - min*60;
					insertPlainText(tr("%1: %2 min %3 s").arg(start_string).arg(min).arg(sec));
				} else insertPlainText(tr("%1: %2 s").arg(start_string).arg(sec));
				emit set_variable(Application_variable(tr("%1").arg(last_progress_status), QString::number((float)process_start.elapsed()/1000)));
				repaint();

			}
			if (line_message.startsWith(PROGRESS_STATUS)) {
				process_start.start();
				last_progress_status = line_message.right(line_message.length() - line_message.lastIndexOf(":") - 2);
				emit setProgressStatus(last_progress_status,0);
			}
		}
	} else {
		setTextColor(Qt::lightGray);
		append(line_time.toString("hh:mm:ss")+": ");
		moveCursor(QTextCursor::End);
		if (line_message.startsWith(LOG_ERROR)) {
			setTextColor(QColor(168,0,0));
			line_message = line_message.right((int)(line_message.size() - std::string(LOG_ERROR).size()));
			line_message = tr("%1 %2").arg("ERROR: ").arg(line_message);
		} else if (line_message.startsWith(LOG_WARNING)) {
			setTextColor(Qt::blue);
			line_message = line_message.right((int)(line_message.size() - std::string(LOG_WARNING).size()));
			line_message = tr("%1 %2").arg("WARNING: ").arg(line_message);
		} else if (line_message.startsWith(LOG_GREEN)) {
			setTextColor(QColor(0,168,0));
			line_message = line_message.right((int)(line_message.size() - std::string(LOG_GREEN).size()));
		} else if (line_message.startsWith(LOG_BLUE)) {
			setTextColor(Qt::blue);
			line_message = line_message.right((int)(line_message.size() - std::string(LOG_BLUE).size()));
		} else if (line_message.startsWith(LOG_RED)) {
			setTextColor(Qt::red);
			line_message = line_message.right((int)(line_message.size() - std::string(LOG_RED).size()));
		} else	setTextColor(Qt::black);
		insertPlainText(line_message);
//		repaint();
	}
	//#ifdef Q_WS_WIN
	//QEventLoop el(this);
	//el.processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers );	
	//#endif //Q_WS_WIN
	line_message.clear();
}