EngineShoutcast::EngineShoutcast(ConfigObject<ConfigValue>* _config) : m_pTextCodec(NULL), m_pMetaData(), m_pShout(NULL), m_pShoutMetaData(NULL), m_iMetaDataLife(0), m_iShoutStatus(0), m_iShoutFailures(0), m_pConfig(_config), m_encoder(NULL), m_pShoutcastNeedUpdateFromPrefs(NULL), m_pUpdateShoutcastFromPrefs(NULL), m_pMasterSamplerate(new ControlObjectSlave("[Master]", "samplerate")), m_pShoutcastStatus(new ControlObject(ConfigKey(SHOUTCAST_PREF_KEY, "status"))), m_bQuit(false), m_custom_metadata(false), m_firstCall(false), m_format_is_mp3(false), m_format_is_ov(false), m_protocol_is_icecast1(false), m_protocol_is_icecast2(false), m_protocol_is_shoutcast(false), m_ogg_dynamic_update(false) { #ifndef __WINDOWS__ // Ignore SIGPIPE signals that we get when the remote streaming server // disconnects. signal(SIGPIPE, SIG_IGN); #endif m_pShoutcastStatus->set(SHOUTCAST_DISCONNECTED); m_pShoutcastNeedUpdateFromPrefs = new ControlObject( ConfigKey(SHOUTCAST_PREF_KEY,"update_from_prefs")); m_pUpdateShoutcastFromPrefs = new ControlObjectSlave( m_pShoutcastNeedUpdateFromPrefs->getKey()); // Initialize libshout shout_init(); if (!(m_pShout = shout_new())) { errorDialog(tr("Mixxx encountered a problem"), tr("Could not allocate shout_t")); return; } if (!(m_pShoutMetaData = shout_metadata_new())) { errorDialog(tr("Mixxx encountered a problem"), tr("Could not allocate shout_metadata_t")); return; } if (shout_set_nonblocking(m_pShout, 1) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting non-blocking mode:"), shout_get_error(m_pShout)); return; } }
//------------------------------------------------------------------- void NewProjectDialog::onOk(wxCommandEvent& event) { // get window width wxString windowWidthStr = _windowWidthEntry->GetValue(); unsigned long windowWidth; if (windowWidthStr.IsEmpty() || !windowWidthStr.ToULong(&windowWidth) || windowWidth > MAX_WINDOW_WIDTH) { wxMessageDialog errorDialog(this, wxEmptyString, wxT("New Project"), wxOK | wxCENTRE | wxOK_DEFAULT | wxICON_ERROR); errorDialog.SetMessage(wxT("Invalid window width.")); errorDialog.ShowModal(); return; } // get window height wxString windowHeightStr = _windowHeightEntry->GetValue(); unsigned long windowHeight; if (windowHeightStr.IsEmpty() || !windowHeightStr.ToULong(&windowHeight) || windowHeight > MAX_WINDOW_HEIGHT) { wxMessageDialog errorDialog(this, wxEmptyString, wxT("New Project"), wxOK | wxCENTRE | wxOK_DEFAULT | wxICON_ERROR); errorDialog.SetMessage(wxT("Invalid window height.")); errorDialog.ShowModal(); return; } // get window full screen (no validation need) bool windowFullScreen = _windowFullScreenCheckBox->GetValue(); // get name (no validation need) wxString name = _nameEntry->GetValue(); // get description (no validation need) wxString description = _descriptionEntry->GetValue(); // get entry point (no validation need) wxString entryPoint = _entryPointEntry->GetValue(); // get location (no validation need) wxString location = _locationEntry->GetValue(); // apply properties _projectProperties.Name = name; _projectProperties.Description = description; _projectProperties.EntryPoint = entryPoint; _projectProperties.Window.Width = windowWidth; _projectProperties.Window.Height = windowHeight; _projectProperties.Window.FullScreen = windowFullScreen; _projectLocation = location; // return ok EndModal(wxID_OK); }
/* * Run the Add Device Group dialog */ void addDevGrpDialog(CDKSCREEN *main_cdk_screen) { CDKENTRY *dev_grp_name_entry = 0; char attr_path[MAX_SYSFS_PATH_SIZE] = {0}, attr_value[MAX_SYSFS_ATTR_SIZE] = {0}; char *dev_grp_name = NULL, *error_msg = NULL; int temp_int = 0; while (1) { /* Get new device group name (entry widget) */ dev_grp_name_entry = newCDKEntry(main_cdk_screen, CENTER, CENTER, "<C></31/B>Add New Device Group\n", "</B>New Group Name (no spaces): ", COLOR_DIALOG_SELECT, '_' | COLOR_DIALOG_INPUT, vMIXED, SCST_DEV_GRP_NAME_LEN, 0, SCST_DEV_GRP_NAME_LEN, TRUE, FALSE); if (!dev_grp_name_entry) { errorDialog(main_cdk_screen, ENTRY_ERR_MSG, NULL); break; } setCDKEntryBoxAttribute(dev_grp_name_entry, COLOR_DIALOG_BOX); setCDKEntryBackgroundAttrib(dev_grp_name_entry, COLOR_DIALOG_TEXT); /* Draw the entry widget */ curs_set(1); dev_grp_name = activateCDKEntry(dev_grp_name_entry, 0); /* Check exit from widget */ if (dev_grp_name_entry->exitType == vNORMAL) { /* Check group name for bad characters */ if (!checkInputStr(main_cdk_screen, NAME_CHARS, dev_grp_name)) break; /* Add the new device group */ snprintf(attr_path, MAX_SYSFS_PATH_SIZE, "%s/device_groups/mgmt", SYSFS_SCST_TGT); snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "create %s", dev_grp_name); if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) { SAFE_ASPRINTF(&error_msg, "Couldn't add SCST (ALUA) device group: %s", strerror(temp_int)); errorDialog(main_cdk_screen, error_msg, NULL); FREE_NULL(error_msg); } } break; } /* Done */ destroyCDKEntry(dev_grp_name_entry); return; }
void EngineShoutcast::write(unsigned char *header, unsigned char *body, int headerLen, int bodyLen) { int ret; if (!m_pShout) return; if (m_iShoutStatus == SHOUTERR_CONNECTED) { // Send header if there is one if ( headerLen > 0 ) { ret = shout_send(m_pShout, header, headerLen); if (ret != SHOUTERR_SUCCESS) { qDebug() << "DEBUG: Send error: " << shout_get_error(m_pShout); if ( m_iShoutFailures > 3 ){ if(!serverConnect()) errorDialog(tr("Lost connection to streaming server"), tr("Please check your connection to the Internet and verify that your username and password are correct.")); } else{ m_iShoutFailures++; } return; } else { //qDebug() << "yea I kinda sent header"; } } ret = shout_send(m_pShout, body, bodyLen); if (ret != SHOUTERR_SUCCESS) { qDebug() << "DEBUG: Send error: " << shout_get_error(m_pShout); if ( m_iShoutFailures > 3 ){ if(!serverConnect()) errorDialog(tr("Lost connection to streaming server"), tr("Please check your connection to the Internet and verify that your username and password are correct.")); } else{ m_iShoutFailures++; } return; } else { //qDebug() << "yea I kinda sent footer"; } if (shout_queuelen(m_pShout) > 0) { qDebug() << "DEBUG: queue length:" << (int)shout_queuelen(m_pShout); } } else { qDebug() << "Error connecting to Shoutcast server:" << shout_get_error(m_pShout); // errorDialog(tr("Shoutcast aborted connect after 3 tries"), tr("Please check your connection to the Internet and verify that your username and password are correct.")); } }
void TransformsGui::onLoadState() { MessageDialog errorDialog(guiHelper); connect(transformFactory, SIGNAL(error(QString,QString)), &errorDialog, SLOT(logError(QString))); QString fileName = QFileDialog::getOpenFileName(this,tr("Choose state file to load from"),"",tr("XML documents (*.xml);; All (*)")); if (fileName.isEmpty()) return; TransformChain talist = transformFactory->loadConfFromFile(fileName); if (talist.isEmpty()) QMessageBox::critical(this,tr("Error"),tr("The loaded chain is empty. Check the logs."),QMessageBox::Ok); else { if (errorDialog.hasMessages()) { errorDialog.setWindowTitle(tr("Error(s) while loading the state file")); if (errorDialog.exec() == QDialog::Rejected) { while (!talist.isEmpty()) delete talist.takeLast(); return; } } else { logger->logStatus(tr("File %1 loaded").arg(fileName)); } setCurrentTransformChain(talist); // not really efficient QString conf; QXmlStreamWriter writer(&conf); transformFactory->saveConfToXML(talist, &writer); emit chainChanged(conf); } }
void TransformsGui::onSaveState() { if (transformWidgetList.size() == 1) { QMessageBox::critical(this,tr("Error"),tr("No transformation selected, nothing to save!"),QMessageBox::Ok); return; } MessageDialog errorDialog(guiHelper); errorDialog.setJustShowMessages(true); connect(transformFactory, SIGNAL(error(QString,QString)), &errorDialog, SLOT(logError(QString))); TransformChain transformList = getCurrentTransformChain(); QString fileName = QFileDialog::getSaveFileName(this,tr("Choose file to save"), "",tr("XML documents (*.xml);; All (*)")); if (fileName.isEmpty()) return; transformFactory->saveConfToFile(fileName,transformList); if (errorDialog.hasMessages()) { errorDialog.setWindowTitle(tr("Error(s) while saving the state file:")); errorDialog.exec(); } else { logger->logStatus(tr("Saved transformation chain to %1").arg(fileName)); } }
void TransformsGui::setCurrentChainConf(const QString &conf) { if (conf.isEmpty()) return; MessageDialog errorDialog(guiHelper); connect(transformFactory, SIGNAL(error(QString,QString)), &errorDialog, SLOT(logError(QString))); QXmlStreamReader reader(conf); TransformChain talist = transformFactory->loadConfFromXML(&reader); if (talist.isEmpty()) QMessageBox::critical(this,tr("Error"),tr("The loaded chain is empty. Check the logs."),QMessageBox::Ok); else { if (errorDialog.hasMessages()) { errorDialog.setWindowTitle(tr("Error(s) while loading the configuration")); if (errorDialog.exec() == QDialog::Rejected) { while (!talist.isEmpty()) delete talist.takeLast(); return; } } setCurrentTransformChain(talist); emit chainChanged(conf); } }
/* * Run the Remove Device Group dialog */ void remDevGrpDialog(CDKSCREEN *main_cdk_screen) { char dev_grp_name[MAX_SYSFS_ATTR_SIZE] = {0}, attr_path[MAX_SYSFS_PATH_SIZE] = {0}, attr_value[MAX_SYSFS_ATTR_SIZE] = {0}; char *error_msg = NULL, *confirm_msg = NULL; boolean confirm = FALSE; int temp_int = 0; /* Have the user choose a SCST device group */ getSCSTDevGrpChoice(main_cdk_screen, dev_grp_name); if (dev_grp_name[0] == '\0') return; /* Get a final confirmation from user before we delete */ SAFE_ASPRINTF(&confirm_msg, "Are you sure you want to delete SCST device group '%s?'", dev_grp_name); confirm = confirmDialog(main_cdk_screen, confirm_msg, NULL); FREE_NULL(confirm_msg); if (confirm) { /* Delete the specified SCST device group */ snprintf(attr_path, MAX_SYSFS_PATH_SIZE, "%s/device_groups/mgmt", SYSFS_SCST_TGT); snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "del %s", dev_grp_name); if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) { SAFE_ASPRINTF(&error_msg, "Couldn't delete SCST (ALUA) device group: %s", strerror(temp_int)); errorDialog(main_cdk_screen, error_msg, NULL); FREE_NULL(error_msg); } } /* Done */ return; }
/* * Run the Add Device to Group dialog */ void addDevToGrpDialog(CDKSCREEN *main_cdk_screen) { char device_name[MAX_SYSFS_ATTR_SIZE] = {0}, dev_handler[MAX_SYSFS_ATTR_SIZE] = {0}, dev_grp_name[MAX_SYSFS_ATTR_SIZE] = {0}, attr_path[MAX_SYSFS_PATH_SIZE] = {0}, attr_value[MAX_SYSFS_ATTR_SIZE] = {0}; char *error_msg = NULL; int temp_int = 0; /* Have the user choose a SCST device */ getSCSTDevChoice(main_cdk_screen, device_name, dev_handler); if (device_name[0] == '\0') return; /* Have the user choose a SCST device group (to add the device to) */ getSCSTDevGrpChoice(main_cdk_screen, dev_grp_name); if (dev_grp_name[0] == '\0') return; /* Add the SCST device to the device group (ALUA) */ snprintf(attr_path, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/devices/mgmt", SYSFS_SCST_TGT, dev_grp_name); snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "add %s", device_name); if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) { SAFE_ASPRINTF(&error_msg, "Couldn't add SCST (ALUA) device to device group: %s", strerror(temp_int)); errorDialog(main_cdk_screen, error_msg, NULL); FREE_NULL(error_msg); } /* Done */ return; }
/* FUNCTION: loadFile */ bool ResultsWindow::loadFile(const QString &fileName) { QApplication::setOverrideCursor(Qt::WaitCursor); // Read file NXCommandResult* commandResult = entityManager->importFromFile(qPrintable(fileName)); QApplication::restoreOverrideCursor(); bool success = true; if (commandResult->getResult() != NX_CMD_SUCCESS) { QFileInfo fileInfo(fileName); QString message = tr("Unable to open file: %1").arg(fileInfo.fileName()); ErrorDialog errorDialog(message, commandResult); errorDialog.exec(); success = false; } else { setCurrentFile(fileName); // Populate results tree setupResultsTree(); QString message = tr("File loaded: %1").arg(fileName); NXLOG_INFO("ResultsWindow", qPrintable(message)); } // delete commandResult; - commandResult now member of importer return success; }
////////////////////////////////////////////////////////////////////////// // Checks if all entries are full and valid // @return 0 if empty or not valid // @return 1 if fill and valid int StuAppFormUI::validEntries(){ if (isEmpty() || (!Tools::validStuNum(stuNumEntry.get_text()) || !Tools::validName(nameEntry.get_text()) || !Tools::validName(surnameEntry.get_text()) || !Tools::validEmail(emailEntry.get_text()) || !Tools::validNumber(yearEntry.get_text()) || !Tools::validGPA(cgpaEntry.get_text()) || !Tools::validGPA(mgpaEntry.get_text()))) { errorDialog(); return 0; } return 1; }
/* * Run the Remove Target from Group dialog */ void remTgtFromGrpDialog(CDKSCREEN *main_cdk_screen) { char dev_grp_name[MAX_SYSFS_ATTR_SIZE] = {0}, tgt_grp_name[MAX_SYSFS_ATTR_SIZE] = {0}, target_name[MAX_SYSFS_ATTR_SIZE] = {0}, attr_path[MAX_SYSFS_PATH_SIZE] = {0}, attr_value[MAX_SYSFS_ATTR_SIZE] = {0}; char *error_msg = NULL, *confirm_msg = NULL; boolean confirm = FALSE; int temp_int = 0; /* Have the user choose a SCST device group */ getSCSTDevGrpChoice(main_cdk_screen, dev_grp_name); if (dev_grp_name[0] == '\0') return; /* Get target group choice from user (based on previously * selected device group) */ getSCSTTgtGrpChoice(main_cdk_screen, dev_grp_name, tgt_grp_name); if (tgt_grp_name[0] == '\0') return; /* Get target group choice from user (based on previously * selected device group) */ getSCSTTgtGrpTgtChoice(main_cdk_screen, dev_grp_name, tgt_grp_name, target_name); if (target_name[0] == '\0') return; /* Get a final confirmation from user before we delete */ SAFE_ASPRINTF(&confirm_msg, "target '%s' from group '%s?'", target_name, tgt_grp_name); confirm = confirmDialog(main_cdk_screen, "Are you sure you want to remove SCST", confirm_msg); FREE_NULL(confirm_msg); if (confirm) { /* Remove the SCST target from the target group (ALUA) */ snprintf(attr_path, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/target_groups/%s/mgmt", SYSFS_SCST_TGT, dev_grp_name, tgt_grp_name); snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "del %s", target_name); if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) { SAFE_ASPRINTF(&error_msg, "Couldn't delete SCST (ALUA) target from target group: %s", strerror(temp_int)); errorDialog(main_cdk_screen, error_msg, NULL); FREE_NULL(error_msg); } } /* Done */ return; }
void EngineShoutcast::process(const CSAMPLE* pBuffer, const int iBufferSize) { //Check to see if Shoutcast is enabled, and pass the samples off to be broadcast if necessary. bool prefEnabled = (m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY,"enabled")).toInt() == 1); if (!prefEnabled) { if (isConnected()) { // We are conneced but shoutcast is disabled. Disconnect. serverDisconnect(); infoDialog(tr("Mixxx has successfully disconnected from the shoutcast server"), ""); } return; } // If we are here then the user wants to be connected (shoutcast is enabled // in the preferences). bool connected = isConnected(); // If we aren't connected or the user has changed their preferences, // disconnect, update from prefs, and reconnect. if (!connected || m_pUpdateShoutcastFromPrefs->get() > 0.0f) { if (connected) { serverDisconnect(); } // Initialize/update the encoder and libshout setup. updateFromPreferences(); if (serverConnect()) { infoDialog(tr("Mixxx has successfully connected to the shoutcast server"), ""); } else { errorDialog(tr("Mixxx could not connect to streaming server"), tr("Please check your connection to the Internet and verify that your username and password are correct.")); } } // If we aren't connected, bail. if (m_iShoutStatus != SHOUTERR_CONNECTED) return; // If we are connected, encode the samples. if (iBufferSize > 0 && m_encoder){ m_encoder->encodeBuffer(pBuffer, iBufferSize); } // Check if track metadata has changed and if so, update. if (metaDataHasChanged()) { updateMetaData(); } }
SimpleJoint* SimulatedWorld::AddJoint() { SimpleJoint* createdJoint; wxArrayString options; wxString option1("Prismatic"); wxString option2("rotational"); options.Add(option1); options.Add(option2); wxArrayString AxisOptions; wxString AxisOption1("X_AXIS"); wxString AxisOption2("Y_AXIS");wxString AxisOption3("Z_AXIS"); AxisOptions.Add(AxisOption1);AxisOptions.Add(AxisOption2);AxisOptions.Add(AxisOption3); bool prismatic=false; int axis=0;double vmin=-PI; double vmax=PI; wxString Type; wxSingleChoiceDialog myDialog(NULL,wxString("Select joint type"),wxString("Options"),options); if (myDialog.ShowModal()==wxID_OK ) { if(myDialog.GetStringSelection()==wxString("Prismatic")) prismatic=true; else prismatic=false; } wxTextEntryDialog myDialogVmax(NULL,wxString("Introduce Vmax"),wxGetTextFromUserPromptStr,wxEmptyString,wxTextEntryDialogStyle,wxDefaultPosition); if (myDialogVmax.ShowModal()==wxID_OK ) { wxString value=myDialogVmax.GetValue(); value.ToDouble(&vmax); } wxTextEntryDialog myDialogVmin(NULL,wxString("Introduce Vmin"),wxGetTextFromUserPromptStr,wxEmptyString,wxTextEntryDialogStyle,wxDefaultPosition); if (myDialogVmin.ShowModal()==wxID_OK ) { wxString value=myDialogVmin.GetValue(); value.ToDouble(&vmin); if(vmin>=vmax) { wxMessageDialog errorDialog(NULL, wxString("Wrong Value-SimpleJoint will be created with default values") ,wxMessageBoxCaptionStr,wxOK|wxCENTRE,wxDefaultPosition); errorDialog.ShowModal(); vmin=-PI; vmax=PI; } } wxSingleChoiceDialog myDialog2(NULL,wxString("Select Axis"),wxString("Options"),AxisOptions); if (myDialog2.ShowModal()==wxID_OK ) { if(myDialog2.GetStringSelection()==wxString("X_AXIS")) axis=1; if(myDialog2.GetStringSelection()==wxString("Y_AXIS")) axis=2; else axis=3; } if (axis==1) createdJoint=new SimpleJoint(vmax,vmin,true,0,X_AXIS,prismatic); else if(axis==2) createdJoint=new SimpleJoint(vmax,vmin,true,0,Y_AXIS,prismatic); else createdJoint=new SimpleJoint(vmax,vmin,true,0,Z_AXIS,prismatic); return createdJoint; }
void MainScreen::on_useCardsButton_clicked() { if (this->driver->getRiskMap()->getPlayer(driver->getCurrentPlayerName())->getCards() >= 2) { CardsTradeDialog* cardsTradeDialog = new CardsTradeDialog(this->driver, this); if (cardsTradeDialog->exec() == QDialog::Accepted) { ui->useCardsButton->setEnabled(false); } } else { QMessageBox errorDialog(this); errorDialog.setWindowTitle("Insufficient Number of Cards"); errorDialog.setText("You need at least 2 cards to be able to trade!"); errorDialog.exec(); } }
void Core::updateTrayIcon(double value) { if (!isPulse_) { const std::string mixer = getActiveMixer(); if (!mixer.empty()) { m_signal_value_changed(value, getSoundCardName(), mixer); } else { errorDialog(_("Sound card not contains any volume control mixers")); m_signal_value_changed(value, getSoundCardName(), std::string("N/A")); } } else { m_signal_value_changed(value, getSoundCardName(), std::string()); } }
void QgsAuthSslImportDialog::sslErrors( const QList<QSslError> &errors ) { if ( !mTimer->isActive() ) { return; } mTimer->stop(); QDialog errorDialog( this ); Ui_SslErrors ui; ui.setupUi( &errorDialog ); connect( ui.certificateChainButton, SIGNAL( clicked() ), this, SLOT( showCertificateInfo() ) ); Q_FOREACH ( const QSslError &error, errors ) { ui.sslErrorList->addItem( error.errorString() ); }
void SslClient::sslErrors(const QList<QSslError> &errors) { QDialog errorDialog(this); Ui_SslErrors ui; ui.setupUi(&errorDialog); connect(ui.certificateChainButton, &QPushButton::clicked, this, &SslClient::displayCertificateInfo); for (const auto &error : errors) ui.sslErrorList->addItem(error.errorString()); executingDialog = true; if (errorDialog.exec() == QDialog::Accepted) socket->ignoreSslErrors(); executingDialog = false; // did the socket state change? if (socket->state() != QAbstractSocket::ConnectedState) socketStateChanged(socket->state()); }
void Core::initPulseAudio() { if (!pulse_) { pulse_ = PulseCore::Ptr(new PulseCore("alsavolume")); if (pulse_->available()) { pulseDevice_ = settings_->pulseDeviceName(); if (pulseDevice_.empty() || !pulse_->deviceNameExists(pulseDevice_)) { pulseDevice_ = pulse_->defaultSink(); } pulse_->setCurrentDevice(pulseDevice_); updatePulseDevices(pulse_->getCurrentDeviceIndex()); } else { errorDialog(_("Can't start PulseAudio! Using Alsa by default")); pulse_.reset(); isPulse_ = false; settingsStr_->setUsePulse(isPulse_); settings_->setUsePulse(isPulse_); } } }
void SslClient::sslErrors(const QList<QSslError> &errors) { QDialog errorDialog(this); Ui_SslErrors ui; ui.setupUi(&errorDialog); connect(ui.certificateChainButton, SIGNAL(clicked()), this, SLOT(displayCertificateInfo())); foreach (const QSslError &error, errors) ui.sslErrorList->addItem(error.errorString()); executingDialog = true; #ifdef Q_OS_SYMBIAN errorDialog.showMaximized(); #endif if (errorDialog.exec() == QDialog::Accepted) socket->ignoreSslErrors(); executingDialog = false; // did the socket state change? if (socket->state() != QAbstractSocket::ConnectedState) socketStateChanged(socket->state()); }
/* * Run the Add Target to Group dialog */ void addTgtToGrpDialog(CDKSCREEN *main_cdk_screen) { WINDOW *add_tgt_window = 0; CDKSCREEN *add_tgt_screen = 0; CDKLABEL *add_tgt_info = 0; CDKENTRY *tgt_name = 0; CDKSCALE *rel_tgt_id = 0; CDKBUTTON *ok_button = 0, *cancel_button = 0; tButtonCallback ok_cb = &okButtonCB, cancel_cb = &cancelButtonCB; char dev_grp_name[MAX_SYSFS_ATTR_SIZE] = {0}, tgt_grp_name[MAX_SYSFS_ATTR_SIZE] = {0}, attr_path[MAX_SYSFS_PATH_SIZE] = {0}, attr_value[MAX_SYSFS_ATTR_SIZE] = {0}; char *error_msg = NULL; char *add_tgt_info_msg[TGT_GRP_INFO_LINES] = {NULL}; int add_tgt_window_lines = 0, add_tgt_window_cols = 0, window_y = 0, window_x = 0, temp_int = 0, i = 0, traverse_ret = 0; /* Have the user choose a SCST device group */ getSCSTDevGrpChoice(main_cdk_screen, dev_grp_name); if (dev_grp_name[0] == '\0') return; /* Get target group choice from user (based on previously * selected device group) */ getSCSTTgtGrpChoice(main_cdk_screen, dev_grp_name, tgt_grp_name); if (tgt_grp_name[0] == '\0') return; /* New CDK screen */ add_tgt_window_lines = 11; add_tgt_window_cols = 55; window_y = ((LINES / 2) - (add_tgt_window_lines / 2)); window_x = ((COLS / 2) - (add_tgt_window_cols / 2)); add_tgt_window = newwin(add_tgt_window_lines, add_tgt_window_cols, window_y, window_x); if (add_tgt_window == NULL) { errorDialog(main_cdk_screen, NEWWIN_ERR_MSG, NULL); return; } add_tgt_screen = initCDKScreen(add_tgt_window); if (add_tgt_screen == NULL) { errorDialog(main_cdk_screen, CDK_SCR_ERR_MSG, NULL); return; } boxWindow(add_tgt_window, COLOR_DIALOG_BOX); wbkgd(add_tgt_window, COLOR_DIALOG_TEXT); wrefresh(add_tgt_window); while (1) { /* Information label */ SAFE_ASPRINTF(&add_tgt_info_msg[0], "</31/B>Adding SCST target to target group..."); SAFE_ASPRINTF(&add_tgt_info_msg[1], " "); SAFE_ASPRINTF(&add_tgt_info_msg[2], "</B>Device group:<!B>\t%s", dev_grp_name); SAFE_ASPRINTF(&add_tgt_info_msg[3], "</B>Target group:<!B>\t%s", tgt_grp_name); add_tgt_info = newCDKLabel(add_tgt_screen, (window_x + 1), (window_y + 1), add_tgt_info_msg, ADD_TGT_INFO_LINES, FALSE, FALSE); if (!add_tgt_info) { errorDialog(main_cdk_screen, LABEL_ERR_MSG, NULL); break; } setCDKLabelBackgroundAttrib(add_tgt_info, COLOR_DIALOG_TEXT); /* Target name (entry) */ tgt_name = newCDKEntry(add_tgt_screen, (window_x + 1), (window_y + 6), NULL, "</B>Target Name: ", COLOR_DIALOG_SELECT, '_' | COLOR_DIALOG_INPUT, vMIXED, 20, 0, SCST_TGT_NAME_LEN, FALSE, FALSE); if (!tgt_name) { errorDialog(main_cdk_screen, ENTRY_ERR_MSG, NULL); break; } setCDKEntryBoxAttribute(tgt_name, COLOR_DIALOG_INPUT); /* Relative target ID (scale) */ rel_tgt_id = newCDKScale(add_tgt_screen, (window_x + 1), (window_y + 7), NULL, "</B>Relative Target ID: ", COLOR_DIALOG_SELECT, 7, 0, MIN_SCST_REL_TGT_ID, MAX_SCST_REL_TGT_ID, 1, 100, FALSE, FALSE); if (!rel_tgt_id) { errorDialog(main_cdk_screen, SCALE_ERR_MSG, NULL); break; } setCDKScaleBackgroundAttrib(rel_tgt_id, COLOR_DIALOG_TEXT); /* Buttons */ ok_button = newCDKButton(add_tgt_screen, (window_x + 16), (window_y + 9), g_ok_cancel_msg[0], ok_cb, FALSE, FALSE); if (!ok_button) { errorDialog(main_cdk_screen, BUTTON_ERR_MSG, NULL); break; } setCDKButtonBackgroundAttrib(ok_button, COLOR_DIALOG_INPUT); cancel_button = newCDKButton(add_tgt_screen, (window_x + 26), (window_y + 9), g_ok_cancel_msg[1], cancel_cb, FALSE, FALSE); if (!cancel_button) { errorDialog(main_cdk_screen, BUTTON_ERR_MSG, NULL); break; } setCDKButtonBackgroundAttrib(cancel_button, COLOR_DIALOG_INPUT); /* Allow user to traverse the screen */ refreshCDKScreen(add_tgt_screen); traverse_ret = traverseCDKScreen(add_tgt_screen); /* User hit 'OK' button */ if (traverse_ret == 1) { /* Turn the cursor off (pretty) */ curs_set(0); /* Check the entry field for bad characters */ if (!checkInputStr(main_cdk_screen, INIT_CHARS, getCDKEntryValue(tgt_name))) break; /* Add the target to the target group */ snprintf(attr_path, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/target_groups/%s/mgmt", SYSFS_SCST_TGT, dev_grp_name, tgt_grp_name); snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "add %s", getCDKEntryValue(tgt_name)); if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) { SAFE_ASPRINTF(&error_msg, "Couldn't add SCST (ALUA) target to target group: %s", strerror(temp_int)); errorDialog(main_cdk_screen, error_msg, NULL); FREE_NULL(error_msg); break; } /* Set the relative target ID */ snprintf(attr_path, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/target_groups/%s/%s/rel_tgt_id", SYSFS_SCST_TGT, dev_grp_name, tgt_grp_name, getCDKEntryValue(tgt_name)); snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "%d", getCDKScaleValue(rel_tgt_id)); if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) { SAFE_ASPRINTF(&error_msg, SET_REL_TGT_ID_ERR, strerror(temp_int)); errorDialog(main_cdk_screen, error_msg, NULL); FREE_NULL(error_msg); break; } } break; } /* Done */ for (i = 0; i < ADD_TGT_INFO_LINES; i++) FREE_NULL(add_tgt_info_msg[i]); if (add_tgt_screen != NULL) { destroyCDKScreenObjects(add_tgt_screen); destroyCDKScreen(add_tgt_screen); delwin(add_tgt_window); } return; }
int split_thread(SceSize args_size, SplitArguments *args) { SceUID thid = -1; // Set progress to 0% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 0); sceKernelDelayThread(DIALOG_WAIT); // Needed to see the percentage SceUID fd = -1; void *buf = NULL; FileListEntry *file_entry = fileListGetNthEntry(args->file_list, args->index); char path[MAX_PATH_LENGTH]; snprintf(path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, file_entry->name); // Get file size SceIoStat stat; memset(&stat, 0, sizeof(SceIoStat)); int res = sceIoGetstat(path, &stat); if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } // Update thread thid = createStartUpdateThread((uint32_t)stat.st_size); // Make folder char folder[MAX_PATH_LENGTH]; snprintf(folder, MAX_PATH_LENGTH, "%s%s", path, SPLIT_SUFFIX); sceIoMkdir(folder, 0777); // Split process fd = sceIoOpen(path, SCE_O_RDONLY, 0); if (fd < 0) { closeWaitDialog(); errorDialog(fd); goto EXIT; } buf = malloc(SPLIT_PART_SIZE); uint32_t seek = 0; while (seek < (uint32_t)stat.st_size) { int read = sceIoRead(fd, buf, SPLIT_PART_SIZE); if (read < 0) { closeWaitDialog(); errorDialog(read); goto EXIT; } int part_num = seek / SPLIT_PART_SIZE; int folder_num = part_num / SPLIT_MAX_FILES; int file_num = part_num % SPLIT_MAX_FILES; char new_path[MAX_PATH_LENGTH]; snprintf(new_path, MAX_PATH_LENGTH, "%s%s/%04d/%04d", path, SPLIT_SUFFIX, folder_num, file_num); int written = WriteFile(new_path, buf, read); // Failed, maybe folder doesn't exist yet? if (written < 0) { // Make folder char folder[MAX_PATH_LENGTH]; snprintf(folder, MAX_PATH_LENGTH, "%s%s/%04d", path, SPLIT_SUFFIX, folder_num); sceIoMkdir(folder, 0777); // Retry written = WriteFile(new_path, buf, read); } if (written < 0) { closeWaitDialog(); errorDialog(written); goto EXIT; } seek += read; SetProgress(seek, stat.st_size); } // Write size char size_path[MAX_PATH_LENGTH]; snprintf(size_path, MAX_PATH_LENGTH, "%s%s/%s", path, SPLIT_SUFFIX, SPLIT_SIZE_NAME); WriteFile(size_path, &seek, sizeof(uint32_t)); // Set progress to 100% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100); sceKernelDelayThread(COUNTUP_WAIT); // Close sceMsgDialogClose(); dialog_step = DIALOG_STEP_SPLITTED; EXIT: if (buf) free(buf); if (fd >= 0) sceIoClose(fd); if (thid >= 0) sceKernelWaitThreadEnd(thid, NULL, NULL); return sceKernelExitDeleteThread(0); }
int copy_thread(SceSize args_size, CopyArguments *args) { SceUID thid = -1; // Set progress to 0% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 0); sceKernelDelayThread(DIALOG_WAIT); // Needed to see the percentage char src_path[MAX_PATH_LENGTH], dst_path[MAX_PATH_LENGTH]; FileListEntry *copy_entry = NULL; if (args->copy_mode == COPY_MODE_MOVE) { // Move // Update thread thid = createStartUpdateThread(args->copy_list->length); copy_entry = args->copy_list->head; int i; for (i = 0; i < args->copy_list->length; i++) { snprintf(src_path, MAX_PATH_LENGTH, "%s%s", args->copy_list->path, copy_entry->name); snprintf(dst_path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, copy_entry->name); int res = sceIoRename(src_path, dst_path); // TODO: if (res == SCE_ERROR_ERRNO_EEXIST) if folder if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } SetProgress(i + 1, args->copy_list->length); copy_entry = copy_entry->next; } // Set progress to 100% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100); sceKernelDelayThread(COUNTUP_WAIT); // Close sceMsgDialogClose(); dialog_step = DIALOG_STEP_MOVED; } else { // Copy if (args->copy_mode == COPY_MODE_EXTRACT) archiveOpen(args->archive_path); // Get src paths info uint32_t size = 0, folders = 0, files = 0; copy_entry = args->copy_list->head; int i; for (i = 0; i < args->copy_list->length; i++) { disableAutoSuspend(); snprintf(src_path, MAX_PATH_LENGTH, "%s%s", args->copy_list->path, copy_entry->name); if (args->copy_mode == COPY_MODE_EXTRACT) { addEndSlash(src_path); getArchivePathInfo(src_path, &size, &folders, &files); } else { removeEndSlash(src_path); getPathInfo(src_path, &size, &folders, &files); } copy_entry = copy_entry->next; } // Update thread thid = createStartUpdateThread(size + folders); // Copy process uint32_t value = 0; copy_entry = args->copy_list->head; for (i = 0; i < args->copy_list->length; i++) { snprintf(src_path, MAX_PATH_LENGTH, "%s%s", args->copy_list->path, copy_entry->name); snprintf(dst_path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, copy_entry->name); if (args->copy_mode == COPY_MODE_EXTRACT) { addEndSlash(src_path); addEndSlash(dst_path); int res = extractArchivePath(src_path, dst_path, &value, size + folders, SetProgress); if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } } else { removeEndSlash(src_path); removeEndSlash(dst_path); int res = copyPath(src_path, dst_path, &value, size + folders, SetProgress); if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } } copy_entry = copy_entry->next; } // Set progress to 100% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100); sceKernelDelayThread(COUNTUP_WAIT); // Close sceMsgDialogClose(); dialog_step = DIALOG_STEP_COPIED; } EXIT: if (thid >= 0) sceKernelWaitThreadEnd(thid, NULL, NULL); return sceKernelExitDeleteThread(0); }
int delete_thread(SceSize args_size, DeleteArguments *args) { SceUID thid = -1; // Set progress to 0% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 0); sceKernelDelayThread(DIALOG_WAIT); // Needed to see the percentage FileListEntry *file_entry = fileListGetNthEntry(args->file_list, args->index); int count = 0; FileListEntry *head = NULL; FileListEntry *mark_entry_one = NULL; if (fileListFindEntry(args->mark_list, file_entry->name)) { // On marked entry count = args->mark_list->length; head = args->mark_list->head; } else { count = 1; mark_entry_one = malloc(sizeof(FileListEntry)); strcpy(mark_entry_one->name, file_entry->name); head = mark_entry_one; } char path[MAX_PATH_LENGTH]; FileListEntry *mark_entry = NULL; // Get paths info uint32_t folders = 0, files = 0; mark_entry = head; int i; for (i = 0; i < count; i++) { disableAutoSuspend(); snprintf(path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, mark_entry->name); removeEndSlash(path); getPathInfo(path, NULL, &folders, &files); mark_entry = mark_entry->next; } // Update thread thid = createStartUpdateThread(folders + files); // Remove process uint32_t value = 0; mark_entry = head; for (i = 0; i < count; i++) { snprintf(path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, mark_entry->name); removeEndSlash(path); int res = removePath(path, &value, folders + files, SetProgress); if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } mark_entry = mark_entry->next; } // Set progress to 100% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100); sceKernelDelayThread(COUNTUP_WAIT); // Close sceMsgDialogClose(); dialog_step = DIALOG_STEP_DELETED; EXIT: if (mark_entry_one) free(mark_entry_one); if (thid >= 0) sceKernelWaitThreadEnd(thid, NULL, NULL); return sceKernelExitDeleteThread(0); }
int join_thread(SceSize args_size, JoinArguments *args) { SceUID thid = -1; // Set progress to 0% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 0); sceKernelDelayThread(DIALOG_WAIT); // Needed to see the percentage SceUID fd = -1; void *buf = NULL; FileListEntry *file_entry = fileListGetNthEntry(args->file_list, args->index); char path[MAX_PATH_LENGTH]; snprintf(path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, file_entry->name); removeEndSlash(path); // Get file size char size_path[MAX_PATH_LENGTH]; snprintf(size_path, MAX_PATH_LENGTH, "%s/%s", path, SPLIT_SIZE_NAME); uint32_t size = 0; int res = ReadFile(size_path, &size, sizeof(uint32_t)); if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } // Update thread thid = createStartUpdateThread((uint32_t)size); // Join process char dst_path[MAX_PATH_LENGTH]; strcpy(dst_path, path); char *p = strrchr(dst_path, '.'); if (p) *p = '\0'; fd = sceIoOpen(dst_path, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777); if (fd < 0) { closeWaitDialog(); errorDialog(fd); goto EXIT; } buf = malloc(SPLIT_PART_SIZE); uint32_t seek = 0; while (seek < size) { int part_num = seek / SPLIT_PART_SIZE; int folder_num = part_num / SPLIT_MAX_FILES; int file_num = part_num % SPLIT_MAX_FILES; char src_path[MAX_PATH_LENGTH]; snprintf(src_path, MAX_PATH_LENGTH, "%s/%04d/%04d", path, folder_num, file_num); int read = ReadFile(src_path, buf, SPLIT_PART_SIZE); if (read < 0) { closeWaitDialog(); errorDialog(read); goto EXIT; } int written = sceIoWrite(fd, buf, read); if (written < 0) { closeWaitDialog(); errorDialog(written); goto EXIT; } seek += read; SetProgress(seek, size); } // Set progress to 100% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100); sceKernelDelayThread(COUNTUP_WAIT); // Close sceMsgDialogClose(); dialog_step = DIALOG_STEP_JOINED; EXIT: if (buf) free(buf); if (fd >= 0) sceIoClose(fd); if (thid >= 0) sceKernelWaitThreadEnd(thid, NULL, NULL); return sceKernelExitDeleteThread(0); }
void EngineShoutcast::updateFromPreferences() { qDebug() << "EngineShoutcast: updating from preferences"; m_pUpdateShoutcastFromPrefs->slotSet(0.0f); m_format_is_mp3 = false; m_format_is_ov = false; m_protocol_is_icecast1 = false; m_protocol_is_icecast2 = false; m_protocol_is_shoutcast = false; m_ogg_dynamic_update = false; // Convert a bunch of QStrings to QByteArrays so we can get regular C char* // strings to pass to libshout. QString codec = m_pConfig->getValueString(ConfigKey(SHOUTCAST_PREF_KEY, "metadata_charset")); QByteArray baCodec = codec.toLatin1(); m_pTextCodec = QTextCodec::codecForName(baCodec); if (!m_pTextCodec) { qDebug() << "Couldn't find shoutcast metadata codec for codec:" << codec << " defaulting to ISO-8859-1."; } // Indicates our metadata is in the provided charset. shout_metadata_add(m_pShoutMetaData, "charset", baCodec.constData()); // Host, server type, port, mountpoint, login, password should be latin1. QByteArray baHost = m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "host")).toLatin1(); QByteArray baServerType = m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "servertype")).toLatin1(); QByteArray baPort = m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "port")).toLatin1(); QByteArray baMountPoint = m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "mountpoint")).toLatin1(); QByteArray baLogin = m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "login")).toLatin1(); QByteArray baPassword = m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "password")).toLatin1(); QByteArray baFormat = m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "format")).toLatin1(); QByteArray baBitrate = m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "bitrate")).toLatin1(); // Encode metadata like stream name, website, desc, genre, title/author with // the chosen TextCodec. QByteArray baStreamName = encodeString(m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "stream_name"))); QByteArray baStreamWebsite = encodeString(m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "stream_website"))); QByteArray baStreamDesc = encodeString(m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "stream_desc"))); QByteArray baStreamGenre = encodeString(m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "stream_genre"))); QByteArray baStreamPublic = encodeString(m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "stream_public"))); // Dynamic Ogg metadata update m_ogg_dynamic_update = (bool)m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY,"ogg_dynamicupdate")).toInt(); m_custom_metadata = (bool)m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "enable_metadata")).toInt(); m_customTitle = m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "custom_title")); m_customArtist = m_pConfig->getValueString( ConfigKey(SHOUTCAST_PREF_KEY, "custom_artist")); int format; int protocol; if (shout_set_host(m_pShout, baHost.constData()) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting hostname!"), shout_get_error(m_pShout)); return; } // WTF? Why SHOUT_PROTOCOL_HTTP and not.. the chosen protocol? if (shout_set_protocol(m_pShout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting protocol!"), shout_get_error(m_pShout)); return; } if (shout_set_port(m_pShout, baPort.toUInt()) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting port!"), shout_get_error(m_pShout)); return; } if (shout_set_password(m_pShout, baPassword.constData()) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting password!"), shout_get_error(m_pShout)); return; } if (shout_set_mount(m_pShout, baMountPoint.constData()) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting mount!"), shout_get_error(m_pShout)); return; } if (shout_set_user(m_pShout, baLogin.constData()) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting username!"), shout_get_error(m_pShout)); return; } if (shout_set_name(m_pShout, baStreamName.constData()) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting stream name!"), shout_get_error(m_pShout)); return; } if (shout_set_description(m_pShout, baStreamDesc.constData()) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting stream description!"), shout_get_error(m_pShout)); return; } if (shout_set_genre(m_pShout, baStreamGenre.constData()) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting stream genre!"), shout_get_error(m_pShout)); return; } if (shout_set_url(m_pShout, baStreamWebsite.constData()) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting stream url!"), shout_get_error(m_pShout)); return; } m_format_is_mp3 = !qstrcmp(baFormat.constData(), SHOUTCAST_FORMAT_MP3); m_format_is_ov = !qstrcmp(baFormat.constData(), SHOUTCAST_FORMAT_OV); if (m_format_is_mp3) { format = SHOUT_FORMAT_MP3; } else if (m_format_is_ov) { format = SHOUT_FORMAT_OGG; } else { qDebug() << "Error: unknown format:" << baFormat.constData(); return; } if (shout_set_format(m_pShout, format) != SHOUTERR_SUCCESS) { errorDialog("Error setting soutcast format!", shout_get_error(m_pShout)); return; } bool bitrate_is_int = false; int iBitrate = baBitrate.toInt(&bitrate_is_int); if (!bitrate_is_int) { qDebug() << "Error: unknown bitrate:" << baBitrate.constData(); } int iMasterSamplerate = m_pMasterSamplerate->get(); if (m_format_is_ov && iMasterSamplerate == 96000) { errorDialog(tr("Broadcasting at 96kHz with Ogg Vorbis is not currently " "supported. Please try a different sample-rate or switch " "to a different encoding."), tr("See https://bugs.launchpad.net/mixxx/+bug/686212 for more " "information.")); return; } if (shout_set_audio_info(m_pShout, SHOUT_AI_BITRATE, baBitrate.constData()) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting bitrate"), shout_get_error(m_pShout)); return; } m_protocol_is_icecast2 = !qstricmp(baServerType.constData(), SHOUTCAST_SERVER_ICECAST2); m_protocol_is_shoutcast = !qstricmp(baServerType.constData(), SHOUTCAST_SERVER_SHOUTCAST); m_protocol_is_icecast1 = !qstricmp(baServerType.constData(), SHOUTCAST_SERVER_ICECAST1); if (m_protocol_is_icecast2) { protocol = SHOUT_PROTOCOL_HTTP; } else if (m_protocol_is_shoutcast) { protocol = SHOUT_PROTOCOL_ICY; } else if (m_protocol_is_icecast1) { protocol = SHOUT_PROTOCOL_XAUDIOCAST; } else { errorDialog(tr("Error: unknown server protocol!"), shout_get_error(m_pShout)); return; } if (m_protocol_is_shoutcast && !m_format_is_mp3) { errorDialog(tr("Error: libshout only supports Shoutcast with MP3 format!"), shout_get_error(m_pShout)); return; } if (shout_set_protocol(m_pShout, protocol) != SHOUTERR_SUCCESS) { errorDialog(tr("Error setting protocol!"), shout_get_error(m_pShout)); return; } // Initialize m_encoder if (m_encoder) { // delete m_encoder if it has been initalized (with maybe) different bitrate delete m_encoder; m_encoder = NULL; } if (m_format_is_mp3) { m_encoder = new EncoderMp3(this); } else if (m_format_is_ov) { m_encoder = new EncoderVorbis(this); } else { qDebug() << "**** Unknown Encoder Format"; return; } if (m_encoder->initEncoder(iBitrate, iMasterSamplerate) < 0) { //e.g., if lame is not found //init m_encoder itself will display a message box qDebug() << "**** Encoder init failed"; delete m_encoder; m_encoder = NULL; } }
void showPreferences(gpointer data) { char* glade_file; GladeXML* gladeWindow; //Load interface from glade file glade_file = g_build_filename(GLADEDIR, GLADE_XML_FILE, NULL); gladeWindow = glade_xml_new(glade_file, "preferences-dialog", NULL); //In case we cannot load glade file if (gladeWindow == NULL) { errorDialog(_("Could not load the preferences interface"), glade_file); g_free (glade_file); return; } g_free (glade_file); //Get the widgets that we will need historyLength = glade_xml_get_widget(gladeWindow, "historyLength"); itemLength = glade_xml_get_widget(gladeWindow, "itemLength"); primaryCheck = glade_xml_get_widget(gladeWindow, "primaryCheck"); defaultCheck = glade_xml_get_widget(gladeWindow, "defaultCheck"); markDefaultCheck = glade_xml_get_widget(gladeWindow, "markDefaultCheck"); saveHistCheck = glade_xml_get_widget(gladeWindow, "saveHistCheck"); keyCombEntry = glade_xml_get_widget(gladeWindow, "keyComb"); helpButton = glade_xml_get_widget(gladeWindow, "helpButton"); closeButton = glade_xml_get_widget(gladeWindow, "closeButton"); prefWin = glade_xml_get_widget(gladeWindow, "preferences-dialog"); //Connect signals to handlers g_signal_connect ((gpointer) primaryCheck, "toggled", G_CALLBACK (on_primaryCheck_toggled), NULL); g_signal_connect ((gpointer) defaultCheck, "toggled", G_CALLBACK (on_defaultCheck_toggled), NULL); g_signal_connect ((gpointer) helpButton, "clicked", G_CALLBACK (on_helpButton_clicked), NULL); g_signal_connect ((gpointer) closeButton, "clicked", G_CALLBACK (on_closeButton_clicked), NULL); g_signal_connect ((gpointer) itemLength, "value_changed", G_CALLBACK (on_itemLength_value_changed), NULL); g_signal_connect ((gpointer) historyLength, "value_changed", G_CALLBACK (on_historyLength_value_changed), NULL); g_signal_connect ((gpointer) markDefaultCheck, "toggled", G_CALLBACK (on_markDefaultCheck_toggled), NULL); g_signal_connect ((gpointer) saveHistCheck, "toggled", G_CALLBACK (on_saveHistCheck_toggled), NULL); g_signal_connect ((gpointer) keyCombEntry, "changed", G_CALLBACK (on_keyCombEntry_changed), NULL); //Show preferences dialog setWidgets(); gtk_widget_show_all(prefWin); //free the glade data g_object_unref(gladeWindow); }
void RawDataVisualizeFrame::OnSaveCurrent(wxCommandEvent& event){ wxString defaultname; if (currentplot == 1){ defaultname = wxT("RawDataBoxplot"); } else if (currentplot == 2){ defaultname = wxT("RawDataDensityPlot"); } else if (currentplot == 3){ defaultname = wxT("RawDataDensityPlotIndividual"); } else { wxString msg=wxT("Sorry there is no current image to save."); wxMessageDialog errorDialog (0, msg, _T("No current plot to save."), wxOK | wxICON_EXCLAMATION); errorDialog.ShowModal(); return; } BitmapSettingDialog *myBitmapSettingDialog = new BitmapSettingDialog(this, -1, wxT("Bitmap Settings"), wxPoint(100,100), wxDefaultSize, wxDEFAULT_DIALOG_STYLE); myBitmapSettingDialog->ShowModal(); defaultname+=wxT("."); defaultname+=myBitmapSettingDialog->GetImageType(); wxString savefilename = wxFileSelector( wxT("Save Image"), wxT(""), defaultname, (const wxChar *)NULL, wxT("PNG files (*.png)|*.png|JPEG files (*.jpg)|*.jpg|TIFF files (*.tif)|*.tif") , wxFD_SAVE); if (savefilename.empty() ){ delete myBitmapSettingDialog; return; } /* if (wxFileExists(savefilename)){ wxString t=savefilename + _T(" already exists. Overwrite?"); wxMessageDialog aboutDialog (0, t, _T("Overwrite?"), wxYES_NO); if (aboutDialog.ShowModal() == wxID_NO){ return; } } */ long horizontalsize,verticalsize; horizontalsize = myBitmapSettingDialog->GetWidth(); verticalsize= myBitmapSettingDialog->GetHeight(); wxBitmap bitmap( horizontalsize,verticalsize ); wxMemoryDC memdc; memdc.SelectObject( bitmap ); PrepareDC( memdc ); memdc.Clear(); if (currentplot == 1){ DrawRawBoxplot(memdc); } else if (currentplot == 2){ DrawRawDensityPlot(memdc); } else { delete myBitmapSettingDialog; return; } wxImage image = bitmap.ConvertToImage(); image.SaveFile(savefilename); delete myBitmapSettingDialog; }
void LuminaryDialog::OnOK(wxCommandEvent& event) { LuminaryConfig *newConfig; SolverConfig newGlobalConfig; uint newNb; newNb = m_nbPanels; newConfig = new LuminaryConfig[newNb]; for(uint i = 0; i < newNb; i++){ newConfig[i].fields = new SolverConfig[1]; newConfig[i].fires = new FlameConfig[1]; } if(!m_globalSolverPanel->getCtrlValues(newGlobalConfig)) return; else { m_currentConfig->globalField = newGlobalConfig; m_currentConfig->useGlobalField = m_activateGlobalSolverCheckBox->GetValue(); m_currentConfig->globalField.buoyancy=0; m_currentConfig->globalField.vorticityConfinement=.1; } for(uint i = 0; i < newNb; i++) { if( m_luminaryPanels[i]->getCtrlValues(newConfig[i]) ){ if( newConfig[i].fires[0].type != CANDLE && newConfig[i].fires[0].type != CANDLESTICK ){ if( newConfig[i].fileName.IsEmpty() ){ wxMessageDialog errorDialog (this,_("You must provide a filename for the wick"),_("Error"),wxOK|wxICON_ERROR); errorDialog.ShowModal(); delete [] newConfig; return; } } /* On recopie les anciens paramètres si ils existent */ if( m_currentConfig->nbLuminaries > i ) { newConfig[i].fires[0].innerForce = m_currentConfig->luminaries[i].fires[0].innerForce; newConfig[i].fires[0].leadLifeSpan = m_currentConfig->luminaries[i].fires[0].leadLifeSpan; newConfig[i].fires[0].periLifeSpan = m_currentConfig->luminaries[i].fires[0].periLifeSpan; newConfig[i].fires[0].lod = m_currentConfig->luminaries[i].fires[0].lod; newConfig[i].fires[0].flickering = m_currentConfig->luminaries[i].fires[0].flickering; newConfig[i].fires[0].fdf = m_currentConfig->luminaries[i].fires[0].fdf; newConfig[i].fires[0].IESFileName = m_currentConfig->luminaries[i].fires[0].IESFileName; newConfig[i].fields[0].buoyancy = m_currentConfig->luminaries[i].fields[0].buoyancy; newConfig[i].fields[0].vorticityConfinement = m_currentConfig->luminaries[i].fields[0].vorticityConfinement; } else { newConfig[i].fires[0].innerForce = 0.005; newConfig[i].fires[0].leadLifeSpan = 6; newConfig[i].fires[0].periLifeSpan = 4; newConfig[i].fires[0].lod = 100; newConfig[i].fires[0].flickering = 0; newConfig[i].fires[0].fdf = 0; newConfig[i].fires[0].IESFileName = _("IES/test.ies"); newConfig[i].fields[0].buoyancy = .2; newConfig[i].fields[0].vorticityConfinement = .1; } }else{ for(uint i = 0; i < newNb; i++){ delete [] newConfig[i].fields; delete [] newConfig[i].fires; } delete [] newConfig; return; } } for(int unsigned i=0; i < m_currentConfig->nbLuminaries; i++) { delete [] m_currentConfig->luminaries[i].fires; delete [] m_currentConfig->luminaries[i].fields; } delete [] m_currentConfig->luminaries; m_currentConfig->nbLuminaries = newNb; m_currentConfig->luminaries = newConfig; EndModal(wxID_OK); }
/* * Run the Device/Target Group Layout dialog */ void devTgtGrpLayoutDialog(CDKSCREEN *main_cdk_screen) { CDKSWINDOW *alua_info = 0; char *swindow_info[MAX_ALUA_LAYOUT_LINES] = {NULL}; int i = 0, line_pos = 0; char dir_name[MAX_SYSFS_PATH_SIZE] = {0}, tmp_buff[MAX_SYSFS_ATTR_SIZE] = {0}; DIR *dev_grp_dir_stream = NULL, *tgt_grp_dir_stream = NULL, *tgt_dir_stream = NULL, *dev_dir_stream = NULL; struct dirent *dev_grp_dir_entry = NULL, *tgt_grp_dir_entry = NULL, *tgt_dir_entry = NULL, *dev_dir_entry = NULL; /* Setup scrolling window widget */ alua_info = newCDKSwindow(main_cdk_screen, CENTER, CENTER, (ALUA_LAYOUT_ROWS + 2), (ALUA_LAYOUT_COLS + 2), "<C></31/B>SCST ALUA Device/Target Group Layout\n", MAX_ALUA_LAYOUT_LINES, TRUE, FALSE); if (!alua_info) { errorDialog(main_cdk_screen, SWINDOW_ERR_MSG, NULL); return; } setCDKSwindowBackgroundAttrib(alua_info, COLOR_DIALOG_TEXT); setCDKSwindowBoxAttribute(alua_info, COLOR_DIALOG_BOX); line_pos = 0; while (1) { /* We'll start with the SCST device groups */ snprintf(dir_name, MAX_SYSFS_PATH_SIZE, "%s/device_groups", SYSFS_SCST_TGT); if ((dev_grp_dir_stream = opendir(dir_name)) == NULL) { if (line_pos < MAX_ALUA_LAYOUT_LINES) { SAFE_ASPRINTF(&swindow_info[line_pos], "opendir(): %s", strerror(errno)); line_pos++; } break; } while ((dev_grp_dir_entry = readdir(dev_grp_dir_stream)) != NULL) { /* The device group names are directories; skip '.' and '..' */ if ((dev_grp_dir_entry->d_type == DT_DIR) && (strcmp(dev_grp_dir_entry->d_name, ".") != 0) && (strcmp(dev_grp_dir_entry->d_name, "..") != 0)) { if (line_pos < MAX_ALUA_LAYOUT_LINES) { SAFE_ASPRINTF(&swindow_info[line_pos], "</B>Device Group:<!B> %s", dev_grp_dir_entry->d_name); line_pos++; } /* Now get all of the device names for this device group */ snprintf(dir_name, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/devices", SYSFS_SCST_TGT, dev_grp_dir_entry->d_name); if ((dev_dir_stream = opendir(dir_name)) == NULL) { if (line_pos < MAX_ALUA_LAYOUT_LINES) { SAFE_ASPRINTF(&swindow_info[line_pos], "opendir(): %s", strerror(errno)); line_pos++; } break; } while ((dev_dir_entry = readdir(dev_dir_stream)) != NULL) { /* The device names are links */ if (dev_dir_entry->d_type == DT_LNK) { if (line_pos < MAX_ALUA_LAYOUT_LINES) { SAFE_ASPRINTF(&swindow_info[line_pos], "\t</B>Device:<!B> %s", dev_dir_entry->d_name); line_pos++; } } } closedir(dev_dir_stream); /* Now get all of the target groups for this device group */ snprintf(dir_name, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/target_groups", SYSFS_SCST_TGT, dev_grp_dir_entry->d_name); if ((tgt_grp_dir_stream = opendir(dir_name)) == NULL) { if (line_pos < MAX_ALUA_LAYOUT_LINES) { SAFE_ASPRINTF(&swindow_info[line_pos], "opendir(): %s", strerror(errno)); line_pos++; } break; } while ((tgt_grp_dir_entry = readdir(tgt_grp_dir_stream)) != NULL) { /* The target group names are directories; * skip '.' and '..' */ if ((tgt_grp_dir_entry->d_type == DT_DIR) && (strcmp(tgt_grp_dir_entry->d_name, ".") != 0) && (strcmp(tgt_grp_dir_entry->d_name, "..") != 0)) { if (line_pos < MAX_ALUA_LAYOUT_LINES) { snprintf(dir_name, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/target_groups/%s/group_id", SYSFS_SCST_TGT, dev_grp_dir_entry->d_name, tgt_grp_dir_entry->d_name); readAttribute(dir_name, tmp_buff); SAFE_ASPRINTF(&swindow_info[line_pos], "\t</B>Target Group:<!B> %s (Group ID: %s)", tgt_grp_dir_entry->d_name, tmp_buff); line_pos++; } /* Loop over each target name for the * current target group */ snprintf(dir_name, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/target_groups/%s", SYSFS_SCST_TGT, dev_grp_dir_entry->d_name, tgt_grp_dir_entry->d_name); if ((tgt_dir_stream = opendir(dir_name)) == NULL) { if (line_pos < MAX_ALUA_LAYOUT_LINES) { SAFE_ASPRINTF(&swindow_info[line_pos], "opendir(): %s", strerror(errno)); line_pos++; } break; } while ((tgt_dir_entry = readdir(tgt_dir_stream)) != NULL) { /* The target names are links (if local), * or directories (if remote); skip '.' and '..' */ if (((tgt_dir_entry->d_type == DT_DIR) && (strcmp(tgt_dir_entry->d_name, ".") != 0) && (strcmp(tgt_dir_entry->d_name, "..") != 0)) || (tgt_dir_entry->d_type == DT_LNK)) { if (line_pos < MAX_ALUA_LAYOUT_LINES) { snprintf(dir_name, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/" "target_groups/%s/%s/rel_tgt_id", SYSFS_SCST_TGT, dev_grp_dir_entry->d_name, tgt_grp_dir_entry->d_name, tgt_dir_entry->d_name); readAttribute(dir_name, tmp_buff); SAFE_ASPRINTF(&swindow_info[line_pos], "\t\t</B>Target:<!B> %s " "(Rel Tgt ID: %s)", tgt_dir_entry->d_name, tmp_buff); line_pos++; } } } closedir(tgt_dir_stream); } } closedir(tgt_grp_dir_stream); /* Print a blank line to separate targets */ if (line_pos < MAX_ALUA_LAYOUT_LINES) { SAFE_ASPRINTF(&swindow_info[line_pos], " "); line_pos++; } } } closedir(dev_grp_dir_stream); break; } /* Add a message to the bottom explaining how to close the dialog */ if (line_pos < MAX_ALUA_LAYOUT_LINES) { SAFE_ASPRINTF(&swindow_info[line_pos], " "); line_pos++; } if (line_pos < MAX_ALUA_LAYOUT_LINES) { SAFE_ASPRINTF(&swindow_info[line_pos], CONTINUE_MSG); line_pos++; } /* Set the scrolling window content */ setCDKSwindowContents(alua_info, swindow_info, line_pos); /* The 'g' makes the swindow widget scroll to the top, then activate */ injectCDKSwindow(alua_info, 'g'); activateCDKSwindow(alua_info, 0); /* We fell through -- the user exited the widget, but we don't care how */ destroyCDKSwindow(alua_info); /* Done */ for (i = 0; i < MAX_ALUA_LAYOUT_LINES; i++) FREE_NULL(swindow_info[i]); return; }