Exemple #1
0
bool Configuration::loadConfig(QString& path){
    QSettings setting(path, QSettings::IniFormat);
    setting.sync();
    this->threads_num_ = setting.value("settings/threads_num",0).toInt();
    this->queue_size_ = setting.value("settings/queue_size",0).toInt();
    this->servers_nb_ = setting.value("settings/servers_number",0).toInt();
    this->DBServers_nb_ = setting.value("settings/servers_DB_number",0).toInt();
    this->interval_ = setting.value("master_settings/interval",0).toInt();
    for(int i = 1; i<=this->servers_nb_ + this->DBServers_nb_; ++i) {
        QString ip = setting.value("serwer"+QString::number(i)+"/ip","0.0.0.0").toString();
        int portExt = setting.value("serwer"+QString::number(i)+"/portExt", 0).toInt();
        int portDB = setting.value("serwer"+QString::number(i)+"/portDB", 0).toInt();
        int portClient = setting.value("serwer"+QString::number(i)+"/portClient", 0).toInt();
        QString stype = setting.value("serwer"+QString::number(i)+"/type","srv").toString();
        SrvType type;
        if(stype == "srv"){
            type = SrvType::SRV;
        }
        else{
            if(stype == "db"){
                type = SrvType::DB;
            }
        }
        QString pubKey = setting.value("serwer"+QString::number(i)+"/key","").toString();
        SServer srv(i, ip, portExt, portDB, portClient, pubKey, type);

        addServer(srv);
    }
}
Exemple #2
0
void MainWindow::createMenu()
{
	m_appMenu = menuBar()->addMenu(tr("&Bluecherry"));
	m_browseEventsAction = m_appMenu->addAction(tr("Browse &events"), this, SLOT(showEventsWindow()));
	m_downloadManagerAction = m_appMenu->addAction(tr("Show &download manager"), this, SLOT(showDownloadsWindow()));
	m_appMenu->addSeparator();
	m_addServerAction = m_appMenu->addAction(tr("Add another server"), this, SLOT(addServer()));
	m_optionsAction = m_appMenu->addAction(tr("&Options"), this, SLOT(showOptionsDialog()));
	m_appMenu->addSeparator();
	m_quitAction = m_appMenu->addAction(tr("&Quit"), qApp, SLOT(quit()));

    m_serversMenu = menuBar()->addMenu(QString());
    updateServersMenu();

	m_liveMenu = menuBar()->addMenu(tr("&Live"));
	updateLiveMenu();

    connect(m_serverRepository, SIGNAL(serverAdded(DVRServer*)), SLOT(updateServersMenu()));
    connect(m_serverRepository, SIGNAL(serverRemoved(DVRServer*)), SLOT(updateServersMenu()));

    connect(bcApp->liveView, SIGNAL(bandwidthModeChanged(int)), SLOT(bandwidthModeChanged(int)));

	m_helpMenu = menuBar()->addMenu(tr("&Help"));
	m_documentationAction = m_helpMenu->addAction(tr("&Documentation"), this, SLOT(openDocumentation()));
	m_supportAction = m_helpMenu->addAction(tr("Bluecherry &support"), this, SLOT(openSupport()));
	m_suggestionsAction = m_helpMenu->addAction(tr("Suggest a &feature"), this, SLOT(openIdeas()));
	m_helpMenu->addSeparator();
	m_aboutAction = m_helpMenu->addAction(tr("&About Bluecherry"), this, SLOT(openAbout()));
}
Exemple #3
0
//-----------------------------------------------------------------------------
bool Root::parseServer(QDomNode& xmlnServer)
{
    Q_ASSERT(!xmlnServer.isNull());

    ServerPtr server = addServer();
    SubjectLocker locker(server.get());

    for (QDomElement xmln = xmln.firstChildElement();
		 !xmln.isNull();
		 xmln = xmln.nextSiblingElement())
    {
	    QString value = xmln.text();
        if (xmln.tagName() == QString::fromLatin1("name"))
            server->setName_(value);
        else if (xmln.tagName() == QString::fromLatin1("host"))
            server->setHostname(value);
        else if (xmln.tagName() == QString::fromLatin1("port"))
            server->setPort(value);
        else if (xmln.tagName() == QString::fromLatin1("database"))
        {
            if (!parseDatabase(server, xmln))
                return false;
        }
    }
    // backward compatibility with FR < 0.3.0
    if (server->getName_().isEmpty())
        server->setName_(server->getConnectionString());
    server->setChildrenLoaded(true);
    return true;
}
Exemple #4
0
void sansm_Add(qcom_sGet* get)
{
  gdb_sObject* op;
  gdb_sNode* np;
  san_sServer* sp;
  int i;
  net_sSanAdd* ap = get->data;

  gdb_AssumeUnlocked;

  gdb_ScopeLock
  {
    np = hash_Search(NULL, gdbroot->nid_ht, &ap->hdr.nid);
    if (np == NULL)
      break;

    for (i = 0; i < ap->count; i++) {
      op = hash_Search(NULL, gdbroot->oid_ht, &ap->sane[i].oid);
      if (op == NULL || !op->l.flags.b.isOwned)
        continue;

      sp = addServer(NULL, np, op, &ap->sane[i]);
      if (sp == NULL)
        continue;
    }
  }
  gdb_ScopeUnlock;
}
Exemple #5
0
/*
 * Test each node and build target server list
 */
