Пример #1
0
    void LoginPage::init()
    {
        QMap<QString, QString> countryCodes = Utils::GetCountryCodes();
        combobox_->setEditBoxClass("CountrySearchEdit");
        combobox_->setComboboxViewClass("CountrySearchView");
        combobox_->setClass("CountySearchWidgetInternal");
        combobox_->setPlaceholder(QT_TRANSLATE_NOOP("login_page","Type country or code"));
        country_search_widget_->layout()->addWidget(combobox_);
        combobox_->setSources(countryCodes);

        connect(combobox_, SIGNAL(selected(QString)), this, SLOT(countrySelected(QString)), Qt::QueuedConnection);
        connect(this, SIGNAL(country(QString)), this, SLOT(redrawCountryCode()), Qt::QueuedConnection);
        connect(next_page_link_, SIGNAL(clicked()), this, SLOT(nextPage()), Qt::QueuedConnection);
        connect(prev_page_link_, SIGNAL(clicked()), this, SLOT(prevPage()), Qt::QueuedConnection);
        connect(edit_phone_button_, SIGNAL(clicked()), this, SLOT(prevPage()), Qt::QueuedConnection);
        connect(edit_phone_button_, SIGNAL(clicked()), this, SLOT(stats_edit_phone()), Qt::QueuedConnection);
        connect(switch_login_link_, SIGNAL(clicked()), this, SLOT(switchLoginType()), Qt::QueuedConnection);
        connect(resend_button_, SIGNAL(clicked()), this, SLOT(sendCode()), Qt::QueuedConnection);
        connect(resend_button_, SIGNAL(clicked()), this, SLOT(stats_resend_sms()), Qt::QueuedConnection);
        connect(timer_, SIGNAL(timeout()), this, SLOT(updateTimer()), Qt::QueuedConnection);

        connect(proxy_settings_link_, SIGNAL(clicked()), this, SLOT(openProxySettings()), Qt::QueuedConnection);

        country_code_->setProperty("CountryCodeEdit", true);
        phone_->setProperty("PhoneNumberEdit", true);
        phone_->setAttribute(Qt::WA_MacShowFocusRect, false);
        phone_->setPlaceholderText(QT_TRANSLATE_NOOP("login_page","your phone number"));
        phone_widget_->layout()->addWidget(country_code_);
        phone_widget_->layout()->addWidget(phone_);
        Testing::setAccessibleName(phone_, "StartWindowPhoneNumberField");

        connect(country_code_, SIGNAL(focusIn()), this, SLOT(setPhoneFocusIn()), Qt::QueuedConnection);
        connect(country_code_, SIGNAL(focusOut()), this, SLOT(setPhoneFocusOut()), Qt::QueuedConnection);
        connect(phone_, SIGNAL(focusIn()), this, SLOT(setPhoneFocusIn()), Qt::QueuedConnection);
        connect(phone_, SIGNAL(focusOut()), this, SLOT(setPhoneFocusOut()), Qt::QueuedConnection);

        connect(uin_login_edit_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(uin_password_edit_, SIGNAL(textEdited(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(code_edit_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(code_edit_, SIGNAL(textChanged(QString)), this, SLOT(codeEditChanged(QString)), Qt::QueuedConnection);
        connect(country_code_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(country_code_, SIGNAL(textEdited(QString)), this, SLOT(countryCodeChanged(QString)), Qt::QueuedConnection);
        connect(phone_, SIGNAL(textChanged(QString)), this, SLOT(clearErrors()), Qt::QueuedConnection);
        connect(phone_, SIGNAL(emptyTextBackspace()), this, SLOT(emptyPhoneRemove()), Qt::QueuedConnection);

        QObject::connect(Ui::GetDispatcher(), SIGNAL(getSmsResult(int64_t, int, int)), this, SLOT(getSmsResult(int64_t, int, int)), Qt::DirectConnection);
        QObject::connect(Ui::GetDispatcher(), SIGNAL(loginResult(int64_t, int)), this, SLOT(loginResult(int64_t, int)), Qt::DirectConnection);
        QObject::connect(Ui::GetDispatcher(), SIGNAL(loginResultAttachUin(int64_t, int)), this, SLOT(loginResultAttachUin(int64_t, int)), Qt::DirectConnection);
        QObject::connect(Ui::GetDispatcher(), SIGNAL(loginResultAttachPhone(int64_t, int)), this, SLOT(loginResultAttachPhone(int64_t, int)), Qt::DirectConnection);

        country_code_->setValidator(new QRegExpValidator(QRegExp("[\\+\\d]\\d*")));
        phone_->setValidator(new QRegExpValidator(QRegExp("\\d*")));
        code_edit_->setValidator(new QRegExpValidator(QRegExp("\\d*")));

        combobox_->selectItem(Utils::GetTranslator()->getCurrentPhoneCode());
        error_label_->hide();
        phone_->setFocus();
        country_code_->setFocusPolicy(Qt::ClickFocus);
        initLoginSubPage(SUBPAGE_PHONE_LOGIN_INDEX);
    }
Пример #2
0
    void LoginPage::nextPage()
    {
        setFocus();
        clearErrors();
        if (login_staked_widget_->currentIndex() == SUBPAGE_PHONE_LOGIN_INDEX)
        {
            entered_phone_->setText(country_code_->text() + phone_->text());
            entered_phone_->adjustSize();
            country_code_->setEnabled(false);
            phone_->setEnabled(false);
            sendCode();
        }
        else if (login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX)
        {
            uin_login_edit_->setEnabled(false);
            uin_password_edit_->setEnabled(false);
            gui_coll_helper collection(GetDispatcher()->create_collection(), true);
            collection.set_value_as_qstring("login", uin_login_edit_->text());
            collection.set_value_as_qstring("password", uin_password_edit_->text());
            collection.set_value_as_bool("save_auth_data", keep_logged_->isChecked());
            collection.set_value_as_bool("not_log", true);

            if (is_login_)
            {
                send_seq_ = GetDispatcher()->post_message_to_core("login_by_password", collection.get());
            }
            else
            {
                send_seq_ = GetDispatcher()->post_message_to_core("login_by_password_for_attach_uin", collection.get());
            }
        }
    }
Пример #3
0
QVariant WorkbookParserPrivate::parse() {

    QString expression;
    QModelIndex index;

    // TODO possibly a range of data has changed.

    if (pWorkbook) {
        index = pWorkbook->currentWorksheetView()->currentIndex();
        expression = pWorkbook->currentWorksheetView()->model()->data(index).toString();
    } else if (pWorksheet) {
        index = pWorksheet->currentIndex();
        expression = pWorksheet->model()->data(index).toString();
    }

    clearErrors();

    // formulae must start with an = sign but it has no relevance later.
    if (expression.startsWith("=")) {
        QStringList tokenList = splitExpression(expression.mid(1));
        tokenise(tokenList);
    }

    return QVariant(QVariant::Double);

}
Пример #4
0
    void LoginPage::getSmsResult(int64_t _seq, int result, int _code_length)
    {
        if (_seq != send_seq_)
            return;

        country_code_->setEnabled(true);
        phone_->setEnabled(true);
        setErrorText(result);
        error_label_->setVisible(result);
        if (result == core::le_success)
        {
            if (_code_length != 0)
                code_length_ = _code_length;
            clearErrors();
            return initLoginSubPage(SUBPAGE_PHONE_CONF_INDEX);
        }

        phone_widget_->setProperty("EnterPhoneWidgetError", true);
        phone_widget_->setProperty("EnterPhoneWidgetFocused", false);
        phone_widget_->setProperty("EnterPhoneWidget", false);
        phone_widget_->setStyle(QApplication::style());
        phone_->setProperty("PhoneNumberError", true);
        phone_->setStyle(QApplication::style());
        emit country(country_code_->text());
    }
Пример #5
0
void FourWheelOmniPilot::updateErrors(float x_goal, float y_goal)
{
    // Reset queues if the target has moved
    if(Measurements::distance(Point(x_goal,y_goal), prev_goal_target) > 50)
        clearErrors();

    //Integral Error for distance
    if (dist_error_deque.size() == DIST_ERROR_MAXSIZE) {
        double popped_integral = dist_error_integral - dist_error_deque.front();
        double sign_popped_integral = (popped_integral > 0) - (popped_integral < 0);
        dist_error_integral = std::min(1000000.0, fabs(popped_integral)) * sign_popped_integral;
        dist_error_deque.pop_front();
    }
    double pushed_integral = dist_error_integral + distance_error;
    double sign_pushed_integral = (pushed_integral > 0) - (pushed_integral < 0);
    dist_error_integral = std::min(1000000.0, fabs(pushed_integral)) * sign_pushed_integral;
    dist_error_deque.push_back(distance_error);

    //Integral Error for orientation
    if (angle_error_deque.size() == ANGLE_ERROR_MAXSIZE) {
        angle_error_integral -= angle_error_deque.front();
        angle_error_deque.pop_front();
    }
    angle_error_integral += angle_error;
    angle_error_deque.push_back(angle_error);

    //std::cout << "DIST ERR INT: " << dist_error_integral << std::endl;
}
Пример #6
0
std::vector<Hero::SKYCS> Hero::getConvertibleSkyCS()
{
    if( m_ast.origWcsInfo == AST__NULL) {
        return { SKYCS::PIXEL };
    }

    AstErrorGuard guard( this); // intercept errors
    AstGCGuard gcGuard;

    // go through all known systems and find out which can be used
    std::vector<SKYCS> res;
    for( auto & cs : getAllKnownCS()) {
        if( cs == m_originalSkyCs) {
            res.push_back( cs);
            continue;
        }
        void * testFrame = astCopy( m_ast.origWcsInfo);
        std::string str = QString("System=%1").arg( skycs2string(cs)).toStdString();
        dbg(1) << "Trying " << str;
        AstWrappers::set( testFrame, QString("System=%1").arg( skycs2string(cs)));
        if ( ! astOK ) {
            clearErrors();
            astClearStatus;
        }
        else {
            res.push_back( cs);
        }
    }

    astClearStatus;
    return res;
}
Пример #7
0
void OPA::enable()
{
	digitalWrite(OPA_CS1_PIN, OPA_CS1_STATE(address));
	digitalWrite(OPA_CS2_PIN, OPA_CS2_STATE(address));
	SerialPort.begin(OPA_BAUDRATE);
	SerialPort.setTimeout(OPA_SERIAL_TIMEOUT);
	clearErrors();
}
Пример #8
0
 void LoginPage::switchLoginType()
 {
     setFocus();
     clearErrors();
     initLoginSubPage(login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX ? SUBPAGE_PHONE_LOGIN_INDEX : SUBPAGE_UIN_LOGIN_INDEX);
     GetDispatcher()->post_stats_to_core(login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX 
         ? core::stats::stats_event_names::reg_page_uin : core::stats::stats_event_names::reg_page_phone);
 }
Пример #9
0
 const char*  XSDHelperImpl::define(std::istream& schema)
 {
     SDOSchemaSAX2Parser schemaParser(schemaInfo, this, parsedLocations, definedNamespaces);
     clearErrors();
     schema  >> schemaParser;
     defineTypes(schemaParser.getTypeDefinitions());
     return schemaInfo.getTargetNamespaceURI();
 }
Пример #10
0
//--------------------------------------------------
// Prepares a new signature for signing and calculates
// the final hash value to sign.
// pSigDoc - signed document object
// ppSigInfo - pointer for address of newly allocated signature
// manifest - manifest or role
// city - signers address , city
// state - signers address , state or province
// zip - signers address , postal code
// country - signers address , country name
// id - id for new signature. Optional, use NULL for default
// return returns error code or ERR_OK
//--------------------------------------------------
EXP_OPTION int ddocPrepareSignature(SignedDoc* pSigDoc, SignatureInfo** ppSigInfo,
                                    const char* manifest, const char* city,
                                    const char* state, const char* zip,
                                    const char* country, X509* pCert, const char* id)
{
    int err = ERR_OK, l1;
    DigiDocMemBuf mbuf1, *pMBuf1;
    char buf1[50];

    mbuf1.pMem = 0;
    mbuf1.nLen = 0;
    ddocDebug(3, "ddocPrepareSignature", "Preparing signature manifest: %s country: %s, state: %s, city: %s, zip: %s, cert: %s, id: %s",
              (manifest ? manifest : "NULL"), (country ? country : "NULL"),
              (state ? state : "NULL"), (city ? city : "NULL"), (zip ? zip : "NULL"),
              (pCert ? "OK" : "ERROR"), (id ? id : "NULL"));
    // check mandator fields
    RETURN_IF_NULL_PARAM(pSigDoc);
    RETURN_IF_NULL_PARAM(ppSigInfo);
    RETURN_IF_NULL_PARAM(pCert);
    clearErrors();
    // add new signature
    err = SignatureInfo_new(ppSigInfo, pSigDoc, id);
    RETURN_IF_NOT(err == ERR_OK, err);
    // automatically calculate doc-info elements for this signature
    addAllDocInfos(pSigDoc, *ppSigInfo);
    // add signature production place
    if (city || state || zip || country)
        err = setSignatureProductionPlace(*ppSigInfo, city, state, zip, country);
    // add user roles/manifests
    if (manifest)
        err = addSignerRole(*ppSigInfo, 0, manifest, -1, 0);
    RETURN_IF_NOT(err == ERR_OK, err);
    // add signers certificate
    err = setSignatureCert(*ppSigInfo, pCert);
    RETURN_IF_NOT(err == ERR_OK, err);
    // timestamp
    createTimestamp(pSigDoc, (char*)buf1, sizeof(buf1));
    setString((char**)&((*ppSigInfo)->szTimeStamp), (const char*)buf1, -1);
    // now calculate signed properties digest
    err = calculateSignedPropertiesDigest(pSigDoc, *ppSigInfo);
    // TODO: replace later
    pMBuf1 = ddocDigestValue_GetDigestValue((*ppSigInfo)->pSigPropDigest);
    ddocSigInfo_SetSigPropRealDigest(*ppSigInfo,
                                     (const char*)pMBuf1->pMem, pMBuf1->nLen);
    // signature type & val
    ddocSignatureValue_new(&((*ppSigInfo)->pSigValue), 0, SIGN_RSA_NAME, 0, 0);
    // calc signed-info digest
    l1 = sizeof(buf1);
    err = calculateSignedInfoDigest(pSigDoc, *ppSigInfo, (byte*)buf1, &l1);
    err = ddocSigInfo_SetSigInfoRealDigest(*ppSigInfo, buf1, l1);
    // debug output - final hash to sign
    pMBuf1 = ddocDigestValue_GetDigestValue((*ppSigInfo)->pSigInfoRealDigest);
    ddocEncodeBase64(pMBuf1, &mbuf1);
    ddocDebug(3, "ddocPrepareSignature", "signing hash %s len: %d b64len: %d",
              (char*)mbuf1.pMem, mbuf1.nLen, l1);
    ddocMemBuf_free(&mbuf1);
    return err;
}
Пример #11
0
void ExprEditor::setExpr(const std::string& expression,const bool doApply)
{
    //exprTe->clear();
    exprTe->selectAll();
    exprTe->insertPlainText(QString::fromStdString(expression));
    clearErrors();
    exprTe->moveCursor(QTextCursor::Start);
    if(doApply) emit apply();
}
Пример #12
0
void DocumentLoader::prepareForLoadStart()
{
    ASSERT(!m_isStopping);
    setPrimaryLoadComplete(false);
    ASSERT(frameLoader());
    clearErrors();
    
    setLoading(true);
    
    frameLoader()->prepareForLoadStart();
}
Пример #13
0
/// loads the given keymap file returns true on  success
/// @param filename the filename to parse
/// @return true if the file was parsed
bool JsonParser::parse(const QString& fileName )
{
    clearErrors();
    QFile file(fileName);
    if( file.open( QIODevice::ReadOnly ) ) {
        bool result = parse( &file );
        file.close();
        return result;
    } else {
        errorMessage_ = file.errorString();
        return false;
    }
}
Пример #14
0
ExprEditor::ExprEditor(QWidget* parent,ExprControlCollection* controls)
    : QWidget(parent),_updatingText(0),errorHeight(0)
{
    // timers
    controlRebuildTimer=new QTimer();
    previewTimer=new QTimer();

    // title and minimum size
    setWindowTitle("Expression Editor");
    setMinimumHeight(100);

    // expression controls, we need for signal connections
    this->controls = controls;

    // make layout
    QVBoxLayout* exprAndErrors=new QVBoxLayout;
    exprAndErrors->setMargin(0);
    setLayout(exprAndErrors);

    // create text editor widget
    exprTe = new ExprTextEdit(this);
    exprTe->setMinimumHeight(50);
    
    // calibrate the font size
    int fontsize = 12;
    while (QFontMetrics(QFont("Liberation Sans",fontsize)).width("abcdef")<38 && fontsize<20) 
	fontsize++;
    while (QFontMetrics(QFont("Liberation Sans",fontsize)).width("abcdef")>44 && fontsize>3) 
	fontsize--;
    
    exprTe->setFont(QFont("Liberation Sans",fontsize));
    
    exprAndErrors->addWidget(exprTe);

    // create error widget
    errorWidget=new QListWidget();
    errorWidget->setSelectionMode(QAbstractItemView::SingleSelection);
    errorWidget->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum));
    connect(errorWidget,SIGNAL(itemSelectionChanged()),SLOT(selectError()));
    clearErrors();
    exprAndErrors->addWidget(errorWidget);

    // wire up signals
    connect(exprTe, SIGNAL(applyShortcut()), SLOT(sendApply()));
    connect(exprTe, SIGNAL(nextError()), SLOT(nextError()));
    connect(exprTe, SIGNAL(textChanged()), SLOT(exprChanged()));
    connect(controls,SIGNAL(controlChanged(int)),SLOT(controlChanged(int)));
    connect(controls,SIGNAL(insertString(const std::string&)),SLOT(insertStr(const std::string&)));
    connect(controlRebuildTimer, SIGNAL(timeout()), SLOT(rebuildControls()));
    connect(previewTimer, SIGNAL(timeout()), SLOT(sendPreview()));
}
Пример #15
0
//--------------------------------------------------
// Checks DigiDoc library internal errors
//--------------------------------------------------
EXP_OPTION int checkDigiDocErrors()
{
  char *errorClass[] = {"NO_ERRORS", "TECHNICAL", "USER", "LIBRARY"};
  int err = ERR_OK;
  while(hasUnreadErrors()) {
    ErrorInfo* pErr = getErrorInfo();
    char* pErrStr = getErrorString(pErr->code);
    printf("Error: %d - %s; file: %s line: %d; failed condition: %s, error class : %s\n",
	   pErr->code, pErrStr, pErr->fileName, pErr->line, pErr->assertion, errorClass[getErrorClass(pErr->code)]);
    err = pErr->code;
  }
  clearErrors();
  return err;
}
Пример #16
0
void main( int argc, char *argv[] )
{

	calibrateClock();
	filterBank[actualFilter] = defaultIirFilterInfo();

	for( i=1; i<argc; i++ ) {
		parseInput(argv[i], INPUT_BUF_SIZE);
		if( getErrors() ) {
			printErrors();
			clearErrors();
		}
	}

	while(1) {
		scanf("%s", inputBuffer);
		parseInput(inputBuffer, INPUT_BUF_SIZE);
		if( getErrors() ) {
			printErrors();
			clearErrors();
		}
	}

}
Пример #17
0
/// Parses the given QIODevice
/// @param device the device to parse the json data
/// @return true if the file was successfully parsed
bool JsonParser::parse( QIODevice* device )
{
    clearErrors();
    bool opened = false;
    if( !device->isOpen() ) {
        if( !device->open( QIODevice::ReadOnly) ) {
            errorMessage_ = device->errorString();
            return false;
        }
        opened = true;
    }

    QByteArray bytesIn = device->readAll();
    bool result = parse( bytesIn );
    if( opened ) device->close();
    return result;
}
Пример #18
0
	void LoginPage::getSmsResult(int result)
	{
		country_code_->setEnabled(true);
		phone_->setEnabled(true);
		setErrorText(result);
		error_label_->setVisible(result);
		if (result == core::le_success)
		{
			clearErrors();
			return initLoginSubPage(SUBPAGE_PHONE_CONF_INDEX);
		}

		phone_widget_->setProperty("EnterPhoneWidgetError", true);
		phone_widget_->setProperty("EnterPhoneWidgetFocused", false);
		phone_widget_->setProperty("EnterPhoneWidget", false);
		phone_widget_->setStyle(QApplication::style());
		emit country(country_code_->text());
	}
Пример #19
0
void main(void)
{
	calibrateClock();
	initializeDevice();

	while(1) {
		if( pendingCommand ) {
		
			if( pendingCommand == LONG_COMMAND ) {
				// error
			} else {
				parseInput(inputBuffer, INPUT_BUF_SIZE);
			}
			
			if( getErrors() ) {
				printErrors();
				clearErrors();
			}
			
		}
	}
}
Пример #20
0
    void LoginPage::loginResult(int64_t _seq, int result)
    {
        if (_seq != send_seq_)
            return;

        updateErrors(result);
        if (result == 0)
        {
            if (login_staked_widget_->currentIndex() == SUBPAGE_PHONE_CONF_INDEX)
            {
                code_edit_->setText("");
                initLoginSubPage(SUBPAGE_PHONE_LOGIN_INDEX);
            }

            GetDispatcher()->post_stats_to_core(login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX 
                ? core::stats::stats_event_names::reg_login_uin
                : core::stats::stats_event_names::reg_login_phone);

            clearErrors();
            emit loggedIn();
        }
    }
Пример #21
0
	void LoginPage::loginResult(int result)
	{
		code_edit_->setEnabled(true);
		uin_login_edit_->setEnabled(true);
		uin_password_edit_->setEnabled(true);
		setErrorText(result);
		error_label_->setVisible(result);

		if (login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX)
		{
			uin_login_edit_->setProperty("UinError", true);
			uin_login_edit_->setProperty("Uin", false);
			uin_login_edit_->setStyle(QApplication::style());
			uin_password_edit_->clear();
		}
		else
		{
			code_edit_->setProperty("EnteredCodeError", true);
			code_edit_->setProperty("EnteredCode", false);
			code_edit_->setStyle(QApplication::style());
		}

		if (result == 0)
        {
            if (login_staked_widget_->currentIndex() == SUBPAGE_PHONE_CONF_INDEX)
            {
                code_edit_->setText("");
                initLoginSubPage(SUBPAGE_PHONE_LOGIN_INDEX);
            }
                        
            GetDispatcher()->post_stats_to_core(login_staked_widget_->currentIndex() == SUBPAGE_UIN_LOGIN_INDEX 
                ? core::stats::stats_event_names::reg_login_uin
                : core::stats::stats_event_names::reg_login_phone);

            clearErrors();
			emit loggedIn();
        }
	}
Пример #22
0
/// opens the given bytes as a json document
/// @param bytesIn the bytes of the Json document
/// @return true if the data was succeeful parsed
bool JsonParser::parse(const QByteArray& bytesIn)
{
    clearErrors();
    QByteArray bytes = stripCommentsFromJson( bytesIn );
    QJsonParseError parseResult;
    QJsonDocument document = QJsonDocument::fromJson( bytes, &parseResult );
    if( parseResult.error != QJsonParseError::NoError ) {
        errorMessage_ = parseResult.errorString();
        errorOffset_ = parseResult.offset;

        // convert the offset to a column and offset
        errorLine_ = errorColumn_ = 0;
        for( int i=0, cnt=qMin( errorOffset_,bytes.size()); i<cnt; ++i ) {
            ++errorColumn_;
            if( bytes.at(i) == '\n' ) {
                errorColumn_= 0;
                ++errorLine_;
            }
        }
        return false;
    }
    result_ = document.toVariant();
    return true;
}
Пример #23
0
 ~xmlErrorVec() {
   clearErrors();
 }
Пример #24
0
// load given song
void Song::loadProject( const QString & fileName )
{
	QDomNode node;

	m_loadingProject = true;

	Engine::projectJournal()->setJournalling( false );

	m_oldFileName = m_fileName;
	m_fileName = fileName;

	DataFile dataFile( m_fileName );
	// if file could not be opened, head-node is null and we create
	// new project
	if( dataFile.head().isNull() )
	{
		if( m_loadOnLaunch )
		{
			createNewProject();
		}
		m_fileName = m_oldFileName;
		return;
	}

	m_oldFileName = m_fileName;

	clearProject();

	clearErrors();

	DataFile::LocaleHelper localeHelper( DataFile::LocaleHelper::ModeLoad );

	Engine::mixer()->requestChangeInModel();

	// get the header information from the DOM
	m_tempoModel.loadSettings( dataFile.head(), "bpm" );
	m_timeSigModel.loadSettings( dataFile.head(), "timesig" );
	m_masterVolumeModel.loadSettings( dataFile.head(), "mastervol" );
	m_masterPitchModel.loadSettings( dataFile.head(), "masterpitch" );

	if( m_playPos[Mode_PlaySong].m_timeLine )
	{
		// reset loop-point-state
		m_playPos[Mode_PlaySong].m_timeLine->toggleLoopPoints( 0 );
	}

	if( !dataFile.content().firstChildElement( "track" ).isNull() )
	{
		m_globalAutomationTrack->restoreState( dataFile.content().
						firstChildElement( "track" ) );
	}

	//Backward compatibility for LMMS <= 0.4.15
	PeakController::initGetControllerBySetting();

	// Load mixer first to be able to set the correct range for FX channels
	node = dataFile.content().firstChildElement( Engine::fxMixer()->nodeName() );
	if( !node.isNull() )
	{
		Engine::fxMixer()->restoreState( node.toElement() );
		if( gui )
		{
			// refresh FxMixerView
			gui->fxMixerView()->refreshDisplay();
		}
	}

	node = dataFile.content().firstChild();

	QDomNodeList tclist=dataFile.content().elementsByTagName("trackcontainer");
	m_nLoadingTrack=0;
	for( int i=0,n=tclist.count(); i<n; ++i )
	{
		QDomNode nd=tclist.at(i).firstChild();
		while(!nd.isNull())
		{
			if( nd.isElement() && nd.nodeName() == "track" )
			{
				++m_nLoadingTrack;
				if( nd.toElement().attribute("type").toInt() == Track::BBTrack )
				{
					n += nd.toElement().elementsByTagName("bbtrack").at(0)
						.toElement().firstChildElement().childNodes().count();
				}
				nd=nd.nextSibling();
			}
		}
	}

	while( !node.isNull() )
	{
		if( node.isElement() )
		{
			if( node.nodeName() == "trackcontainer" )
			{
				( (JournallingObject *)( this ) )->restoreState( node.toElement() );
			}
			else if( node.nodeName() == "controllers" )
			{
				restoreControllerStates( node.toElement() );
			}
			else if( gui )
			{
				if( node.nodeName() == gui->getControllerRackView()->nodeName() )
				{
					gui->getControllerRackView()->restoreState( node.toElement() );
				}
				else if( node.nodeName() == gui->pianoRoll()->nodeName() )
				{
					gui->pianoRoll()->restoreState( node.toElement() );
				}
				else if( node.nodeName() == gui->automationEditor()->m_editor->nodeName() )
				{
					gui->automationEditor()->m_editor->restoreState( node.toElement() );
				}
				else if( node.nodeName() == gui->getProjectNotes()->nodeName() )
				{
					 gui->getProjectNotes()->SerializingObject::restoreState( node.toElement() );
				}
				else if( node.nodeName() == m_playPos[Mode_PlaySong].m_timeLine->nodeName() )
				{
					m_playPos[Mode_PlaySong].m_timeLine->restoreState( node.toElement() );
				}
			}
		}
		node = node.nextSibling();
	}

	// quirk for fixing projects with broken positions of TCOs inside
	// BB-tracks
	Engine::getBBTrackContainer()->fixIncorrectPositions();

	// Connect controller links to their controllers
	// now that everything is loaded
	ControllerConnection::finalizeConnections();

	// resolve all IDs so that autoModels are automated
	AutomationPattern::resolveAllIDs();


	Engine::mixer()->doneChangeInModel();

	ConfigManager::inst()->addRecentlyOpenedProject( fileName );

	Engine::projectJournal()->setJournalling( true );

	emit projectLoaded();

	if ( hasErrors())
	{
		if ( gui )
		{
			QMessageBox::warning( NULL, tr("LMMS Error report"), errorSummary(),
							QMessageBox::Ok );
		}
		else
		{
			QTextStream(stderr) << Engine::getSong()->errorSummary() << endl;
		}
	}

	m_loadingProject = false;
	m_modified = false;
	m_loadOnLaunch = false;

	if( gui && gui->mainWindow() )
	{
		gui->mainWindow()->resetWindowTitle();
	}
}
Пример #25
0
 void LoginPage::prevPage()
 {
     clearErrors();
     initLoginSubPage(SUBPAGE_PHONE_LOGIN_INDEX);
 }
Пример #26
0
void ExplorerPane::clear()
{
    clearMetadata();
    clearErrors();
    clearSimulator();
}
Пример #27
0
 void reset() {
   clearErrors();
   clear();
 }
Пример #28
0
STDMETHODIMP CComDigiDocLib::ClearDigiDocErrors()
{
	error_buf = ""; 
	clearErrors(); 
	return S_OK;
}
Пример #29
0
//--------------------------------------------------
// Reads in signed XML document and extracts the desired data file
// pSigDoc - signed document object if exists. Can be NULL
// szFileName - digidoc filename
// szDataFileName - name of the file where to store embedded data.
// szDocId - DataFile Id atribute value
// szCharset - convert DataFile content to charset
//--------------------------------------------------
EXP_OPTION int ddocExtractDataFile(SignedDoc* pSigDoc, const char* szFileName,
                                   const char* szDataFileName, const char* szDocId,
                                   const char* szCharset)
{
    FILE *fIn = 0, *fOut = 0;
    int err = ERR_OK, i, nRead, lt, la, lc, j, ld, lb, l, eState = 0, fs = 0;
    long len, lExtr = 0, lSize = 0;
    char chars[1050], tag[100], attr[100], con[1030], dec[70], b64line[70];
    unsigned char b64 = 0, nNc = 0, bFound = 0;
    void *pBuf;
    EVP_ENCODE_CTX ectx;
#ifdef WIN32
    wchar_t *convFileName = 0, *convDataFileName = 0;
    i= 0;
    err = utf82unicode((const char*)szFileName, (char**)&convFileName, &i);
    ddocDebug(3, "ddocExtractDataFile", "file: %s, conv-file: %s len: %d", szFileName, convFileName, i);
    i= 0;
    err = utf82unicode((const char*)szDataFileName, (char**)&convDataFileName, &i);
    ddocDebug(3, "ddocExtractDataFile", "dfile: %s, conv-dfile: %s len: %d", szDataFileName, convDataFileName, i);
#endif

    RETURN_IF_NULL_PARAM(szFileName);
    RETURN_IF_NULL_PARAM(szDataFileName);
    RETURN_IF_NULL_PARAM(szDocId);
    RETURN_IF_NULL_PARAM(szCharset);
    clearErrors();
    ddocDebug(3, "ddocExtractDataFile", "SigDoc: %s, docid: %s, digidoc: %s, file: %s, charset: %s", (pSigDoc ? "OK" : "NULL"), szDocId, szFileName, szDataFileName, szCharset);
    if(szCharset && !strcmp(szCharset, "NO-CHANGE"))
        nNc = 1;
    // try reading from memory if already cached?
    nRead = ddocGetDataFileCachedData(pSigDoc, szDocId, &pBuf, &len);
    if(pBuf) { // gotcha
        ddocDebug(3, "ddocSaxExtractDataFile", "Using cached data: %d bytes", len);
#ifdef WIN32
        if((fOut = _wfopen(convDataFileName, L"wb")) != NULL) {
#else
        if((fOut = fopen(szDataFileName, "wb")) != NULL) {
#endif
            fwrite(pBuf, 1, len, fOut);
            fclose(fOut);
        } else {
            free(pBuf);
            ddocDebug(1, "ddocSaxExtractDataFile", "Error writing file: %s", szDataFileName);
            SET_LAST_ERROR_RETURN_CODE(ERR_FILE_WRITE);
        }
        free(pBuf);
        return nRead;
    }
    // open ddoc file
#ifdef WIN32
    if((fIn = _wfopen(convFileName, L"rb")) != NULL) {
#else
    if((fIn = fopen(szFileName, "rb")) != NULL) {
#endif
        ddocDebug(3, "ddocExtractDataFile", "Opened ddoc-file: %s", szFileName);
        do {
            nRead = fread(chars, 1, 1024, fIn);
            chars[nRead] = 0;
            ddocDebug(6, "ddocExtractDataFile", "Parsing %d bytes: \n%s\n", nRead, chars);
            // handle read data
            for(i = 0; i < nRead; i++) {
                switch(eState) {
                case ST_START: // search '<?xml'
                    if(chars[i] == '<' &&
                            !strncmp(chars+i, "<?xml", 5)) {
                        eState = ST_XML;
                        i += 4;
                    }
                    break;
                case ST_XML: // search '<'
                    if(chars[i] == '<') {
                        eState = ST_TAG_NM;
                        lt = 0;
                        tag[lt] = 0;
                    }
                    break;
                case ST_TAG_NM: // read tag name
                    if(isalnum(chars[i]) || chars[i] == ':' || chars[i] == '/') {
                        if(lt < sizeof(tag)-1) {
                            tag[lt] = chars[i];
                            tag[++lt] = 0;
                        } else {
                            ddocDebug(1, "ddocSaxExtractDataFile", "Invalid xml tag-len > %d", sizeof(tag));
                            SET_LAST_ERROR_RETURN_CODE(ERR_FILE_READ);
                        }
                    } else if(chars[i] == '>') { // tag ended - content
                        eState = ST_CON;
                    } else { // expecting atributes
                        eState = ST_TAG_WS;
                    }
                    break;
                case ST_TAG_WS:
                    if(chars[i] == '>') {
                        if(bFound) {
                            eState = ST_DF_CON;
                            if(b64)
                                EVP_DecodeInit(&ectx);
                        } else
                            eState = ST_CON; // tag endded - content
                        lc = 0;
                        con[lc] = 0;
                    } else if(isalnum(chars[i])) {
                        eState = ST_ATTR_NM; // attr name started
                        la = 0;
                        attr[la] = chars[i];
                        attr[++la] = 0;
                    }
                    break;
                case ST_ATTR_NM:
                    if(isalnum(chars[i])) {
                        if(la < (int)sizeof(attr)-1) {
                            attr[la] = chars[i];
                            attr[++la] = 0;
                        }
                        else
                            ddocDebug(1, "ddocExtractDataFile", "Truncating attr name: %s", attr);
                        break;
                        //19.11.08 added support for '
                    } else if(chars[i] == '\"'/*|| chars[i] == '\''*/) {
                        eState = ST_ATTR_CON;
                        lc = 0;
                        con[lc] = 0;
                        fs = 2;
                    } else if(chars[i] == '\'' && fs==0) {
                        eState = ST_ATTR_CON;
                        lc = 0;
                        con[lc] = 0;
                        fs = 1;
                    } else {
                        eState = ST_ATTR_WS;
                    }
                    break;
                case ST_ATTR_WS:
                    //19.11.08 added support for '
                    if(chars[i] == '\"'/*|| chars[i] == '\''*/) {
                        eState = ST_ATTR_CON;
                        lc = 0;
                        con[lc] = 0;
                    } else if(chars[i] == '\'' && fs==1)  {
                        eState = ST_ATTR_CON;
                        lc = 0;
                        con[lc] = 0;
                    } else {
                        eState = ST_TAG_WS;
                    }
                    break;
                case ST_ATTR_CON:
                    //19.11.08 added support for '
                    if(chars[i] != '\"' /*&& chars[i] != '\''*/) {
                        if(lc < (int)sizeof(con)-1) {
                            con[lc] = chars[i];
                            con[++lc] = 0;
                        } else
                            ddocDebug(1, "ddocExtractDataFile", "Truncating attr content: %s", attr);
                    } else if(chars[i] == '\'' && fs==1)  {
                        if(lc < (int)sizeof(con)-1) {
                            con[lc] = chars[i];
                            con[++lc] = 0;
                        } else
                            ddocDebug(1, "ddocExtractDataFile", "Truncating attr content: %s", attr);
                    } else {
                        eState = ST_TAG_WS;
                        // attribute value complete
                        if(!strcmp(tag, "DataFile")) {
                            //	ddocDebug(3, "ddocSaxExtractDataFile", "DataFile start, attr: %s", attr);
                            if(!strcmp(attr, "ContentType")) {
                                b64 = (!strcmp(con, "EMBEDDED_BASE64")) ? 1 : 0;
                                lb = 0;
                                b64line[0] = 0;
                            }
                            if(!strcmp(attr, "Size") && bFound) {
                                lSize = atol(con);
                            }
                            if(!strcmp(attr, "Id")) {
                                ddocDebug(3, "ddocSaxExtractDataFile", "Found Id: %s searching id: %s", con, szDocId);
                                if(!strcmp(con, szDocId)) {
                                    bFound = 1;
#ifdef WIN32
                                    fOut = _wfopen(convDataFileName, L"wb");
                                    ddocDebug(3, "ddocSaxExtractDataFile", "Opening file: %s handle: %s", convDataFileName, (fOut ? "OK" : "NULL"));
#else
                                    fOut = fopen(szDataFileName, "wb");
                                    ddocDebug(3, "ddocSaxExtractDataFile", "Opening file: %s handle: %s", szDataFileName, (fOut ? "OK" : "NULL"));
#endif
                                    if(!fOut) {
                                        SET_LAST_ERROR(ERR_FILE_WRITE);
                                        err = ERR_FILE_WRITE;
                                        return err;
                                    }
                                }
                            }
                        }
                    }
                    break;
                case ST_CON:
                    if(chars[i] == '<') {
                        eState = ST_TAG_NM;
                        lt = 0;
                        tag[lt] = 0;
                    } else {
                        //con[lc] = chars[i];
                        //con[++lc] = 0;
                    }
                    break;
                case ST_DF_START: // find tag end
                    if(chars[i] == '>') {
                        eState = ST_DF_CON;
                        lc = 0;
                        con[lc] = 0;
                        if(b64)
                            EVP_DecodeInit(&ectx);
                    }
                    break;
                case ST_DF_CON:
                    if(chars[i] == '<') {
                        eState = ST_DF_TAG;
                        lt = 0;
                        tag[lt] = 0;
                    } else {
                        if(lc < (int)sizeof(con) - 1) {
                            if(b64 && !nNc) {
                                for(l = 0; l < lc; ) {
                                    while(lb < 64 && l < lc && l < sizeof(con)) {
                                        if(con[l] != '\n' && con[l] != '\r')
                                            b64line[lb++] = con[l];
                                        l++;
                                    }
                                    if(lb == 64) {
                                        b64line[lb++] = '\n';
                                        b64line[lb] = 0;
                                        ld = sizeof(dec);
                                        dec[0] = 0;
                                        EVP_DecodeUpdate(&ectx, (unsigned char*)dec, &ld, (unsigned char*)b64line, lb);
                                        lExtr += ld;
                                        if(ld > 0)
                                            fwrite(dec, 1, ld, fOut);
                                        lb = 0;
                                    }
                                }
                            } else if(nNc || !b64) {
                                lExtr += lc;
                                fwrite(con, 1, lc, fOut);
                            }
                            lc = 0;
                        }
                        if(lc < sizeof(con)-1) {
                            con[lc] = chars[i];
                            con[++lc] = 0;
                        }
                    }
                    break;
                case ST_DF_TAG:
                    if(/*isalnum(chars[i]) || chars[i] == ':' || chars[i] == '/' ||*/ chars[i] != '>') {
                        if(lt < sizeof(tag)-1) {
                            tag[lt] = chars[i];
                            tag[++lt] = 0;
                        } else {
                            ddocDebug(1, "ddocSaxExtractDataFile", "Invalid xml tag-len > %d", sizeof(tag));
                            SET_LAST_ERROR_RETURN_CODE(ERR_FILE_READ);
                        }
                    } else { // DF intenal tag name ready
                        if(!strcmp(tag, "/DataFile")) { // end of DF
                            eState = ST_DF_END;
                        } else { // wrong tag - this is content
                            if(lc < sizeof(con)-1) {
                                con[lc] = '<';
                                for(j = 0; j < lt; j++)
                                    con[++lc] = tag[j];
                                con[++lc] = '>';
                                con[++lc] = 0;
                            }
                            eState = ST_DF_CON;
                        }
                    }
                    if(eState != ST_DF_END)
                        break;
                case ST_DF_END:
                    if(b64 && !nNc) {
                        if(lc > 0) {
                            for(l = 0; l < lc; ) {
                                while(lb < 64 && l < lc) {
                                    if(con[l] != '\n' && con[l] != '\r')
                                        b64line[lb++] = con[l];
                                    l++;
                                }
                                b64line[lb++] = '\n';
                                b64line[lb] = 0;
                                ld = sizeof(dec);
                                dec[0] = 0;
                                EVP_DecodeUpdate(&ectx, (unsigned char*)dec, &ld, (unsigned char*)b64line, lb);
                                lExtr += ld;
                                if(ld > 0)
                                    fwrite(dec, 1, ld, fOut);
                                lb = 0;
                            }
                        }
                        ld = 0;
                        dec[ld] = 0;
                        EVP_DecodeFinal(&ectx, (unsigned char*)dec, &ld);
                        lExtr += ld;
                        if(ld)
                            fwrite(dec, 1, ld, fOut);
                    } else if(nNc || !b64) {
                        if(lc) {
                            lExtr += lc;
                            fwrite(con, 1, lc, fOut);
                            lc = 0;

                        }
                    }
                    i = sizeof(chars);
                    //AM 24.09.08 RIK
                    eState = ST_DF_END_END;
                    break;
                }
            }
            //AM 24.09.08 RIK ST_DF_END to ST_DF_END_END_END
        } while(nRead > 0 && !err && eState < ST_DF_END_END);
    } else {
        ddocDebug(1, "ddocExtractDataFile", "Error reading file: %s", szFileName);
        SET_LAST_ERROR(ERR_FILE_READ);
    }
    if(fIn)
        fclose(fIn);
    if(fOut)
        fclose(fOut);
    if(!nNc && lSize != lExtr) {
        ddocDebug(1, "ddocExtractDataFile", "Warning! Extracted: %ld bytes but expected: %ld bytes", lExtr, lSize);
        //SET_LAST_ERROR(ERR_FILE_READ);
        //err = ERR_FILE_READ;
    }
    if(!bFound) {
        ddocDebug(1, "ddocExtractDataFile", "DF: %s not found", szDocId);
        SET_LAST_ERROR(ERR_FILE_WRITE);
        err = ERR_FILE_WRITE;
    }
    ddocDebug(3, "ddocExtractDataFile", "Extracted DF: %s to %s size: %ld expected: %ld", szDocId, szDataFileName, lExtr, lSize);
#ifdef WIN32
    free(convFileName);
    free(convDataFileName);
#endif
    return err;
}