Exemplo n.º 1
0
RemoteDialog::RemoteDialog(QWidget *parent) :
    QDialog(parent),
    m_ui(new Ui::RemoteDialog),
    m_remoteModel(new RemoteModel(GitPlugin::instance()->gitClient(), this)),
    m_addDialog(0)
{
    setModal(false);
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
    setAttribute(Qt::WA_DeleteOnClose, true); // Do not update unnecessarily

    m_ui->setupUi(this);

    m_ui->remoteView->setModel(m_remoteModel);
    m_ui->remoteView->horizontalHeader()->setStretchLastSection(true);
    m_ui->remoteView->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
    QFontMetrics fm(font());
    m_ui->remoteView->verticalHeader()->setDefaultSectionSize(qMax(static_cast<int>(fm.height() * 1.2), fm.height() + 4));

    connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addRemote()));
    connect(m_ui->fetchButton, SIGNAL(clicked()), this, SLOT(fetchFromRemote()));
    connect(m_ui->pushButton, SIGNAL(clicked()), this, SLOT(pushToRemote()));
    connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(removeRemote()));
    connect(m_ui->refreshButton, SIGNAL(clicked()), this, SLOT(refreshRemotes()));

    connect(m_ui->remoteView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SLOT(updateButtonState()));

    updateButtonState();
}
Exemplo n.º 2
0
OkState
RpcServerManager::addRemote(const std::string & name, const std::string &spec)
{
    OkState valid = validateName(name);
    if (valid.failed()) return valid;

    if (alreadyManaged(name, spec)) {
        return OkState(0, "already correct");
    }
    const NamedService *old = _rpcsrvmap.lookup(name);
    if (old != nullptr) {
        if (old->getSpec() !=  spec) {
            LOG(warning, "collision on remote add: name %s registered to %s locally, "
                "but another location broker wants it registered to %s",
                name.c_str(), old->getSpec().c_str(), spec.c_str());
            removeRemote(name, old->getSpec());
            return OkState(13, "registered, with different spec");
        }
        // was alright already, remove reservation
        _rpcsrvmap.removeReservation(name);
        return OkState(0, "already correct");
    }
    _rpcsrvmap.removeReservation(name);
    auto rpcsrv = std::make_unique<ManagedRpcServer>(name, spec, *this);
    ManagedRpcServer & rpcServer = *rpcsrv;
    _rpcsrvmap.addNew(std::move(rpcsrv));
    rpcServer.healthCheck();
    return OkState(0, "done");
}