void makeServerList(void)
{
	/* Initialize */
	reset_var(VAR_allServers);
	/* GTM Master */
	addServer(aval(VAR_gtmMasterServer));
	/* GTM Slave */
	if (isVarYes(VAR_gtmSlave))
		addServer(aval(VAR_gtmSlaveServer));
	/* GTM_Proxy */
	if (isVarYes(VAR_gtmProxy))
		addServer(aval(VAR_gtmProxyServers));
	/* Coordinator Master */
	if (find_var(VAR_coordMasterServers))
		addServer(aval(VAR_coordMasterServers));
	/* Coordinator Slave */
	if (isVarYes(VAR_coordSlave))
		addServer(aval(VAR_coordSlaveServers));
	/* Datanode Master */
	addServer(aval(VAR_datanodeMasterServers));
	/* Datanode Slave */
	if (isVarYes(VAR_datanodeSlave))
		addServer(aval(VAR_datanodeSlaveServers));
	/* Should add secondary slaves */
}
Exemple #6
0
		Host(Poll* p, string root): _responsePool(128) {
			this->poll=p;
			defaultServer=&server;
			addServer(&server);
			server.root=root;
			updateTime();
			t.setCallback({&Host::timerCB,this});
			p->add(t);
		}
Exemple #7
0
void MainWindow::showEvent(QShowEvent *event)
{
    if (!event->spontaneous())
    {
        if (m_serverRepository->serverCount() == 0)
            addServer();
    }
    else
        bcApp->releaseLive();

    QMainWindow::showEvent(event);
}
    ServerGroupDialog::ServerGroupDialog(const QString& title, QWidget *parent)
        : KDialog(parent)
    {
        setCaption(title);
        setButtons(Ok|Cancel);

        m_id = -1;
        m_identitiesNeedsUpdate = false;
        m_editedServer = false;

        m_mainWidget = new Ui::ServerGroupDialogUI();
        m_mainWidget->setupUi(mainWidget());
        mainWidget()->layout()->setMargin(0);
        m_mainWidget->serverWidget->layout()->setMargin(0);
        m_mainWidget->channelWidget->layout()->setMargin(0);

        connect(m_mainWidget->m_editIdentityButton, SIGNAL(clicked()), this, SLOT(editIdentity()));

        IdentityList identities = Preferences::identityList();

        for (IdentityList::ConstIterator it = identities.constBegin(); it != identities.constEnd(); ++it)
            m_mainWidget->m_identityCBox->addItem((*it)->getName());

        m_mainWidget->m_removeServerButton->setIcon(KIcon("list-remove"));
        m_mainWidget->m_upServerBtn->setIcon(KIcon("arrow-up"));
        m_mainWidget->m_downServerBtn->setIcon(KIcon("arrow-down"));

        connect(m_mainWidget->m_addServerButton, SIGNAL(clicked()), this, SLOT(addServer()));
        connect(m_mainWidget->m_changeServerButton, SIGNAL(clicked()), this, SLOT(editServer()));
        connect(m_mainWidget->m_removeServerButton, SIGNAL(clicked()), this, SLOT(deleteServer()));
        connect(m_mainWidget->m_serverLBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateServerArrows()));
        connect(m_mainWidget->m_upServerBtn, SIGNAL(clicked()), this, SLOT(moveServerUp()));
        connect(m_mainWidget->m_downServerBtn, SIGNAL(clicked()), this, SLOT(moveServerDown()));

        m_mainWidget->m_removeChannelButton->setIcon(KIcon("list-remove"));
        m_mainWidget->m_upChannelBtn->setIcon(KIcon("arrow-up"));
        m_mainWidget->m_downChannelBtn->setIcon(KIcon("arrow-down"));

        connect(m_mainWidget->m_addChannelButton, SIGNAL(clicked()), this, SLOT(addChannel()));
        connect(m_mainWidget->m_changeChannelButton, SIGNAL(clicked()), this, SLOT(editChannel()));
        connect(m_mainWidget->m_removeChannelButton, SIGNAL(clicked()), this, SLOT(deleteChannel()));
        connect(m_mainWidget->m_channelLBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateChannelArrows()));
        connect(m_mainWidget->m_upChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelUp()));
        connect(m_mainWidget->m_downChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelDown()));

        setButtonGuiItem(Ok, KGuiItem(i18n("&OK"), "dialog-ok", i18n("Change network information")));
        setButtonGuiItem(Cancel, KGuiItem(i18n("&Cancel"), "dialog-cancel", i18n("Discards all changes made")));

        m_mainWidget->m_nameEdit->setFocus();

        setInitialSize(QSize(320, 400));
    }
