예제 #1
0
void DataHandler(char * data){
		/* data is the date received from uart.
		 * which has mode etc information encoded onto it.
		 */
	/* first I have to verify whether the data is correct then we have to interpre the data.
	 * step by step token by token.
	 */
	
	

		//call data validator.
		if(validateData(data)){	
			interpretData(data);	
		}
		else{
#ifdef DEBUG		
				printf("Data Validation failed");
#endif
		}






}
예제 #2
0
bool
GaduAddContactPage::apply( Kopete::Account* a , Kopete::MetaContact* mc )
{
    if ( validateData() ) {
        QString userid	= addUI_->addEdit_->text().trimmed();
        QString name	= addUI_->nickEdit_->text().trimmed();
        if ( a != account_ ) {
            kDebug(14100) << "Problem because accounts differ: " << a->accountId()
                          << " , " << account_->accountId() << endl;
        }
        if ( !a->addContact( userid,  mc, Kopete::Account::ChangeKABC )  ) {
            return false;
        }
        GaduContact *contact = static_cast<GaduContact*>( a->contacts().value( userid ) );

        contact->setProperty( GaduProtocol::protocol()->propEmail, addUI_->emailEdit_->text().trimmed() );
        contact->setProperty( GaduProtocol::protocol()->propFirstName, addUI_->fornameEdit_->text().trimmed() );
        contact->setProperty( GaduProtocol::protocol()->propLastName, addUI_->snameEdit_->text().trimmed() );
        contact->setProperty( GaduProtocol::protocol()->propPhoneNr, addUI_->telephoneEdit_ ->text().trimmed() );
        /*
        contact->setProperty( "ignored", i18n( "ignored" ), "false" );
        contact->setProperty( "nickName", i18n( "nickname" ), name );
        */
    }
    return true;
}
예제 #3
0
std::vector<ActiveControl> BinaryParse::fanFpsObject(UInt32 dataLength, void* esifData)
{
    std::vector<ActiveControl> controls;
    UInt8* data = reinterpret_cast<UInt8*>(esifData);
    data += sizeof(esif_data_variant); //Ignore revision field
    struct EsifDataBinaryFpsPackage* currentRow = reinterpret_cast<struct EsifDataBinaryFpsPackage*>(data);

    validateData(dataLength);

    // Subtracting one data variant here for the revision field
    UIntN rows = (dataLength - sizeof(esif_data_variant)) / sizeof(EsifDataBinaryFpsPackage);

    if ((dataLength - sizeof(esif_data_variant)) % sizeof(EsifDataBinaryFpsPackage))
    {
        // Data size mismatch, should be evenly divisible
        throw dptf_exception("Data size mismatch.");
    }

    for (UIntN i = 0; i < rows; i++)
    {
        ActiveControl temp(
            static_cast<UInt32>(currentRow->control.integer.value),
            static_cast<UInt32>(currentRow->tripPoint.integer.value),  // May want to represent this differently; -1 is MAX_INT for whatever type
            static_cast<UInt32>(currentRow->speed.integer.value),
            static_cast<UInt32>(currentRow->noiseLevel.integer.value),
            static_cast<UInt32>(currentRow->power.integer.value));

        controls.push_back(temp);

        data += sizeof(struct EsifDataBinaryFpsPackage);
        currentRow = reinterpret_cast<struct EsifDataBinaryFpsPackage*>(data);
    }

    return controls;
}
예제 #4
0
URLFormWidget::URLFormWidget(QWidget *parent) :
    AbstractFormWidget(parent), m_markEmpty(false)
{
    m_fieldNameLabel = new QLabel("Invalid Name", this);
    m_mainLayout = new QVBoxLayout(this);
    m_lineEdit = new QLineEdit(this);
    m_openURLAction = m_lineEdit->addAction(QIcon(":/images/icons/browser.png"),
                                            QLineEdit::TrailingPosition);
    m_openURLAction->setToolTip(tr("Open web link"));

    //static styling
    m_fieldNameLabel->setStyleSheet("QLabel {color: gray;}");

    //on mac disable focus rect around rounded borders
    m_lineEdit->setAttribute(Qt::WA_MacShowFocusRect, 0);

    m_mainLayout->addWidget(m_fieldNameLabel);
    m_mainLayout->addWidget(m_lineEdit);
    m_mainLayout->addStretch();

    this->heightUnits = 1;
    this->widthUnits = 1;

    //connections
    connect(m_lineEdit, SIGNAL(editingFinished()),
            this, SLOT(validateData()));
    connect(m_openURLAction, SIGNAL(triggered()),
            this, SLOT(openURLActionTriggered()));

    updateFocusPolicy();
}
예제 #5
0
ProgressFormWidget::ProgressFormWidget(QWidget *parent) :
    AbstractFormWidget(parent),
    m_maxValue(100)
{
    m_fieldNameLabel = new QLabel("Invalid Name", this);
    m_mainLayout = new QVBoxLayout(this);
    m_progressBar = new QProgressBar(this);
    m_spinBox = new QSpinBox(this);

    //static styling
    m_fieldNameLabel->setStyleSheet("QLabel {color: gray;}");

    m_progressLayout = new QHBoxLayout;
    m_progressLayout->addWidget(m_spinBox);
    m_progressLayout->addWidget(m_progressBar);

    m_mainLayout->addWidget(m_fieldNameLabel);
    m_mainLayout->addLayout(m_progressLayout);
    m_mainLayout->addStretch();

    m_spinBox->setSizePolicy(QSizePolicy::Fixed,
                             QSizePolicy::Fixed);
    m_progressBar->setSizePolicy(QSizePolicy::MinimumExpanding,
                                 QSizePolicy::Fixed);

    this->heightUnits = 1;
    this->widthUnits = 2;

    //connections
    connect(m_spinBox, SIGNAL(editingFinished()),
            this, SLOT(validateData()));

    setupFocusPolicy();
}
예제 #6
0
void FormDlgRuleSnippet::slotBtnSave()
{
    if (validateData())
    {
        writeRow();
        accept();
    }
}
예제 #7
0
void PMSettingsDialog::slotOk( )
{
   if( validateData( ) )
   {
      saveSettings( );
      QDialog::accept( );
   }
}
/**

Writes the sound data of the AIFF file to a temp file in the CS229 format

**/
File_Data AIFFtoTemp(FILE* outfile, FILE* infile, char * infilepath){
	File_Data data = processAIFF(outfile, infile);
	if(!validateData(data)){
		fprintf(stderr, "Error occured in COMM chunk\n");
		exit(-1);
	}
	processSSND(outfile, infilepath, data);
	return data;
}
예제 #9
0
void ScriptHandler::validateData(DataInformation* data)
{
    if (!data)
        return;

    data->setHasBeenValidated(false); //not yet validated

    if (data->hasChildren())
    {
        //first validate the children
        for (uint i = 0; i < data->childCount(); ++i)
        {
            validateData(data->childAt(i));
        }
    }

    //check if has a validation function:
    AdditionalData* additionalData = data->additionalData();
    if (additionalData && additionalData->validationFunction().isValid())
    {
        //value exists, we assume it has been checked to be a function
#ifdef OKTETA_DEBUG_SCRIPT
        mDebugger->attachTo(mEngine);
        mDebugger->action(QScriptEngineDebugger::InterruptAction)->trigger();
        kDebug()
        << "validating element: " << data->name();
#endif

//         QScriptValue thisObject = mEngine->newQObject(data,
//                 QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater);
//         QScriptValue mainStruct = mEngine->newQObject(data->mainStructure(),
//                 QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater);
        QScriptValue thisObject = data->toScriptValue(mEngine, &mHandlerInfo);
        QScriptValue mainStruct = data->mainStructure()->toScriptValue(mEngine, &mHandlerInfo);
        QScriptValueList args;
        args << mainStruct;
        QScriptValue result = additionalData->validationFunction().call(thisObject, args);
        if (result.isError())
        {
            ScriptUtils::object()->logScriptError(QLatin1String("error occurred while "
                "validating element ") + data->name(), result);
            data->setValidationError(QLatin1String("Error occurred in validation: ")
                    + result.toString());
        }
        if (mEngine->hasUncaughtException())
        {
            ScriptUtils::object()->logScriptError(
                    mEngine->uncaughtExceptionBacktrace());
            data->setValidationError(QLatin1String("Error occurred in validation: ")
                    + result.toString());
        }
        if (result.isBool() || result.isBoolean())
        {
            data->setValidationSuccessful(result.toBool());
        }
    }
}
예제 #10
0
std::vector<ThermalRelationshipTableEntry> BinaryParse::passiveTrtObject(UInt32 dataLength, void* esifData)
{
    std::vector<ThermalRelationshipTableEntry> controls;
    UInt8* data = reinterpret_cast<UInt8*>(esifData);
    struct EsifDataBinaryTrtPackage* currentRow = reinterpret_cast<struct EsifDataBinaryTrtPackage*>(data);

    validateData(dataLength);

    UIntN rows = countTrtRows(dataLength, data);

    // Reset currentRow to point to the beginning of the data block
    data = reinterpret_cast<UInt8*>(esifData);
    currentRow = reinterpret_cast<struct EsifDataBinaryTrtPackage*>(data);

    for (UIntN i = 0; i < rows; i++)
    {
        // Since the TRT has 2 strings in it, the process for extracting them is:
        //  1. Extract the source at the beginning of the structure
        //  2. Since the actual string data is placed between the source and target, the pointer needs moved
        //  3. Move the pointer past the source string data and set current row
        //  4. Now the targetDevice field will actually point to the right spot
        //  5. Extract target device
        //  6. Move the pointer as before (past the targetDevice string data) and set current row
        //  7. Extract the remaining fields
        //  8. Point data and currentRow to the next row

        std::string source(
            reinterpret_cast<const char*>(&(currentRow->sourceDevice)) + sizeof(union esif_data_variant),
            currentRow->sourceDevice.string.length);

        data += currentRow->sourceDevice.string.length;
        currentRow = reinterpret_cast<struct EsifDataBinaryTrtPackage*>(data);

        std::string target(
            reinterpret_cast<const char*>(&(currentRow->targetDevice)) + sizeof(union esif_data_variant),
            currentRow->targetDevice.string.length);

        data += currentRow->targetDevice.string.length;
        currentRow = reinterpret_cast<struct EsifDataBinaryTrtPackage*>(data);

        ThermalRelationshipTableEntry temp(
            normalizeAcpiScope(source),
            normalizeAcpiScope(target),
            static_cast<UInt32>(currentRow->thermalInfluence.integer.value),
            static_cast<UInt32>(currentRow->thermalSamplingPeriod.integer.value));

        controls.push_back(temp);

        // Since we've already accounted for the strings, we now move the pointer by the size of the structure
        //  to get to the next row.
        data += sizeof(struct EsifDataBinaryTrtPackage);
        currentRow = reinterpret_cast<struct EsifDataBinaryTrtPackage*>(data);
    }

    return controls;
}
void ProjectSelectionPage::itemChanged( const QModelIndex& current, const QModelIndex& )
{
    KStandardDirs* dirs = m_templatesModel->plugin()->componentData().dirs();
    QString picPath = dirs->findResource("apptemplate_previews", m_templatesModel->data( current, Qt::UserRole+2 ).toString() );
    if( picPath.isEmpty() ) 
    {
        picPath = dirs->findResource("apptemplate_previews", "default-kdevelop.png");
    }
    ui->preview->setPixmap( QPixmap( picPath ) );
    ui->description->setText( m_templatesModel->data( current ).toString() );
    validateData();
}
void convertCS229toAIFF(FILE* outfile, FILE* infile) {
    File_Data data;
    data.samples = -1;
    processHeader(infile, &data);

    if(!validateData(data)) {
        fprintf(stderr, "Error occured in header.\n");
        exit(-1);
    }
    getSamplesCS229(infile, &data);
    writeHeaderAIFF(outfile, data);
    setupSoundAIFF(outfile, data);
    writeSamplesAIFF(outfile, data);
}
예제 #13
0
LpmTable BinaryParse::lpmTableObject(UInt32 dataLength, void* binaryData)
{
    std::vector<LpmEntry> lpmTableEntries;
    UInt8* data = reinterpret_cast<UInt8*>(binaryData);
    struct EsifDataBinaryLpmtPackage* currentRow = reinterpret_cast<struct EsifDataBinaryLpmtPackage*>(data);
    esif_data_variant* dataVariant;
    LpmConfigurationVersion::Type version;

    validateData(dataLength);

    UIntN rows = countLpmtRows(dataLength, data);

    dataVariant = reinterpret_cast<esif_data_variant*>(binaryData);
    version = static_cast<LpmConfigurationVersion::Type>(dataVariant->integer.value);

    // Reset currentRow to point to the beginning of the data block
    data = reinterpret_cast<UInt8*>(binaryData);
    data += sizeof(esif_data_variant);
    currentRow = reinterpret_cast<struct EsifDataBinaryLpmtPackage*>(data);

    for (UIntN i = 0; i < rows; i++)
    {
        std::string target(
            reinterpret_cast<const char*>(&(currentRow->targetDevice)) + sizeof(union esif_data_variant),
            currentRow->targetDevice.string.length);

        data += currentRow->targetDevice.string.length;
        currentRow = reinterpret_cast<struct EsifDataBinaryLpmtPackage*>(data);

        // Convert from esif/acpi type to dptf type.
        esif_domain_type esifDomainType =
            static_cast<esif_domain_type>(currentRow->domainType.integer.value);
        DomainType::Type domainType = EsifDomainTypeToDptfDomainType(esifDomainType);
        LpmEntry lpmEntry(
            normalizeAcpiScope(target),
            domainType,
            static_cast<ControlKnobType::Type>(currentRow->controlKnob.integer.value),
            static_cast<UInt32>(currentRow->controlValue.integer.value));

        lpmTableEntries.push_back(lpmEntry);

        // Since we've already accounted for the strings, we now move the pointer by the size of the structure
        //  to get to the next row.
        data += sizeof(struct EsifDataBinaryLpmtPackage);
        currentRow = reinterpret_cast<struct EsifDataBinaryLpmtPackage*>(data);
    }

    return (LpmTable(version, lpmTableEntries));
}
File_Data CS229toTemp(FILE* outfile, FILE* infile) {
    File_Data data;
    data.samples = -1;
    strncpy(data.format, "CS229", 5);
    processHeader(infile, &data);

    if(!validateData(data)) {
        fprintf(stderr, "Error occured in header.\n");
        exit(-1);
    }

    getSamplesCS229(infile, &data);
    writeSamplesCS229(outfile, data);

    return data;
}
예제 #15
0
std::vector<PerformanceControl> BinaryParse::processorPssObject(UInt32 dataLength, void* esifData)
{
    std::vector<PerformanceControl> controls;
    UInt8* data = reinterpret_cast<UInt8*>(esifData);
    struct EsifDataBinaryPssPackage* currentRow = reinterpret_cast<struct EsifDataBinaryPssPackage*>(data);

    validateData(dataLength);

    UIntN rows = dataLength / sizeof(EsifDataBinaryPssPackage);

    if (dataLength % sizeof(EsifDataBinaryPssPackage))
    {
        // Data size mismatch, should be evenly divisible
        throw dptf_exception("Failed to parse PSS object.  The length of data received does not match the expected \
                             data length.");
    }
예제 #16
0
void mmTransDialog::OnOk(wxCommandEvent& event)
{
    m_trx_data.STATUS = "";
    m_trx_data.NOTES = textNotes_->GetValue();
    m_trx_data.TRANSACTIONNUMBER = textNumber_->GetValue();
    m_trx_data.TRANSDATE = dpc_->GetValue().FormatISODate();
    wxStringClientData* status_obj = (wxStringClientData*) choiceStatus_->GetClientObject(choiceStatus_->GetSelection());
    if (status_obj) m_trx_data.STATUS = Model_Checking::toShortStatus(status_obj->GetData());

    if (!validateData()) return;

    Model_Checking::Data *r = Model_Checking::instance().get(m_trx_data.TRANSID);
    if (m_new_trx || m_duplicate)
        r = Model_Checking::instance().create();

    Model_Checking::putDataToTransaction(r, m_trx_data);

    m_trx_data.TRANSID = Model_Checking::instance().save(r);

    Model_Splittransaction::Data_Set splt;
    for (const auto& entry : local_splits) 
    {
        Model_Splittransaction::Data *s = Model_Splittransaction::instance().create();
        s->CATEGID = entry.CATEGID;
        s->SUBCATEGID = entry.SUBCATEGID;
        s->SPLITTRANSAMOUNT = entry.SPLITTRANSAMOUNT;
        splt.push_back(*s);
    }
    Model_Splittransaction::instance().update(splt, m_trx_data.TRANSID);

    if (CustomFieldDialog_)
        CustomFieldDialog_->OnSave(true);

    if (m_new_trx || m_duplicate)
    {
        const wxString& RefType = Model_Attachment::reftype_desc(Model_Attachment::TRANSACTION);
        mmAttachmentManage::RelocateAllAttachments(RefType, -1, m_trx_data.TRANSID);
        Model_CustomFieldData::instance().RelocateAllData(RefType, -1, m_trx_data.TRANSID);
    }

    const Model_Checking::Data& tran(*r);
    Model_Checking::Full_Data trx(tran);
    wxLogDebug("%s", trx.to_json());
    EndModal(wxID_OK);
}
예제 #17
0
void ScriptHandler::validateData(DataInformation* data)
{
    Q_CHECK_PTR(data);

    if (data->hasBeenValidated())
        return;
    //first validate the children
    for (uint i = 0; i < data->childCount(); ++i)
        validateData(data->childAt(i));

    //check if has a validation function:
    QScriptValue validationFunc = data->validationFunc();
    if (validationFunc.isValid())
    {
        QScriptValue result = callFunction(validationFunc, data, ScriptHandlerInfo::Validating);
        if (result.isError())
        {
            mTopLevel->logger()->error(data) << "Error occurred while validating element: "
                    << result.toString();
            data->setValidationError(QStringLiteral("Error occurred in validation: ")
                    + result.toString());
        }
        else if (mEngine->hasUncaughtException())
        {
            mTopLevel->logger()->error(data) << "Error occurred while validating element:"
                    << result.toString() << "\nBacktrace:" << mEngine->uncaughtExceptionBacktrace();
            data->setValidationError(QStringLiteral("Error occurred in validation: ")
                    + result.toString());
            mEngine->clearExceptions();
        }
        if (result.isBool() || result.isBoolean())
        {
            data->mValidationSuccessful = result.toBool();
        }
        if (result.isString())
        {
            //error string
            QString str = result.toString();
            if (!str.isEmpty())
                data->setValidationError(str);
        }
        data->mHasBeenValidated = true;
    }
}
예제 #18
0
int KeyboardProxy::handleRawData(char *data, int bytes)
{
	int error = validateData(data, bytes);
	if (error != SUCCESS)
		return error;

	UCHAR inputData[KEYBOARD_PACKET_SIZE] = { 0 };
	set<UCHAR> currentKeysDown;
	copySet(&currentKeysDown, &lastKeysDown);

	// start with the keys that had no state change
	for (int i = 0; i < bytes; i += 2)
		if (lastKeysDown.find(data[i]) != lastKeysDown.end())
			currentKeysDown.erase(data[i]);

	// Do the rest of the data; there is a 6 key cap
	for (int i = 0; i < bytes && currentKeysDown.size() < 6; i += 2)
		if (data[i + 1])
			currentKeysDown.insert(data[i]);

	// create the data to send
	int index = 2;
	set<UCHAR>::iterator it;
	for (it = currentKeysDown.begin(); it != currentKeysDown.end(); ++it)
	{
		if (*it == 226) // left alt
			inputData[0] |= 0b00000100;
		if (*it == 224) // left control
			inputData[0] |= 0b00000001;
		if (*it == 225) // left shift
			inputData[0] |= 0b00000010;
		if (*it == 231) // left GUI
			inputData[0] |= 0b00001000;
		inputData[index] = *it;
		index++;
	}

	sendDataToDriver(inputData, KEYBOARD_PACKET_SIZE);

	copySet(&lastKeysDown, &currentKeysDown);

	return SUCCESS;
}
예제 #19
0
void DateFormWidget::editingFinishedSlot()
{
    //Get current field id (column) and record id
    int fieldId = -1;
    int recordId = -1;
    FormView *view = nullptr;
    QWidget *parent = parentWidget();
    if (parent)
        view = qobject_cast<FormView*>(parent->parentWidget());
    if (view) {
        int row = view->getCurrentRow();
        fieldId = view->getCurrentColumn();
        if (row != -1) {
            bool ok;
            int i = view->model()->data(view->model()->index(row, 0)).toInt(&ok);
            if (ok)
                recordId = i;
        }
    }

    //check if alarm trigger property is enabled
    //if it is, update alarm trigger in alarms table
    if (fieldId != -1) {
        MetadataEngine *meta = &MetadataEngine::getInstance();
        MetadataPropertiesParser parser(meta->getFieldProperties(
                                            MetadataEngine::TriggerProperty,
                                            fieldId));
        if (parser.size() > 0) {
            bool alarmTrigger = parser.getValue("alarmOnDate") == "1";

            //add or update alarm
            if ((recordId != -1) && (alarmTrigger)) {
                QDateTime dateTime(m_dateTimeEdit->dateTime());
                AlarmManager a(this);
                a.addOrUpdateAlarm(meta->getCurrentCollectionId(),
                                   fieldId, recordId, dateTime);
            }
        }
    }

    //save
    validateData();
}
예제 #20
0
static void
calculateDeltas(int sock, struct input_data *data)
{
    // Send Data to Engine via UDP
    send(sock, data, sizeof(struct input_data), 0);

    // Receive Data from Engine via UDP
    frame_t data_received, data_expected;
    validateData(data, &data_expected);
    int e = recv(sock, &data_received, sizeof(struct output_data), 0);

    printf("\nReceived: Quantity = %d, Delta = %d\n", data_received.spread_quantity, data_received.spread_delta);
    printf("Expected: Quantity = %d, Delta = %d\n", data_expected.spread_quantity, data_expected.spread_delta);
    if (e == -1)
    {
        printf("No bytes recv\n");
        exit(0);
    }
}
예제 #21
0
CheckboxFormWidget::CheckboxFormWidget(QWidget *parent) :
    AbstractFormWidget(parent)
{
    m_mainLayout = new QVBoxLayout(this);
    m_checkbox = new QCheckBox(this);

    m_mainLayout->addStretch();
    m_mainLayout->addWidget(m_checkbox);
    m_mainLayout->addStretch();

    this->heightUnits = 1;
    this->widthUnits = 1;

    //connections
    connect(m_checkbox, SIGNAL(clicked()),
            this, SLOT(validateData()));

    setupFocusPolicy();
}
/**

Trims the cs229 sample data for every element in the pointer highlow
Size is the amount of highlow combinations there are

**/
void trimCS229(highlow_t *highlow, int size) {

    File_Data data;
    data.samples = -1;
    processHeader(stdin, &data);

    if(!validateData(data)) {
        fprintf(stderr, "Error occured in header.\n");
        exit(-1);
    }

    getSamplesCS229(stdin, &data);

    int i;
    for(i = 0; i < size; i++) {
        cut(&data, highlow[i].low, highlow[i].high);
    }
    writeHeaderCS229(stdout, data);
    writeSamplesCS229(stdout, data);
}
예제 #23
0
void BillingWindow::on_submitButton_clicked()
{
    qDebug() << "Submit button was clicked in billing window";

    if (validateData()) {
        CreditCardInfo *cInfo = new CreditCardInfo(ui->nameField->text(), ui->emailField->text(), "", "", ui->nameField->text(), ui->numberField->text(), ui->expiryField->text(), ui->codeField->text());
        DeliveryInfo *dInfo = new DeliveryInfo(ui->emailField->text());
        placeOrderCtrl->getStudent()->setCreditCardInfo(cInfo);
        placeOrderCtrl->getStudent()->setDeliveryInfo(dInfo);

        placeOrderCtrl->submitOrder();

        delete cInfo;
        delete dInfo;

        placeOrderCtrl = NULL;
        this->close();
    }

}
예제 #24
0
ActiveControlStatus* BinaryParse::fanFstObject(UInt32 dataLength, void* esifData)
{
    ActiveControlStatus* control;
    UInt8* data = reinterpret_cast<UInt8*>(esifData);
    struct EsifDataBinaryFstPackage* currentRow = reinterpret_cast<struct EsifDataBinaryFstPackage*>(data);

    validateData(dataLength);

    if (dataLength != sizeof(EsifDataBinaryFstPackage))
    {
        //Data size mismatch
        throw dptf_exception("Data size mismatch.");
    }

    control = new ActiveControlStatus(
        static_cast<UInt32>(currentRow->control.integer.value),
        static_cast<UInt32>(currentRow->speed.integer.value));

    return control;
}
예제 #25
0
bool IRCAddContactPage::apply( Kopete::Account* a, Kopete::MetaContact* m )
{
	if ( validateData() )
	{
		QString name = m_ircAddUI.m_uniqueName->text();

		if ( a->addContact(name, m, Kopete::Account::ChangeKABC ) )
		{
			IRCContact * newContact = qobject_cast<IRCContact*>( Kopete::ContactList::self()->findContact( a->protocol()->pluginId(), a->accountId(), name ) );
			if ( newContact )
			{
				newContact->setType( m_ircAddUI.m_rbEcho->isChecked() ? IRCContact::Echo : IRCContact::Group );
				return true;
			}
		}
		else
			return false;
	}
	return false;
}
/**

Trims the sound data of a AIFF file for every high low combo in highlow
The size argument specifies how many high low combos are present in highlow

**/
File_Data trimAIFF(highlow_t* highlow, int size){

	File_Data data = processAIFF(stdout, stdin);
	if(!validateData(data)){
		fprintf(stderr, "Error occured in COMM chunk\n");
		exit(-1);
	}
	getSamplesAIFF(NULL, &data);

	int i;

	for(i = 0; i < size; i++){
		cut(&data, highlow[i].low, highlow[i].high);
	}

	writeHeaderAIFF(stdout, data);

	setupSoundAIFF(stdout, data);

	writeSamplesAIFF(stdout, data);
}
/**

Shows the samples of an AIFF file

**/
File_Data showAIFF(FILE* file, char* fileName, int width, int zoom, int chan, int curses){
	File_Data data = processAIFF(stdout, file);
	if(!validateData(data)){
		if(curses)
			endwin();
		fprintf(stderr, "Error occured in COMM chunk\n");
		exit(-1);
	}
	getSamplesAIFF(fileName, &data);

	if(curses){
		int rows, cols;
		getmaxyx(stdscr, rows, cols);
		int botSamp = (rows - 3) / data.channels;
		showSamplesRange(data, width, zoom, chan, curses, 0, botSamp, 0, botSamp*(rows - 3) - botSamp * data.channels);
	}
	else
		showSamples(data, width, zoom, chan, curses);

	return data;
}
예제 #28
0
ActiveControlStaticCaps* BinaryParse::fanFifObject(UInt32 dataLength, void* esifData)
{
    ActiveControlStaticCaps* control;
    UInt8* data = reinterpret_cast<UInt8*>(esifData);
    struct EsifDataBinaryFifPackage* currentRow = reinterpret_cast<struct EsifDataBinaryFifPackage*>(data);

    validateData(dataLength);

    if (dataLength != sizeof(EsifDataBinaryFifPackage))
    {
        //Data size mismatch
        throw dptf_exception("Data size mismatch.");
    }

    control = new ActiveControlStaticCaps(
        (static_cast<UInt32>(currentRow->hasFineGrainControl.integer.value) != 0),
        (static_cast<UInt32>(currentRow->supportsLowSpeedNotification.integer.value) != 0),
        static_cast<UInt32>(currentRow->stepSize.integer.value));

    return control;
}
예제 #29
0
MainWindow::MainWindow(dataStorageInterface* dataStorageType,QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    this->dataStorageType = dataStorageType;
    ui->setupUi(this);

    //Reset all the input fields
    resetFields();
    ui->dateEdit->setDisplayFormat("dd - MMMM - yyyy");

    //Display today's Occasion from the existing data
    displayOccasions();

    //Connecting to the Slots
    connect(ui->pushAdd, SIGNAL(clicked()),this, SLOT(validateData()));
    connect(ui->pushAdd, SIGNAL(clicked()),this, SLOT(resetFields()));
    connect(ui->pushSave, SIGNAL(clicked()),this, SLOT(saveData()));
    connect(ui->pushReset, SIGNAL(clicked()),this, SLOT(resetFields()));
    connect(ui->pushRevert, SIGNAL(clicked()),this, SLOT(revert()));
}
예제 #30
0
void NewAccountDialog::frameActionReceived( GeneralFrame* frame,const std::string& action )
{
    if(action == "cancel")
    {
        hideGeneralFrame();
    }
    else
    {
        if(validateData())
        {
            /*
            std::string gender;
            if(m_gender->getSelectedIndex() == 0)
            	gender = "m";
            else
            gender = "f";

            std::stringstream ss;
            int year = 0;
            int month = m_birthday[0]->getSelectedIndex();
            month++;
            ss.clear();
            ss.str("");
            ss << m_birthday[1]->getItemAt(m_birthday[1]->getSelectedIndex());
            int day = 0;
            ss >> day;
            ss.clear();
            ss.str("");
            ss << m_birthday[2]->getItemAt(m_birthday[2]->getSelectedIndex());
            ss >> year;
            */
            DISPATCH_LOBBY_EVENT
            (*it)->createAccount(m_txtUsername->getText(),
                                 m_txtPassword->getPassword(),
                                 m_txtEmail->getText(),m_txtFirstName->getText(),m_txtLastName->getText());
        }
    }

}