Ejemplo n.º 1
0
ComponentSignalInstance::ComponentSignalInstance(Circuit& circuit, ComponentInstance& cmpInstance,
                                                 const XmlDomElement& domElement) throw (Exception) :
    QObject(nullptr), mCircuit(circuit), mComponentInstance(cmpInstance),
    mComponentSignal(nullptr), mNetSignal(nullptr), mAddedToCircuit(false)
{
    // read attributes
    Uuid compSignalUuid = domElement.getAttribute<Uuid>("comp_signal", true);
    mComponentSignal = mComponentInstance.getLibComponent().getSignalByUuid(compSignalUuid);
    if(!mComponentSignal)
    {
        throw RuntimeError(__FILE__, __LINE__, compSignalUuid.toStr(), QString(
            tr("Invalid component signal UUID: \"%1\"")).arg(compSignalUuid.toStr()));
    }
    Uuid netsignalUuid = domElement.getAttribute<Uuid>("netsignal", false, Uuid());
    if (!netsignalUuid.isNull())
    {
        mNetSignal = mCircuit.getNetSignalByUuid(netsignalUuid);
        if(!mNetSignal)
        {
            throw RuntimeError(__FILE__, __LINE__, netsignalUuid.toStr(),
                QString(tr("Invalid netsignal UUID: \"%1\"")).arg(netsignalUuid.toStr()));
        }
    }

    init();
}
Ejemplo n.º 2
0
void Entry::setIcon(const Uuid& uuid)
{
    Q_ASSERT(!uuid.isNull());

    if (m_data.customIcon != uuid) {
        m_data.customIcon = uuid;
        m_data.iconNumber = 0;

        Q_EMIT modified();
        emitDataChanged();
    }
}
Ejemplo n.º 3
0
void Metadata::addCustomIcon(const Uuid& uuid, const QImage& icon)
{
    Q_ASSERT(!uuid.isNull());
    Q_ASSERT(!m_customIcons.contains(uuid));

    m_customIcons.insert(uuid, icon);
    // reset cache in case there is also an icon with that uuid
    m_customIconCacheKeys[uuid] = QPixmapCache::Key();
    m_customIconScaledCacheKeys[uuid] = QPixmapCache::Key();
    m_customIconsOrder.append(uuid);
    Q_ASSERT(m_customIcons.count() == m_customIconsOrder.count());
    Q_EMIT modified();
}
Ejemplo n.º 4
0
void Group::setIcon(const Uuid& uuid)
{
    Q_ASSERT(!uuid.isNull());

    if (m_data.customIcon != uuid) {
        m_data.customIcon = uuid;
        m_data.iconNumber = 0;

        updateTimeinfo();
        Q_EMIT modified();
        Q_EMIT dataChanged(this);
    }
}
Ejemplo n.º 5
0
void Metadata::removeCustomIcon(const Uuid& uuid)
{
    Q_ASSERT(!uuid.isNull());
    Q_ASSERT(m_customIcons.contains(uuid));

    m_customIcons.remove(uuid);
    QPixmapCache::remove(m_customIconCacheKeys.value(uuid));
    m_customIconCacheKeys.remove(uuid);
    QPixmapCache::remove(m_customIconScaledCacheKeys.value(uuid));
    m_customIconScaledCacheKeys.remove(uuid);
    m_customIconsOrder.removeAll(uuid);
    Q_ASSERT(m_customIcons.count() == m_customIconsOrder.count());
    Q_EMIT modified();
}
void CDspIOCtClientHandler::handleToDispatcherPackage (
		const IOSender::Handle& h,
		const SmartPtr<IOPackage>& p )
{

	if ( p->header.type == PET_IO_CLI_AUTHENTICATE_EXEC_SESSION ) {
		const PRL_IO_AUTH_EXEC_REQUEST *authRequest =
			reinterpret_cast<const PRL_IO_AUTH_EXEC_REQUEST*>( p->buffers[0].getImpl() );

		if ( p->data[0].bufferSize < sizeof(*authRequest) ) {
			WRITE_TRACE(DBG_FATAL, "Wrong auth session package!");
			CDspService::instance()->getIOServer().disconnectClient( h );
			return;
		}

		Uuid sessionId = Uuid::toUuid( authRequest->sessionUuid );
		if ( sessionId.isNull() ) {
			WRITE_TRACE(DBG_FATAL, "Wrong auth session package!");
			CDspService::instance()->getIOServer().disconnectClient( h );
			return;
		}

		// Try to find client by auth session
		SmartPtr<CDspClient> client = CDspService::instance()->
			getClientManager().getUserSession( sessionId.toString() );

		bool auth = client.isValid();

		PRL_IO_AUTH_RESPONSE authResp = { auth };
		SmartPtr<IOPackage> pkg =
			IOPackage::createInstance( PET_IO_AUTH_RESPONSE,
									   IOPackage::RawEncoding,
									   &authResp, sizeof(authResp) );
		// Save result
		QMutexLocker locker( &m_mutex );

		ClientInfo cliInfo;
		m_ioClients[h] = cliInfo;

		locker.unlock();

		// Send package
		IOSendJob::Handle job =
			CDspService::instance()->getIOServer().sendPackage( h, pkg );
		IOSendJob::Result res =
			CDspService::instance()->getIOServer().waitForSend( job );

		// Close connection if fail
		if ( ! auth || res != IOSendJob::Success ) {
			WRITE_TRACE(DBG_FATAL, "Error: %s", (! auth ? "authentication failed!" :
						"send of authentication pkg failed!"));
			CDspService::instance()->getIOServer().disconnectClient( h );
		}

		return;
	} else if (p->header.type == PET_IO_STDIN_PORTION ||
			p->header.type == PET_IO_STDIN_WAS_CLOSED ||
			p->header.type == PET_IO_CLIENT_PROCESSED_ALL_DESCS_DATA)
	{
		if (!getIOUserSession(h)) {
			WRITE_TRACE(DBG_FATAL, "Client '%s' is not authed! Close connection!",
					QSTR2UTF8(h));
			CDspService::instance()->getIOServer().disconnectClient( h );
			return;
		}

		SmartPtr<CDspCtResponseHandler> hResponse = getResponseHandler(h,
				Uuid::toString(p->header.parentUuid));
		if (!hResponse) {
			WRITE_TRACE(DBG_FATAL, "Client %s guest session %s is not created pkt.type=%d",
					QSTR2UTF8(h),
					QSTR2UTF8((Uuid::toString(p->header.parentUuid))),
					p->header.type);
			CDspService::instance()->getIOServer().disconnectClient( h );
			return;
		}
		hResponse->process(p);
	}
}
Ejemplo n.º 7
0
void XmlDomElement::setAttribute(const QString& name, const Uuid& value) noexcept
{
    setAttribute<QString>(name, value.isNull() ? "" : value.toStr());
}
Ejemplo n.º 8
0
void Entry::setUuid(const Uuid& uuid)
{
    Q_ASSERT(!uuid.isNull());
    set(m_uuid, uuid);
}
Ejemplo n.º 9
0
void DatabaseTabWidget::checkReloadDatabases()
{
    QSet<QString> changedFiles;

    changedFiles = m_changedFiles.subtract(m_expectedFileChanges);
    m_changedFiles.clear();

    if (changedFiles.isEmpty())
        return;

    Q_FOREACH (DatabaseManagerStruct dbStruct, m_dbList) {
        QString filePath = dbStruct.filePath;
        Database * db = dbStruct.dbWidget->database();

        if (!changedFiles.contains(filePath))
            continue;

        QFileInfo fi(filePath);
        QDateTime lastModified = fi.lastModified();
        if (dbStruct.lastModified == lastModified)
            continue;

        DatabaseWidget::Mode mode = dbStruct.dbWidget->currentMode();
        if (mode == DatabaseWidget::None || mode == DatabaseWidget::LockedMode || !db->hasKey())
            continue;

        ReloadBehavior reloadBehavior = ReloadBehavior(config()->get("ReloadBehavior").toInt());
        if (   (reloadBehavior == AlwaysAsk)
            || (reloadBehavior == ReloadUnmodified && mode == DatabaseWidget::EditMode)
            || (reloadBehavior == ReloadUnmodified && dbStruct.modified)) {
            int res = QMessageBox::warning(this, fi.exists() ? tr("Database file changed") : tr("Database file removed"),
                                           tr("Do you want to discard your changes and reload?"),
                                           QMessageBox::Yes|QMessageBox::No);
            if (res == QMessageBox::No)
                continue;
        }

        if (fi.exists()) {
            //Ignore/cancel all edits
            dbStruct.dbWidget->switchToView(false);
            dbStruct.modified = false;

            //Save current group/entry
            Uuid currentGroup;
            if (Group* group = dbStruct.dbWidget->currentGroup())
                currentGroup = group->uuid();
            Uuid currentEntry;
            if (Entry* entry = dbStruct.dbWidget->entryView()->currentEntry())
                currentEntry = entry->uuid();
            QString searchText = dbStruct.dbWidget->searchText();
            bool caseSensitive = dbStruct.dbWidget->caseSensitiveSearch();
            bool allGroups =     dbStruct.dbWidget->isAllGroupsSearch();

            //Reload updated db
            CompositeKey key = db->key();
            int tabPos = databaseIndex(db);
            closeDatabase(db);
            openDatabase(filePath, QString(), QString(), key, tabPos);

            //Restore current group/entry
            dbStruct = indexDatabaseManagerStruct(count() - 1);
            if (dbStruct.dbWidget && dbStruct.dbWidget->currentMode() == DatabaseWidget::ViewMode) {
                Database * db = dbStruct.dbWidget->database();
                if (!currentGroup.isNull())
                    if (Group* group = db->resolveGroup(currentGroup))
                        dbStruct.dbWidget->groupView()->setCurrentGroup(group);
                if (!searchText.isEmpty())
                    dbStruct.dbWidget->search(searchText, caseSensitive, allGroups);
                if (!currentEntry.isNull())
                    if (Entry* entry = db->resolveEntry(currentEntry))
                        dbStruct.dbWidget->entryView()->setCurrentEntry(entry);
            }
        } else {
            //Ignore/cancel all edits
            dbStruct.dbWidget->switchToView(false);
            dbStruct.modified = false;

            //Close database
            closeDatabase(dbStruct.dbWidget->database());
        }
    }