Exemple #9
0
serversDialog::serversDialog(QWidget *parent) : QDialog(parent) {

	setupUi(this) ;

	connect(buttonBox,SIGNAL(rejected()),this,SLOT(deleteLater())) ;
	connect(buttonBox,SIGNAL(accepted()),this,SLOT(acceptList())) ;
	connect(addButton,SIGNAL(clicked()),this,SLOT(addServer())) ;
	connect(editButton,SIGNAL(clicked()),this,SLOT(editServer())) ;
	connect(removeButton,SIGNAL(clicked()),this,SLOT(removeServer())) ;
	connect(serverList,SIGNAL(itemSelectionChanged()),this,SLOT(rowChanged())) ;

	updateServerList() ;

}
Exemple #10
0
/** The OK button callback
  *
  * It makes some tests in the server information and add it using
  * CurlServerAdd.
  *
  * \param o A parameter used for FOX callbacks
  * \param s A parameter used for FOX callbacks
  * \param v A parameter used for FOX callbacks
  *
  * \return Always 1
  *
  */
long RainbruRPG::Gui::AddServer::
onOkClicked(FXObject *o,FXSelector s,void* v){
  LOGI("OK button clicked");

  // Makes some controls
  if (controls()){   // We can add the server
    addServer();
    handle(this, FXSEL(SEL_COMMAND, FXDialogBox::ID_ACCEPT), NULL);
  }
  else{              // An error occured
    FXMessageBox::information(this, MBOX_OK, "Validation error", errorMsg);
  }
  return 1;
}
Exemple #11
0
bool Task::parseListen(const TaskConfig &tc, const std::string &log_label) {
    auto to = tc.cfg().upper_bound("listen");
    for (auto p=tc.cfg().lower_bound("listen"); p!=to; ++p) {
        std::istringstream s(p->second);
        uint16_t port;
        std::string ip;
        s >> port;
        if (!s) {
            err_log() << "Bad configuration directive: listen " << p->second;
            setError("bad configuration directive");
            return false;
        }
        s >> ip;
        bool tls;
        if (ip.empty()) {
            tls = false;
        } else if (ip == "tls") {
            ip.clear();
            tls = true;
        } else {
            std::string tmp;
            s >> tmp;
            tls = (tmp == "tls");
        }
        auto sock = new ServerSocket(log_label, this, port, ip);
#ifdef USE_GNUTLS
        if (tls) {
            std::string cert, key, password;
            s >> cert >> key >> password;
            if (key.empty() || !tlsSetKey(sock, cert, key, password)) {
                err_log() << "Bad configuration: " << p->second;
                setError("cannot use TLS certificate");
                return false;
            }
            log() << "Port " << port << " enable TLS";
        }
#else
        if (tls) {
            err_log() << "cannot enable TLS, will not listen on port " << port;
            return false;
        }
#endif
        if (!addServer(sock)) {
            setError("cannot listen");
            return false;
        }
    }
    return true;
}
Exemple #12
0
    /** Callback from the refresh request.
     *  \param success If the refresh was successful.
     *  \param input The XML data describing the server.
     */
    void ServersManager::refresh(bool success, const XMLNode *input)
    {
        if (!success)
        {
            Log::error("Server Manager", "Could not refresh server list");
            return;
        }

        const XMLNode *servers_xml = input->getNode("servers");
        cleanUpServers();
        for (unsigned int i = 0; i < servers_xml->getNumNodes(); i++)
        {
            addServer(new Server(*servers_xml->getNode(i), /*is_lan*/false));
        }
        m_last_load_time.setAtomic((float)StkTime::getRealTime());
    }   // refresh
Exemple #13
0
GomokuWindow::GomokuWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_client(new LocalClient(this))
{
    ui->setupUi(this);

    connect(ui->createServer, SIGNAL(clicked(bool)),
            this, SLOT(createServer()));

    connect(ui->message, SIGNAL(returnPressed()),
            this, SLOT(sendMessage()));

    connect(ui->sendButton, SIGNAL(clicked(bool)),
            this, SLOT(sendMessage()));

    m_serverDiscovery = new ServerDiscovery(this);
    m_server = new Server(this);

    connect(m_server, SIGNAL(serverStarted(quint16)),
            this, SLOT(addServerToDiscovery(quint16)));

    connect(m_server, SIGNAL(messageReceived(QString,QString)),
            this, SLOT(onServerMessageReceived(QString,QString)));

    connect(m_serverDiscovery,SIGNAL(serverFound(QString,quint16)),
            this, SLOT(addServer(QString,quint16)));

    connect(m_client, SIGNAL(messageReceived(QString,QString)),
            this, SLOT(addMessage(QString,QString)));

    connect(m_client, SIGNAL(connected()),
            this, SLOT(onClientConnected()));

    connect(m_client, SIGNAL(participantsReceived(QList<int>,QStringList)),
            this, SLOT(participantsOnReceived(QList<int>,QStringList)));

    m_serverDiscovery->discoveryServer();
}
Exemple #14
0
void MainWindow::updateServersMenu()
{
    m_serversMenu->clear();

    QList<DVRServer *> servers = m_serverRepository->servers();
    m_serversMenu->setTitle((servers.size() > 1) ? tr("&Servers") : tr("&Server"));

    if (servers.isEmpty())
    {
        m_serversMenu->addAction(tr("Add a server"), this, SLOT(addServer()));
        return;
    }

    if (servers.size() == 1)
    {
        QMenu *sm = serverMenu(servers.first());
        m_serversMenu->addActions(sm->actions());
        return;
    }

    qSort(servers.begin(), servers.end(), DVRServer::lessThan);
    foreach (DVRServer *s, servers)
        m_serversMenu->addMenu(serverMenu(s));
}
ServerInputDialog::ServerInputDialog( const QVector< ServerLogic::Server > &servers, QWidget *parent ) :
	QDialog( parent ),
	m_ui( new Ui::ServerInputDialog )
{
	m_ui->setupUi( this );

	connect( m_ui->buttonSave, SIGNAL( accepted() ), this, SLOT( accept() ) );
	connect( m_ui->buttonCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
	connect( m_ui->add, SIGNAL( clicked() ), this, SLOT( addServer() ) );
	connect( m_ui->remove, SIGNAL( clicked() ), this, SLOT( removeServer() ) );

	QStringList labels;
	labels << "name" << "url";
	m_ui->serverList->setHorizontalHeaderLabels( labels );
	m_ui->serverList->horizontalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents );
	m_ui->serverList->horizontalHeader()->setStretchLastSection( true );

	for ( int i = 0; i < servers.size(); i++ ) {
		m_ui->serverList->insertRow(i);
		m_ui->serverList->setItem( i, 0, new QTableWidgetItem( servers.at(i).name ) );
				m_ui->serverList->setItem( i, 1, new QTableWidgetItem( servers.at(i).url.toString( ) ) );
	}

}
Exemple #16
0
DcmtkServerDialog::DcmtkServerDialog() {
    setWindowTitle("Dicom Downloader");


    listWidget_ = new DcmtkSeriesListWidget();
    configDialog_ = new DcmtkServerConfigDialog();

    serverCombo_ = new QComboBox();
    serverCombo_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    newServerButton_ = new QPushButton("New");
    newServerButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    deleteServerButton_ = new QPushButton("Delete");
    deleteServerButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    editServerButton_ = new QPushButton("Edit");
    editServerButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    updateListButton_ = new QPushButton("Update");
    updateListButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    openButton_ = new QPushButton("Open");
    openButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    openButton_->setDisabled(true);
    outputDirectory_ = new QLineEdit("");
    outputDirectory_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    changeDirectoryButton_ = new QPushButton("...");
    changeDirectoryButton_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    loadServers();

    connect(newServerButton_, SIGNAL(clicked()), this, SLOT(addServer()));
    connect(deleteServerButton_, SIGNAL(clicked()), this, SLOT(deleteServer()));
    connect(serverCombo_, SIGNAL(currentIndexChanged(int)), this, SLOT(displayConfig(int)));
    connect(editServerButton_, SIGNAL(clicked()), this, SLOT(editConfig()));
    connect(updateListButton_, SIGNAL(clicked()), this, SLOT(updateList()));
    connect(openButton_, SIGNAL(clicked()), this, SLOT(open()));
    connect(listWidget_, SIGNAL(seriesSelected()), this, SLOT(enableOpenButton()));
#ifdef VRN_DICOMLOADER
    connect(changeDirectoryButton_, SIGNAL(clicked()), this, SLOT(selectOutputDir()));
#endif
    QGridLayout *layout = new QGridLayout;

    layout->addWidget(new QLabel("Server:"),0,0,(Qt::Alignment)0);
    layout->addWidget(serverCombo_,0,1,(Qt::Alignment)0);
    fillCombo();
    layout->addWidget(editServerButton_,0,2,(Qt::Alignment)0);
    layout->addWidget(newServerButton_,0,3,(Qt::Alignment)0);
    layout->addWidget(deleteServerButton_,0,4,(Qt::Alignment)0);
    layout->addWidget(listWidget_,1,0,1,5,(Qt::Alignment)0);
    layout->addWidget(updateListButton_,2,3,1,1,(Qt::Alignment)0);
    layout->addWidget(openButton_,2,4,1,1,(Qt::Alignment)0);
#ifdef VRN_DICOMLOADER
    layout->addWidget(new QLabel("Output Directory:"),4,0,(Qt::Alignment)0);
    layout->addWidget(outputDirectory_,4,1,1,3,(Qt::Alignment)0);
    layout->addWidget(changeDirectoryButton_,4,4,1,1,(Qt::Alignment)0);
#endif

    listWidget_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    setLayout(layout);
//     if (servers_.size() > 0)
//         displayConfig(servers_[0]);

    dt_ = 0;
}
ServerChoice::ServerChoice(TeamHolder* team) :
    ui(new Ui::ServerChoice), wasConnected(false), team(team)
{
    ui->setupUi(this);
    ui->announcement->hide();

    ServerChoiceModel *model = new ServerChoiceModel();
    model->setParent(ui->serverList);
    filter = new QSortFilterProxyModel(ui->serverList);
    filter->setSourceModel(model);
    filter->setSortRole(ServerChoiceModel::SortRole);
    ui->serverList->setModel(filter);

    connect(ui->description, SIGNAL(anchorClicked(QUrl)), SLOT(anchorClicked(QUrl)));

    QSettings settings;

    registry_connection = new Analyzer(true);
    connect(registry_connection, SIGNAL(connected()), SLOT(connected()));

    registry_connection->connectTo(
        settings.value("ServerChoice/RegistryServer", "registry.pokemon-online.eu").toString(),
        settings.value("ServerChoice/RegistryPort", 5090).toUInt()
    );
    registry_connection->setParent(this);

    ui->switchPort->setIcon(QApplication::style()->standardIcon(QStyle::SP_BrowserReload));

    connect(registry_connection, SIGNAL(connectionError(int,QString)), SLOT(connectionError(int , QString)));
    connect(registry_connection, SIGNAL(regAnnouncementReceived(QString)), ui->announcement, SLOT(setText(QString)));
    connect(registry_connection, SIGNAL(regAnnouncementReceived(QString)), ui->announcement, SLOT(show()));

    connect(registry_connection, SIGNAL(serverReceived(ServerInfo)), model, SLOT(addServer(ServerInfo)));
    connect(this, SIGNAL(clearList()), model, SLOT(clear()));
    connect(registry_connection, SIGNAL(serverReceived(ServerInfo)), SLOT(serverAdded()));

    //TO-DO: Make  the item 0 un-resizable and unselectable - Latios

    ui->serverList->setColumnWidth(0, settings.value("ServerChoice/PasswordProtectedWidth", 26).toInt());
    ui->serverList->setColumnWidth(1, settings.value("ServerChoice/ServerNameWidth", 152).toInt());
    if (settings.contains("ServerChoice/PlayersInfoWidth")) {
        ui->serverList->setColumnWidth(2, settings.value("ServerChoice/PlayersInfoWidth").toInt());
    }
    ui->serverList->horizontalHeader()->setStretchLastSection(true);

    connect(ui->serverList, SIGNAL(activated(QModelIndex)), SLOT(regServerChosen(QModelIndex)));
    connect(ui->serverList, SIGNAL(currentCellChanged(QModelIndex)), SLOT(showDetails(QModelIndex)));

    ui->nameEdit->setText(team->name());
    ui->advServerEdit->addItem(settings.value("ServerChoice/DefaultServer").toString());

    connect(ui->nameEdit, SIGNAL(returnPressed()), SLOT(advServerChosen()));
    connect(ui->advServerEdit->lineEdit(), SIGNAL(returnPressed()), SLOT(advServerChosen()));

    QCompleter *completer = new QCompleter(ui->advServerEdit);
    completer->setCaseSensitivity(Qt::CaseInsensitive);
    QStringList res = settings.value("ServerChoice/SavedServers").toStringList();

    foreach (QString r, res) {
        if (r.contains("-")) {
            savedServers.push_back(QStringList() << r.section("-", -1).trimmed() << r.section("-", 0, -2).trimmed());
        } else {
            savedServers.push_back(QStringList() << r << "");
        }
    }

    QStringListModel *m = new QStringListModel(res, completer);

    completer->setModel(m);
    ui->advServerEdit->setCompleter(completer);
    ui->advServerEdit->setModel(m);

    connect(ui->teambuilder, SIGNAL(clicked()), SIGNAL(teambuilder()));
    connect(ui->advancedConnection, SIGNAL(clicked()), SLOT(advServerChosen()));

    QTimer *t = new QTimer(this);
    t->singleShot(5000, this, SLOT(timeout()));

#if QT_VERSION >= QT_VERSION_CHECK(4,8,0)
    ui->serverList->sortByColumn(ServerChoiceModel::Players, Qt::SortOrder(filter->headerData(ServerChoiceModel::Players, Qt::Horizontal, Qt::InitialSortOrderRole).toInt()));
#else
    ui->serverList->sortByColumn(ServerChoiceModel::Players, Qt::DescendingOrder);
#endif
}
Exemple #18
0
void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &location )
{
    if ( !doc )
    {
        msg_Err( m_sd, "Null IXML_Document" );
        return;
    }

    if ( location.empty() )
    {
        msg_Err( m_sd, "Empty location" );
        return;
    }

    const char* psz_base_url = location.c_str();

    /* Try to extract baseURL */
    IXML_NodeList* p_url_list = ixmlDocument_getElementsByTagName( doc, "URLBase" );
    if ( p_url_list )
    {
        if ( IXML_Node* p_url_node = ixmlNodeList_item( p_url_list, 0 ) )
        {
            IXML_Node* p_text_node = ixmlNode_getFirstChild( p_url_node );
            if ( p_text_node )
                psz_base_url = ixmlNode_getNodeValue( p_text_node );
        }
        ixmlNodeList_free( p_url_list );
    }

    /* Get devices */
    IXML_NodeList* p_device_list = ixmlDocument_getElementsByTagName( doc, "device" );

    if ( !p_device_list )
        return;

    for ( unsigned int i = 0; i < ixmlNodeList_length( p_device_list ); i++ )
    {
        IXML_Element* p_device_element = ( IXML_Element* ) ixmlNodeList_item( p_device_list, i );

        if( !p_device_element )
            continue;

        const char* psz_device_type = xml_getChildElementValue( p_device_element, "deviceType" );

        if ( !psz_device_type )
        {
            msg_Warn( m_sd, "No deviceType found!" );
            continue;
        }

        if ( strncmp( MEDIA_SERVER_DEVICE_TYPE, psz_device_type,
                      strlen( MEDIA_SERVER_DEVICE_TYPE ) - 1 )
                && strncmp( SATIP_SERVER_DEVICE_TYPE, psz_device_type,
                            strlen( SATIP_SERVER_DEVICE_TYPE ) - 1 ) )
            continue;

        const char* psz_udn = xml_getChildElementValue( p_device_element,
                              "UDN" );
        if ( !psz_udn )
        {
            msg_Warn( m_sd, "No UDN!" );
            continue;
        }

        /* Check if server is already added */
        if ( getServer( psz_udn ) )
        {
            msg_Warn( m_sd, "Server with uuid '%s' already exists.", psz_udn );
            continue;
        }

        const char* psz_friendly_name =
            xml_getChildElementValue( p_device_element,
                                      "friendlyName" );

        if ( !psz_friendly_name )
        {
            msg_Dbg( m_sd, "No friendlyName!" );
            continue;
        }

        std::string iconUrl = getIconURL( p_device_element, psz_base_url );

        // We now have basic info, we need to get the content browsing url
        // so the access module can browse without fetching the manifest again

        if ( !strncmp( SATIP_SERVER_DEVICE_TYPE, psz_device_type,
                       strlen( SATIP_SERVER_DEVICE_TYPE ) - 1 ) )
        {
            SD::MediaServerDesc* p_server = NULL;

            vlc_url_t url;
            vlc_UrlParse( &url, psz_base_url );

            char *psz_satip_channellist = config_GetPsz(m_sd, "satip-channelist");
            if( !psz_satip_channellist ) {
                break;
            }

            /* a user may have provided a custom playlist url */
            if (strncmp(psz_satip_channellist, "CustomList", 10) == 0) {
                char *psz_satip_playlist_url = config_GetPsz( m_sd, "satip-channellist-url" );
                if ( psz_satip_playlist_url ) {
                    p_server = new(std::nothrow) SD::MediaServerDesc( psz_udn, psz_friendly_name, psz_satip_playlist_url, iconUrl );

                    if( likely( p_server ) ) {
                        p_server->satIpHost = url.psz_host;
                        p_server->isSatIp = true;
                        if( !addServer( p_server ) ) {
                            delete p_server;
                        }
                    }

                    /* to comply with the SAT>IP specification, we don't fall back on another channel list if this path failed */
                    free( psz_satip_playlist_url );
                    vlc_UrlClean( &url );
                    continue;
                }
            }

            /* If requested by the user, check for a SAT>IP m3u list, which may be provided by some rare devices */
            if (strncmp(psz_satip_channellist, "ServerList", 10) == 0) {
                const char* psz_m3u_url = xml_getChildElementValue( p_device_element, "satip:X_SATIPM3U" );
                if ( psz_m3u_url ) {
                    if ( strncmp( "http", psz_m3u_url, 4) )
                    {
                        char* psz_url = NULL;
                        if ( UpnpResolveURL2( psz_base_url, psz_m3u_url, &psz_url ) == UPNP_E_SUCCESS )
                        {
                            p_server = new(std::nothrow) SD::MediaServerDesc( psz_udn, psz_friendly_name, psz_url, iconUrl );
                            free(psz_url);
                        }
                    } else {
                        p_server = new(std::nothrow) SD::MediaServerDesc( psz_udn, psz_friendly_name, psz_m3u_url, iconUrl );
                    }

                    if ( unlikely( !p_server ) )
                        break;

                    p_server->satIpHost = url.psz_host;
                    p_server->isSatIp = true;
                    if ( !addServer( p_server ) )
                        delete p_server;

                    free(psz_satip_channellist);
                } else {
                    msg_Warn( m_sd, "SAT>IP server '%s' did not provide a playlist", url.psz_host);
                }

                /* to comply with the SAT>IP specifications, we don't fallback on another channel list if this path failed */
                vlc_UrlClean( &url );
                continue;
            }

            /* Normally, fetch a playlist from the web,
             * which will be processed by a lua script a bit later */
            char *psz_url;
            if (asprintf( &psz_url, "http://www.satip.info/Playlists/%s.m3u",
                          psz_satip_channellist ) < 0 ) {
                vlc_UrlClean( &url );
                free( psz_satip_channellist );
                continue;
            }

            p_server = new(std::nothrow) SD::MediaServerDesc( psz_udn,
                    psz_friendly_name, psz_url, iconUrl );

            if( likely( p_server ) ) {
                p_server->satIpHost = url.psz_host;
                p_server->isSatIp = true;
                if( !addServer( p_server ) ) {
                    delete p_server;
                }
            }
            free( psz_url );
            free( psz_satip_channellist );
            vlc_UrlClean( &url );

            continue;
        }

        /* Check for ContentDirectory service. */
        IXML_NodeList* p_service_list = ixmlElement_getElementsByTagName( p_device_element, "service" );
        if ( !p_service_list )
            continue;
        for ( unsigned int j = 0; j < ixmlNodeList_length( p_service_list ); j++ )
        {
            IXML_Element* p_service_element = (IXML_Element*)ixmlNodeList_item( p_service_list, j );

            const char* psz_service_type = xml_getChildElementValue( p_service_element, "serviceType" );
            if ( !psz_service_type )
            {
                msg_Warn( m_sd, "No service type found." );
                continue;
            }

            int k = strlen( CONTENT_DIRECTORY_SERVICE_TYPE ) - 1;
            if ( strncmp( CONTENT_DIRECTORY_SERVICE_TYPE,
                          psz_service_type, k ) )
                continue;

            const char* psz_control_url = xml_getChildElementValue( p_service_element,
                                          "controlURL" );
            if ( !psz_control_url )
            {
                msg_Warn( m_sd, "No control url found." );
                continue;
            }

            /* Try to browse content directory. */
            char* psz_url = ( char* ) malloc( strlen( psz_base_url ) + strlen( psz_control_url ) + 1 );
            if ( psz_url )
            {
                if ( UpnpResolveURL( psz_base_url, psz_control_url, psz_url ) == UPNP_E_SUCCESS )
                {
                    SD::MediaServerDesc* p_server = new(std::nothrow) SD::MediaServerDesc( psz_udn,
                            psz_friendly_name, psz_url, iconUrl );
                    free( psz_url );
                    if ( unlikely( !p_server ) )
                        break;

                    if ( !addServer( p_server ) )
                    {
                        delete p_server;
                        continue;
                    }
                }
                else
                    free( psz_url );
            }
        }
        ixmlNodeList_free( p_service_list );
    }
    ixmlNodeList_free( p_device_list );
}
Exemple #19
0
ret_code ServerList::work(const TimeDuration &elapsed)
{
    m_btnJoindre->setEnabled(m_selectedServer);
    switch (m_type)
    {
        case LAN:
        {
            if(!m_connection_udp->isConnected())
                return CONTINUE;
            if(m_connection_udp->hasError())
            {
                std::cout << std::endl << m_connection_udp->getError().message() << std::endl;
                return CONTINUE;
            }
            Packet packet;
            while(m_connection_udp->hasData())
            {
                EngineMessage *message;
                m_connection_udp->fillPacket(packet);
                std::uint8_t messageType;
                packet >> messageType;
                if(messageType == mf::MESSAGE)
                {
                    message = new EngineMessage(nullptr, packet);
                    if(message->message==mf::EngineMessageType::SERVER_INFO)
                    {
                        Server *s =  new Server(packet.sender.to_string(),
                                                std::string(message->strings[mf::EngineMessageKey::SERVER_NAME]),
                                std::string(""),
                                message->ints[mf::EngineMessageKey::MAX_PLAYERS],
                                message->ints[mf::EngineMessageKey::PLAYER_NUMBER],
                                false,
                                std::string(message->strings[mf::EngineMessageKey::MAP_NAME]),
                                std::string(""),
                                0.0
                                );
                        addServer(s);
                    }
                    delete message;
                }
            }
        }
        break;
        case WAN:
        {
            if (!m_connection_ssl->isConnected())
                return CONTINUE;
            if (m_connection_ssl->hasError())
            {
                std::cout << std::endl << m_connection_ssl->getError().message() << std::endl;
                return CONTINUE;
            }
            while(m_connection_ssl->hasData())
            {
                ServerGlobalMessage* message;
                message = m_deserialize(m_connection_ssl->getData());
                for (Server s : message->servers)
                    addServer(new Server(s));

                delete message;
            }
        }
        break;
    }
    return (m_retour) ?ret_code::FINISHED:ret_code::CONTINUE;
}
Exemple #20
0
void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &location )
{
    if ( !doc )
    {
        msg_Err( p_sd_, "Null IXML_Document" );
        return;
    }

    if ( location.empty() )
    {
        msg_Err( p_sd_, "Empty location" );
        return;
    }

    const char* psz_base_url = location.c_str();

    /* Try to extract baseURL */
    IXML_NodeList* p_url_list = ixmlDocument_getElementsByTagName( doc, "URLBase" );
    if ( p_url_list )
    {
        if ( IXML_Node* p_url_node = ixmlNodeList_item( p_url_list, 0 ) )
        {
            IXML_Node* p_text_node = ixmlNode_getFirstChild( p_url_node );
            if ( p_text_node )
                psz_base_url = ixmlNode_getNodeValue( p_text_node );
        }
        ixmlNodeList_free( p_url_list );
    }

    /* Get devices */
    IXML_NodeList* p_device_list = ixmlDocument_getElementsByTagName( doc, "device" );

    if ( !p_device_list )
        return;
    for ( unsigned int i = 0; i < ixmlNodeList_length( p_device_list ); i++ )
    {
        IXML_Element* p_device_element = ( IXML_Element* ) ixmlNodeList_item( p_device_list, i );

        if( !p_device_element )
            continue;

        const char* psz_device_type = xml_getChildElementValue( p_device_element, "deviceType" );

        if ( !psz_device_type )
        {
            msg_Warn( p_sd_, "No deviceType found!" );
            continue;
        }

        if ( strncmp( MEDIA_SERVER_DEVICE_TYPE, psz_device_type,
                strlen( MEDIA_SERVER_DEVICE_TYPE ) - 1 ) )
            continue;

        const char* psz_udn = xml_getChildElementValue( p_device_element,
                                                        "UDN" );
        if ( !psz_udn )
        {
            msg_Warn( p_sd_, "No UDN!" );
            continue;
        }

        /* Check if server is already added */
        if ( p_sd_->p_sys->p_server_list->getServer( psz_udn ) )
        {
            msg_Warn( p_sd_, "Server with uuid '%s' already exists.", psz_udn );
            continue;
        }

        const char* psz_friendly_name =
                   xml_getChildElementValue( p_device_element,
                                             "friendlyName" );

        if ( !psz_friendly_name )
        {
            msg_Dbg( p_sd_, "No friendlyName!" );
            continue;
        }

        // We now have basic info, we need to get the content browsing url
        // so the access module can browse without fetching the manifest again

        /* Check for ContentDirectory service. */
        IXML_NodeList* p_service_list = ixmlElement_getElementsByTagName( p_device_element, "service" );
        if ( !p_service_list )
            continue;
        for ( unsigned int j = 0; j < ixmlNodeList_length( p_service_list ); j++ )
        {
            IXML_Element* p_service_element = (IXML_Element*)ixmlNodeList_item( p_service_list, j );

            const char* psz_service_type = xml_getChildElementValue( p_service_element, "serviceType" );
            if ( !psz_service_type )
            {
                msg_Warn( p_sd_, "No service type found." );
                continue;
            }

            int k = strlen( CONTENT_DIRECTORY_SERVICE_TYPE ) - 1;
            if ( strncmp( CONTENT_DIRECTORY_SERVICE_TYPE,
                        psz_service_type, k ) )
                continue;

            const char* psz_control_url = xml_getChildElementValue( p_service_element,
                                          "controlURL" );
            if ( !psz_control_url )
            {
                msg_Warn( p_sd_, "No control url found." );
                continue;
            }

            /* Try to browse content directory. */
            char* psz_url = ( char* ) malloc( strlen( psz_base_url ) + strlen( psz_control_url ) + 1 );
            if ( psz_url )
            {
                if ( UpnpResolveURL( psz_base_url, psz_control_url, psz_url ) == UPNP_E_SUCCESS )
                {
                    SD::MediaServerDesc* p_server = new(std::nothrow) SD::MediaServerDesc( psz_udn,
                            psz_friendly_name, psz_url );
                    free( psz_url );
                    if ( unlikely( !p_server ) )
                        break;

                    if ( !addServer( p_server ) )
                    {
                        delete p_server;
                        continue;
                    }
                }
                else
                    free( psz_url );
            }
        }
        ixmlNodeList_free( p_service_list );
    }
    ixmlNodeList_free( p_device_list );
}
Exemple #21
0
//-----------------------------------------------------------------------------
ServerPtr Root::addServer()
{
    ServerPtr server(new Server());
    addServer(server);
    return server;
}
Exemple #22
0
ServerChoice::ServerChoice()
{
    resize(500,450);

    registry_connection = new Analyzer(true);
    registry_connection->connectTo("pokemon-online.dynalias.net", 5081);
    registry_connection->setParent(this);

    connect(registry_connection, SIGNAL(connectionError(int,QString)), SLOT(connectionError(int , QString)));
    connect(registry_connection, SIGNAL(serverReceived(QString, QString, quint16,QString,quint16,quint16)), SLOT(addServer(QString, QString, quint16, QString,quint16,quint16)));

    QVBoxLayout *l = new QVBoxLayout(this);
    mylist = new QCompactTable(0,3);

    QStringList horHeaders;
    horHeaders << tr("Server Name") << tr("Players / Max") << tr("Advanced connection");
    mylist->setHorizontalHeaderLabels(horHeaders);
    mylist->setSelectionBehavior(QAbstractItemView::SelectRows);
    mylist->setSelectionMode(QAbstractItemView::SingleSelection);
    mylist->setShowGrid(false);
    mylist->verticalHeader()->hide();
    mylist->horizontalHeader()->resizeSection(0, 150);
    mylist->horizontalHeader()->setStretchLastSection(true);
    mylist->setMinimumHeight(200);

    connect(mylist, SIGNAL(cellActivated(int,int)), SLOT(regServerChosen(int)));
    connect(mylist, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(showDescription(int)));

    l->addWidget(mylist, 100);

    myDesc = new QTextBrowser();
    myDesc->setOpenExternalLinks(true);
    myDesc->setFixedHeight(100);
    l->addWidget(new QEntitled("Server Description", myDesc));

    QSettings settings;
    myAdvServer = new QLineEdit(settings.value("default_server").toString());
    connect(myAdvServer, SIGNAL(returnPressed()), SLOT(advServerChosen()));

    l->addWidget(new QEntitled("&Advanced Connection", myAdvServer));

    QHBoxLayout *hl= new QHBoxLayout();
    l->addLayout(hl);

    QPushButton *cancel = new QPushButton("&Go Back");
    QPushButton *ok = new QPushButton("Advanced &Connection");

    connect(cancel, SIGNAL(clicked()), SIGNAL(rejected()));
    connect(ok, SIGNAL(clicked()), SLOT(advServerChosen()));

    hl->addWidget(cancel);
    hl->addWidget(ok);
}