Beispiel #1
0
UndeclaredIdentifierError::UndeclaredIdentifierError(
    const std::string& identifier, const location& loc) : FrontEndError(loc) {
  boost::format fmt("Use of undeclared identifier '%1%'.");
  setMessage(boost::str(fmt % identifier));
}
Beispiel #2
0
NoSuchFieldError::NoSuchFieldError(
    const std::string& class_name, const std::string& field_name,
    const location& loc) : FrontEndError(loc) {
  boost::format fmt("%1% has no such field '%2%'.");
  setMessage(boost::str(fmt % class_name % field_name));
}
Beispiel #3
0
// Synchronize remote linked notebooks
bool SyncRunner::syncRemoteLinkedNotebooksActual() {
    QLOG_TRACE_IN();
    LinkedNotebookTable ltable(db);
    QList<qint32> lids;
    ltable.getAll(lids);
    bool fs;
    for (int i = 0; i < lids.size(); i++) {
        LinkedNotebook book;
        qint32 usn = ltable.getLastUpdateSequenceNumber(lids[i]);
        qint32 startingUSN = usn;
        ltable.get(book, lids[i]);
        int chunkSize = 5000;

        // If the share key is set, we need to authenticate
        if (!comm->authenticateToLinkedNotebookShard(book)) {

            // If we can't authenticate, we just gid of the notebook
            // because the user probably stopped sharing.
            qint32 linkedLid = 0;
            LinkedNotebookTable ntable(db);
            linkedLid = ntable.getLid(book.guid);
            ntable.expunge(book.guid);
            emit notebookExpunged(linkedLid);
            return true;

            //this->communicationErrorHandler();
            //error = true;
            //return false;
        }
        bool more = true;
        SyncState syncState;
        if (!comm->getLinkedNotebookSyncState(syncState, book)) {
            this->communicationErrorHandler();
            error = true;
            return false;
        }
        if (syncState.updateCount <= usn)
            more = false;
        qint32 startingSequenceNumber = usn;
        if (usn == 0)
            fs = true;
        else
            fs = false;


        // ***** STARTING PASS #1


        while (more && keepRunning) {
            SyncChunk chunk;
            if (!comm->getLinkedNotebookSyncChunk(chunk, book, usn, chunkSize, fs)) {
                more = false;
                if (comm->getLastErrorType() == CommunicationError::EDAMNotFoundException) {
                    ltable.expunge(lids[i]);
                    if (!finalSync)
                        emit(notebookExpunged(lids[i]));
                } else {
                    this->communicationErrorHandler();
                    error = true;
                    QLOG_TRACE_OUT();
                    return false;
                }
            } else {
                processSyncChunk(chunk, lids[i]);
                usn = chunk.chunkHighUSN;
                if (chunk.updateCount > 0 && chunk.updateCount > startingSequenceNumber) {
                    int pct = (usn - startingSequenceNumber) * 100 / (chunk.updateCount - startingSequenceNumber);
                    QString sharename = "";
                    if (book.shareName.isSet())
                        sharename = book.shareName;
                    emit setMessage(
                        tr("Downloading ") + QString::number(pct) + tr("% complete for tags in shared notebook ") +
                        sharename + tr("."), defaultMsgTimeout);
                }
                if (!chunk.chunkHighUSN.isSet() || chunk.chunkHighUSN >= chunk.updateCount)
                    more = false;
            }
        }

        //************* STARTING PASS 2

        usn = startingUSN;
        more = true;
        chunkSize = 50;
        if (error == true)
            more = false;

        QString sharename = "";
        if (book.shareName.isSet())
            sharename = book.shareName;
        emit setMessage(tr("Downloading notes for shared notebook ") + sharename + tr("."), defaultMsgTimeout);


        while (more && keepRunning) {
            SyncChunk chunk;
            if (!comm->getLinkedNotebookSyncChunk(chunk, book, usn, chunkSize, fs)) {
                more = false;
                if (comm->getLastErrorType()== CommunicationError::EDAMNotFoundException) {
                    ltable.expunge(lids[i]);
                    if (!finalSync)
                        emit(notebookExpunged(lids[i]));
                } else {
                    this->communicationErrorHandler();
                    error = true;
                    return false;
                }
            } else {
                processSyncChunk(chunk, lids[i]);
                usn = chunk.chunkHighUSN;
                if (chunk.updateCount > 0 && chunk.updateCount > startingSequenceNumber) {
                    int pct = (usn - startingSequenceNumber) * 100 / (chunk.updateCount - startingSequenceNumber);
                    QString sharename = "";
                    if (book.shareName.isSet())
                        sharename = book.shareName;
                    emit setMessage(
                        tr("Downloading ") + QString::number(pct) + tr("% complete for shared notebook ") + sharename +
                        tr("."), defaultMsgTimeout);
                }
                if (!chunk.chunkHighUSN.isSet() || chunk.chunkHighUSN >= chunk.updateCount) {
                    more = false;
                    ltable.setLastUpdateSequenceNumber(lids[i], syncState.updateCount);
                }
            }
        }

        qint32 noteUSN = uploadLinkedNotes(lids[i]);
        if (noteUSN > usn)
            ltable.setLastUpdateSequenceNumber(lids[i], noteUSN);
    }
    TagTable tagTable(db);
    tagTable.cleanupLinkedTags();
    QLOG_TRACE_OUT();
    return true;
}
void PlayerCreateState::onButtonClick(MouseEvent* event)
{
    auto sender = dynamic_cast<ImageButton*>(event->emitter());
    auto state = dynamic_cast<PlayerCreateState*>(event->reciever());

    for(auto it = state->_buttons.begin(); it != state->_buttons.end(); ++it)
    {
        if (it->second == sender)
        {
            std::string name = it->first;

            if (name == "name") return onNameButtonClick(event);
            if (name == "age")  return onAgeButtonClick(event);
            if (name == "gender") return onGenderButtonClick(event);
            if (name == "cancel") return onBackButtonClick(event);
            if (name == "done") return onDoneButtonClick(event);

            if (name.find("stats_") == 0)
            {
                state->_selectedLabel = state->_labels.at(name.substr(0,7));
                state->_selectedImage->setTexture(state->_images.at(name.substr(0,7))->texture());
                unsigned int number = atoi(name.substr(6,1).c_str());
                if (name.find("_increase") == 7)
                {
                    _statIncrease(number - 1);
                }
                else
                {
                    _statDecrease(number - 1);
                }
            }

            if (name.find("traits_") == 0)
            {
                unsigned int number = atoi(name.substr(7).c_str());
                state->_selectedLabel = state->_labels.at(name);
                state->_selectedImage->setTexture(state->_images.at(name)->texture());

                if (!_traitToggle(number - 1))
                {
                    auto state = new PlayerEditAlertState();
                    auto msg = ResourceManager::msgFileType("text/english/game/editor.msg");
                    std::string text = msg->message(148)->text() + "\n" + msg->message(149)->text();
                    state->setMessage(text);
                    Game::getInstance()->pushState(state);
                }
            }

            if (name.find("skills_") == 0)
            {
                unsigned int number = atoi(name.substr(7).c_str());
                state->_selectedLabel = state->_labels.at(name);
                state->_selectedImage->setTexture(state->_images.at(name)->texture());
                if (!_skillToggle(number - 1))
                {
                    auto state = new PlayerEditAlertState();
                    auto msg = ResourceManager::msgFileType("text/english/game/editor.msg");
                    std::string text = msg->message(140)->text() + "\n" + msg->message(141)->text();
                    state->setMessage(text);
                    Game::getInstance()->pushState(state);
                }
            }
        }
    }
}
Beispiel #5
0
void SequenceManager::signal() {
	if (_globals->_sceneObjects->contains(&_sceneText))
		_sceneText.hide();

	bool continueFlag = true;
	while (continueFlag) {
		if (_sequenceOffset >=_sequenceData.size()) {
			// Reached the end of the sequence
			if (!_keepActive)
				remove();
			break;
		}

		uint16 idx = static_cast<uint16>(getNextValue() - 32000);
		if (idx > 34)
			continue;

		int16 v1, v2, v3;
		switch (idx) {
		case 0:
			// Stop sequence
			continueFlag = false;
			break;
		case 1:
			_sceneObject->animate(ANIM_MODE_1, NULL);
			break;
		case 2:
			_sceneObject->animate(ANIM_MODE_2, NULL);
			break;
		case 3:
			_sceneObject->animate(ANIM_MODE_3);
			break;
		case 4:
			v1 = getNextValue();
			v2 = getNextValue();
			_sceneObject->animate(ANIM_MODE_8, v1, v2 ? this : NULL);
			break;
		case 5:
			v1 = getNextValue();
			v2 = getNextValue();
			_sceneObject->animate(ANIM_MODE_7, v1, v2 ? this : NULL);
			break;
		case 6:
			v2 = getNextValue();
			_sceneObject->animate(ANIM_MODE_5, v2 ? this : NULL);
			break;
		case 7:
			v2 = getNextValue();
			_sceneObject->animate(ANIM_MODE_6, v2 ? this : NULL);
			break;
		case 8:
			v1 = getNextValue();
			v3 = getNextValue();
			v2 = getNextValue();
			_sceneObject->animate(ANIM_MODE_4, v1, v3, v2 ? this : NULL);
			break;
		case 9:
			v1 = getNextValue();
			v3 = getNextValue();
			v2 = getNextValue();
			_globals->_sceneManager._scene->_sceneBounds.moveTo(v3, v2);
			_globals->_sceneManager._scene->loadScene(v1);
			break;
		case 10: {
			int resNum= getNextValue();
			int lineNum = getNextValue();
			int color = getNextValue();
			int xp = getNextValue();
			int yp = getNextValue();
			int width = getNextValue();
			setMessage(resNum, lineNum, color, Common::Point(xp, yp), width);
			break;
		}
		case 11:
			v1 = getNextValue();
			v2 = getNextValue();
			setAction(globalManager(), v2 ? this : NULL, v1, _objectList[0], _objectList[1], _objectList[2], _objectList[3], NULL);
			break;
		case 12:
			v1 = getNextValue();
			setDelay(v1);
			break;
		case 13: {
			v1 = getNextValue();
			v3 = getNextValue();
			v2 = getNextValue();
			NpcMover *mover = new NpcMover();
			Common::Point destPos(v1, v3);
			_sceneObject->addMover(mover, &destPos, v2 ? this : NULL);
			break;
		}
		case 14:
			v1 = getNextValue();
			_sceneObject->_numFrames = v1;
			break;
		case 15:
			v1 = getNextValue();
			_sceneObject->_moveRate = v1;
			break;
		case 16:
			v1 = getNextValue();
			v2 = getNextValue();
			_sceneObject->_moveDiff = Common::Point(v1, v2);
			break;
		case 17:
			_sceneObject->hide();
			break;
		case 18:
			_sceneObject->show();
			break;
		case 19:
			v1 = getNextValue();
			_sceneObject->setVisage(v1);
			break;
		case 20:
			v1 = getNextValue();
			_sceneObject->setStrip(v1);
			break;
		case 21:
			v1 = getNextValue();
			_sceneObject->setFrame(v1);
			break;
		case 22:
			v1 = getNextValue();
			_sceneObject->fixPriority(v1);
			break;
		case 23:
			v1 = getNextValue();
			_sceneObject->changeZoom(v1);
			break;
		case 24:
			v1 = getNextValue();
			v2 = getNextValue();
			v3 = getNextValue();
			_sceneObject->setPosition(Common::Point(v1, v2), v3);
			break;
		case 25: {
			int yStart = getNextValue();
			int minPercent = getNextValue();
			int yEnd = getNextValue();
			int maxPercent = getNextValue();
			_globals->_sceneManager._scene->setZoomPercents(yStart, minPercent, yEnd, maxPercent);
			break;
		}
		case 26:
			v1 = getNextValue();
			v2 = getNextValue();
			_soundHandler.startSound(v1, v2 ? this : NULL, 127);
			break;
		case 27: {
			v1 = getNextValue();
			v3 = getNextValue();
			v2 = getNextValue();
			PlayerMover *mover = new PlayerMover();
			Common::Point destPos(v1, v3);
			_sceneObject->addMover(mover, &destPos, v2 ? this : NULL);
			break;
		}
		case 28:
			_objectIndex = getNextValue();
			assert((_objectIndex >= 0) && (_objectIndex < 6));
			_sceneObject = _objectList[_objectIndex];
			assert(_sceneObject);
			break;
		case 29:
			_sceneObject->animate(ANIM_MODE_NONE);
			break;
		case 30:
			v1 = getNextValue();
			_globals->_scrollFollower = (v1 == -1) ? NULL : _objectList[v1];
			break;
		case 31:
			_sceneObject->setObjectWrapper(new SceneObjectWrapper());
			break;
		case 32:
			_sceneObject->setObjectWrapper(NULL);
			break;
		case 33:
			v1 = getNextValue();
			if (_keepActive)
				setDelay(1);
			else {
				_sceneText.remove();
				_globals->_sceneManager._scene->_stripManager.start(v1, this);
			}
			break;
		case 34: {
			v1 = getNextValue();
			v2 = getNextValue();
			int objIndex1 = getNextValue() - 1;
			int objIndex2 = getNextValue() - 1;
			int objIndex3 = getNextValue() - 1;
			int objIndex4 = getNextValue() - 1;
			int objIndex5 = getNextValue() - 1;
			int objIndex6 = getNextValue() - 1;

			setAction(globalManager(), v2 ? this : NULL, v1, _objectList[objIndex1], _objectList[objIndex2],
				_objectList[objIndex3], _objectList[objIndex4], _objectList[objIndex5], _objectList[objIndex6], NULL);
			break;
		}
		default:
			error("SequenceManager::signal - Unknown action %d at offset %xh", idx, _sequenceOffset - 2);
			break;
		}
	}
}
Beispiel #6
0
void StatusMessageWidget::resizeEvent(QResizeEvent *event)
{
	QLabel::resizeEvent(event);

	setMessage(m_message);
}
Beispiel #7
0
void MsgEdit::replyClick()
{
    ICQMsg *msg = new ICQMsg;
    msg->Uin.push_back(Uin);
    setMessage(msg);
}
Beispiel #8
0
void *MsgEdit::processEvent(Event *e)
{
    if ((e->type() == EventContactChanged) && (((Contact*)(e->param()))->id() == m_userWnd->m_id)){
        adjustType();
        return NULL;
    }
    if (e->type() == EventClientChanged){
        adjustType();
        return NULL;
    }
    if (e->type() == EventMessageReceived){
        Message *msg = (Message*)(e->param());
        if (msg->getFlags() & MESSAGE_NOVIEW)
            return NULL;
        if ((msg->contact() == m_userWnd->id()) && (msg->type() != MessageStatus)){
            if (CorePlugin::m_plugin->getContainerMode()){
                bool bSetFocus = false;
                if (topLevelWidget() && topLevelWidget()->inherits("Container")){
                    Container *container = static_cast<Container*>(topLevelWidget());
                    if (container->wnd() == m_userWnd)
                        bSetFocus = true;
                }
                setMessage(msg, bSetFocus);
            }else{
                if (m_edit->isReadOnly())
                    QTimer::singleShot(0, this, SLOT(setupNext()));
            }
        }
    }
    if (e->type() == EventRealSendMessage){
        MsgSend *s = (MsgSend*)(e->param());
        if (s->edit == this){
            sendMessage(s->msg);
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->param == this) && (cmd->id == CmdTranslit)){
            Contact *contact = getContacts()->contact(m_userWnd->id());
            if (contact){
                TranslitUserData *data = (TranslitUserData*)(contact->getUserData(CorePlugin::m_plugin->translit_data_id));
                if (data){
                    cmd->flags &= ~COMMAND_CHECKED;
                    if (data->Translit.bValue)
                        cmd->flags |= COMMAND_CHECKED;
                }
            }
            return NULL;
        }
        if ((cmd->menu_id != MenuTextEdit) || (cmd->param != this))
            return NULL;
        cmd->flags &= ~(COMMAND_CHECKED | COMMAND_DISABLED);
        switch (cmd->id){
        case CmdUndo:
            if (m_edit->isReadOnly())
                return NULL;
            if (!m_edit->isUndoAvailable())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdRedo:
            if (m_edit->isReadOnly())
                return NULL;
            if (!m_edit->isRedoAvailable())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdCut:
            if (m_edit->isReadOnly())
                return NULL;
        case CmdCopy:
            if (!m_edit->hasSelectedText())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdPaste:
            if (m_edit->isReadOnly())
                return NULL;
            if (QApplication::clipboard()->text().isEmpty())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdClear:
            if (m_edit->isReadOnly())
                return NULL;
        case CmdSelectAll:
            if (m_edit->text().isEmpty())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        }
        return NULL;
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
#if defined(USE_KDE)
#if KDE_IS_VERSION(3,2,0)
        if (cmd->id == CmdEnableSpell){
            m_edit->setCheckSpellingEnabled(cmd->flags & COMMAND_CHECKED);
            return NULL;
        }
        if ((cmd->id == CmdSpell) && (cmd->param == this)){
            m_edit->checkSpelling();
            return e->param();
        }
#endif
#endif
        if ((cmd->id == CmdSmile) && (cmd->param == this)){
            Event eBtn(EventCommandWidget, cmd);
            QToolButton *btnSmile = (QToolButton*)(eBtn.process());
            if (btnSmile){
                SmilePopup *popup = new SmilePopup(this);
                QSize s = popup->minimumSizeHint();
                popup->resize(s);
                connect(popup, SIGNAL(insert(int)), this, SLOT(insertSmile(int)));
                QPoint p = CToolButton::popupPos(btnSmile, popup);
                popup->move(p);
                popup->show();
            }
            return e->param();
        }
Beispiel #9
0
void MsgEdit::action(int type, bool bSaveEdit)
{
    if (type == mnuMail){
        pMain->sendMail(Uin);
        return;
    }
    if (sendEvent) return;
    if (Uin == 0)
        log(L_WARN, "Bad UIN for message create");
    if ((type == mnuAction) || (type == mnuActionInt)){
        if ((type == mnuAction) && canSend())
            return;
        ICQUser *u = pClient->getUser(Uin);
        if (u && u->unreadMsgs.size()){
            ICQMessage *msg = history()->getMessage(u->unreadMsgs.front());
            if (msg){
                setMessage(msg, true, true);
                setState();
                return;
            }
        }
        if (u && (u->Type == USER_TYPE_EXT)){
            PhoneBook::iterator it;
            for (it = u->Phones.begin(); it != u->Phones.end(); ++it){
                PhoneInfo *info = static_cast<PhoneInfo*>(*it);
                if (info->Type() == SMS){
                    type = mnuSMS;
                    break;
                }
            }
            if (type == mnuActionInt){
                pMain->sendMail(u->Uin);
                return;
            }
        }else{
            type = mnuMessage;
        }
    }
    ICQMessage *editMsg = NULL;
    switch (type){
    case mnuMessage:
        editMsg = new ICQMsg;
        editMsg->Uin.push_back(Uin);
        break;
    case mnuURL:
        editMsg = new ICQUrl;
        editMsg->Uin.push_back(Uin);
        break;
    case mnuSMS:
        editMsg = new ICQSMS;
        editMsg->Uin.push_back(Uin);
        break;
    case mnuAuth:
        editMsg = new ICQAuthRequest;
        editMsg->Uin.push_back(Uin);
        break;
    case mnuContacts:
        editMsg = new ICQContacts;
        editMsg->Uin.push_back(Uin);
        break;
    case mnuFile:
        editMsg = new ICQFile;
        editMsg->Uin.push_back(Uin);
        break;
    case mnuChat:
        editMsg = new ICQChat;
        editMsg->Uin.push_back(Uin);
        break;
    default:
        log(L_WARN, "Unknown message type: %u", type);
    }
    setMessage(editMsg, false, false, bSaveEdit);
    setState();
}
Beispiel #10
0
void MsgEdit::processEvent(ICQEvent *e)
{
    ICQUser *u;
    switch (e->type()){
    case EVENT_ACKED:
        if (e->message() && (e->message() == message())){
            sendEvent = NULL;
            setMessage();
            if (bCloseSend){
                close();
            }else{
                action(mnuAction);
                switch (e->message()->Type()){
                case ICQ_MSGxFILE:
                    emit setStatus(i18n("Transfer started"), 2000);
                    break;
                case ICQ_MSGxCHAT:
                    emit setStatus(i18n("Chat started"), 2000);
                    break;
                }
            }
        }
        break;
    case EVENT_INFO_CHANGED:
        fillPhones();
        u = pClient->getUser(Uin);
        if (u && u->inIgnore())
            QTimer::singleShot(10, this, SLOT(close()));
        break;
    case EVENT_USER_DELETED:
        if (e->Uin() == Uin)
            close();
        break;
    }
    if (e->message() && (e->message() == message())){
        if (e->type() == EVENT_MESSAGE_SEND){
            if (e->state == ICQEvent::Success){
                history()->addMessage(message());
                if (!msgTail.isEmpty()){
                    emit addMessage(message(), false, true);
                    emit showMessage(Uin(), message()->Id);
                    if (e->message()->Type() == ICQ_MSGxSMS){
                        ICQSMS *m = new ICQSMS;
                        m->Uin.push_back(Uin);
                        m->Message = smsChunk();
                        m->Phone = phoneEdit->lineEdit()->text().local8Bit();
                        msg = m;
                        sendEvent = pClient->sendMessage(msg);
                        return;
                    }
                    log(L_WARN, "Bad type for chunked message");
                }
                if (bCloseSend){
                    close();
                }else{
                    emit addMessage(message(), false, true);
                    emit showMessage(Uin(), message()->Id);
                    setMessage();
                    action(mnuAction);
                    emit setStatus(i18n("Message sent"), 2000);
                }
            }else{
                e->message()->bDelete = false;
                emit setStatus(i18n("Send failed"), 2000);
                if (e->message() && *(e->message()->DeclineReason.c_str()))
                    BalloonMsg::message(QString::fromLocal8Bit(msg->DeclineReason.c_str()),
                                        btnNext);
            }
            bCloseSend = false;
            sendEvent = NULL;
            setState();
        }else if ((e->type() == EVENT_MESSAGE_RECEIVED) && (e->state == ICQEvent::Fail)){
            msg = NULL;
            setMessage();
            action(mnuAction);
        }
    }
}
Beispiel #11
0
bool z3ResEx::extractItem( FILEINDEX_ENTRY &info, unsigned char method, char *strMrf, char *strName )
{
	TFileStream mrf( strMrf );

	if( !( mrf.isOpen() ) )
	{
		setMessage( "ERROR: Unable to open file (%s)", strMrf );
		return false;
	}

	// Format the output filename
	std::string fname( fsRename( strMrf, strName ) );
	
	// UNFORCED EXTRACTION
	// If file already exists, ignore it
	if( TFileSize( fname.c_str() ) == info.size )
	{
		mrf.Close();
		return true;
	}

	unsigned char *buf( new unsigned char[ info.zsize ] );

	// Load MRF data into buffer
	mrf.Seek( info.offset, bufo_start );
	mrf.Read( buf, info.zsize );
	mrf.Close();

	// Copy into TStream
	TMemoryStream fdata;
	fdata.LoadFromBuffer( buf, info.zsize );
	delete buf;

	printf
	(	
		( m_doExtraction ? "Saving %s.. " : "Checking %s.. " ),
		fname.substr( fname.rfind('/') +1 ).c_str()
	);

	// Create path only when extraction is flagged
	if( m_doExtraction )
		fsCreatePath( fname );

	switch( method )
	{
		// Compressed, most files
		case FILEINDEX_ENTRY_COMPRESSED :
		{
			fsXor( fdata, info.xorkey );

			TMemoryStream fdata_raw;
			if( fsRle( fdata, fdata_raw ) )
			{
				if( m_doExtraction )
					fdata_raw.SaveToFile( fname.c_str() );

				puts(" ..done!");
			}
		
			// fsRle will display any errors

			fdata_raw.Close();
			break;
		}

		// Encrypted and compressed, some system data (GunZ 2)
		case FILEINDEX_ENTRY_COMPRESSED2 :
		{
			TMemoryStream fdata_dec;
			z3Decrypt( fdata, fdata_dec, m_fileindexKey, m_fileindexKeyLength );
			fdata.Close();

			// Now same as FILEINDEX_ENTRY_COMPRESSED

			fsXor( fdata_dec, info.xorkey );

			TMemoryStream fdata_raw;
			if( fsRle( fdata_dec, fdata_raw ) )
			{
				if( m_doExtraction )
					fdata_raw.SaveToFile( fname.c_str() );

				printf(" ..done!\n");
			}
		
			// fsRle will display any errors

			fdata_dec.Close();
			fdata_raw.Close();

			break;
		}

		// Large files, some FSB (GunZ 2)
		case FILEINDEX_ENTRY_UNCOMPRESSED :
		{
			if( m_doExtraction )
				fdata.SaveToFile( fname.c_str() );

			puts(" ..done!");

			break;
		}

		default:
		{
			fdata.Close();
			printf("ERROR: Unknown compression type (%02X)\n", method);

			return false;
		}
	}

	fdata.Close();

	return true;
}
Beispiel #12
0
void z3ResEx::Run( )
{
	// Check the fileindex exists
	if( TFileSize( msfName ) == 0 )
	{
		setMessage( "ERROR: Unable to open file (%s)", msfName );
	}
	else
	{
		TMemoryStream msf;

		m_fileindexKey			= nullptr;
		m_fileindexKeyLength	= 0;

		//
		// Brute-force the key (version 1)
		//

		unsigned int keyIndex( 0 );

		// For all known keys
		while( ( keyIndex < keyList1Count ) && ( msf.Size() == 0 ) )
		{
			// Try to read the fileindex
			if( fsReadMSF( msf, keyList1[ keyIndex ].Data, KeyLength1, 0 ) )
			{
				m_fileindexKey			= keyList1[ keyIndex ].Data;
				m_fileindexKeyLength	= KeyLength1;
				m_fileindexVer			= 0;

				if( m_verboseMessages )
					printf("Found key for %s!\n", keyList1[ keyIndex ].Desc );
			}

			++keyIndex;
		}

		// If key has not been found
		if( m_fileindexKey == nullptr )
		{
			//
			//  Continue to brute-force the key (version 2)
			//

			keyIndex = 0;
			// For all known keys
			while( ( keyIndex < keyList2Count ) && ( msf.Size() == 0 ) )
			{
				// Try to read the fileindex
				if( fsReadMSF( msf, keyList2[ keyIndex ].Data, KeyLength2, 1 ) )
				{
					m_fileindexKey			= keyList2[ keyIndex ].Data;
					m_fileindexKeyLength	= KeyLength2;
					m_fileindexVer			= 1;

					if( m_verboseMessages )
						printf("Found key for %s!\n", keyList2[ keyIndex ].Desc );
				}

				++keyIndex;
			}
		}

		// If a valid key has been found and fileindex loaded
		if( !( ( m_fileindexKey == nullptr ) && ( msf.Size() == 0 ) ) )
		{
			// Attempt to parse it (to extract or list files)
			msf.Seek( 0, bufo_start );
			parseMsf( msf );
		}
		else
		{
			// No key found or incompatiable file (not checked)
			setMessage( "ERROR: This file is using an updated key or unsupported method" );
		}

		msf.Close();
	}
}
Beispiel #13
0
void SyncRunner::evernoteSync() {
    QLOG_TRACE() << "Sync thread:" << QThread::currentThreadId();
    if (!global.connected) {
        return;
    }

    User user;
    UserTable userTable(db);
    if (!comm->getUserInfo(user)) {
        this->communicationErrorHandler();
        error = true;
        return;
    }
    userTable.updateUser(user);

    SyncState syncState;
    if (!comm->getSyncState("", syncState)) {
        this->communicationErrorHandler();
        error = true;
        return;
    }

    fullSync = false;

    qlonglong lastSyncDate = userTable.getLastSyncDate();
    updateSequenceNumber = userTable.getLastSyncNumber();

    if ((syncState.fullSyncBefore / 1000) > lastSyncDate) {
        QLOG_DEBUG() << "Full sequence date has expired";
        lastSyncDate = 0;
        fullSync = true;
    }

    if (updateSequenceNumber == 0) {
        fullSync = true;
    }

    emit setMessage(tr("Beginning sync"), defaultMsgTimeout);

    // If there are remote changes
    QLOG_DEBUG() << "--->>>  Current Chunk High Sequence Number: " << syncState.updateCount;
    QLOG_DEBUG() << "--->>>  Last User High Sequence Number: " << updateSequenceNumber;

    if (syncState.updateCount > updateSequenceNumber) {
        QLOG_DEBUG() << "Remote changes found. Downloading changes....";
        emit setMessage(tr("Downloading changes.."), 0);
        bool rc = syncRemoteToLocal(syncState.updateCount);
        if (!rc) {
            error = true;
        }
    }

    if (!comm->getUserInfo(user)) {
        this->communicationErrorHandler();
        error = true;
        return;
    }
    userTable.updateUser(user);

    if (!global.disableUploads && !error) {
        qint32 searchUsn = uploadSavedSearches();
        if (searchUsn > updateSequenceNumber)
            updateSequenceNumber = searchUsn;
        qint32 tagUsn = uploadTags();
        if (tagUsn > updateSequenceNumber)
            updateSequenceNumber = tagUsn;
        qint32 notebookUsn = uploadNotebooks();
        if (notebookUsn > updateSequenceNumber)
            updateSequenceNumber = notebookUsn;
        qint32 personalNotesUsn = uploadPersonalNotes();
        if (personalNotesUsn > updateSequenceNumber)
            updateSequenceNumber = personalNotesUsn;
    }

    // Synchronize linked notebooks
    if (!error && !syncRemoteLinkedNotebooksActual())
        error = true;

    if (error || !comm->getSyncState("", syncState)) {
        error = true;
        this->communicationErrorHandler();
        return;
    }
    userTable.updateSyncState(syncState);

    // Cleanup any missing parent tags
    QList<qint32> lids;
    TagTable tagTable(db);
    tagTable.findMissingParents(lids);
    for (int i = 0; i < lids.size(); i++) {
        if (!finalSync)
            emit(tagExpunged(lids[i]));
    }
    tagTable.cleanupMissingParents();

    if (!error)
        emit setMessage(tr("Sync completed successfully"), defaultMsgTimeout);
    QLOG_TRACE() << "Leaving SyncRunner::evernoteSync()";
}
Beispiel #14
0
NoSuchMemberFunctionError::NoSuchMemberFunctionError(
    const std::string& class_name, const std::string& func_name,
    const location& loc) : FrontEndError(loc) {
  boost::format fmt("Class %1% doesn't have member function %2%");
  setMessage(boost::str(fmt % class_name % func_name));
}
Beispiel #15
0
void MsgEdit::refuseClick()
{
    ICQMessage *msg = new ICQAuthRefused;
    msg->Uin.push_back(Uin);
    setMessage(msg);
}
Beispiel #16
0
IncompatibleOpError::IncompatibleOpError(
    const std::string& op, DataType* type, const location& loc) : FrontEndError(loc) {
  boost::format format("Need \"%1%\" for type \"%2%\".");
  format % op % type->getName();
  setMessage(format.str());
}
void
InspectorWindow::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
		case MSG_INSPECT_ADDRESS:
		{
			target_addr_t address = 0;
			bool addressValid = false;
			if (msg->FindUInt64("address", &address) != B_OK)
			{
				ExpressionParser parser;
				parser.SetSupportHexInput(true);
				const char* addressExpression = fAddressInput->Text();
				BString errorMessage;
				try {
					address = parser.EvaluateToInt64(addressExpression);
				} catch(ParseException parseError) {
					errorMessage.SetToFormat("Failed to parse address: %s",
						parseError.message.String());
				} catch(...) {
					errorMessage.SetToFormat(
						"Unknown error while parsing address");
				}

				if (errorMessage.Length() > 0) {
					BAlert* alert = new(std::nothrow) BAlert("Inspect Address",
						errorMessage.String(), "Close");
					if (alert != NULL)
						alert->Go();
				} else
					addressValid = true;
			} else {
				addressValid = true;
			}

			if (addressValid) {
				if (fCurrentBlock != NULL
					&& !fCurrentBlock->Contains(address)) {
					fCurrentBlock->ReleaseReference();
					fCurrentBlock = NULL;
				}

				if (fCurrentBlock == NULL)
					fListener->InspectRequested(address, this);
				else
					fMemoryView->SetTargetAddress(fCurrentBlock, address);

				fCurrentAddress = address;
				BString computedAddress;
				computedAddress.SetToFormat("0x%" B_PRIx64, address);
				fAddressInput->SetText(computedAddress.String());
			}
			break;
		}
		case MSG_NAVIGATE_PREVIOUS_BLOCK:
		case MSG_NAVIGATE_NEXT_BLOCK:
		{
			if (fCurrentBlock != NULL)
			{
				target_addr_t address = fCurrentBlock->BaseAddress();
				if (msg->what == MSG_NAVIGATE_PREVIOUS_BLOCK)
					address -= fCurrentBlock->Size();
				else
					address += fCurrentBlock->Size();

				BMessage setMessage(MSG_INSPECT_ADDRESS);
				setMessage.AddUInt64("address", address);
				PostMessage(&setMessage);
			}
			break;
		}
		{
			break;
		}
		default:
		{
			BWindow::MessageReceived(msg);
			break;
		}
	}
}
Beispiel #18
0
/** Constructor */
ReplyLine::ReplyLine(const QString &status, const QString &msg)
{
  _status = status;
  setMessage(msg);
}
Beispiel #19
0
void KCValidity::loadOdfValidation(KCCell* const cell, const QString& validationName,
                                 KCOdfLoadingContext& tableContext)
{
    KXmlElement element = tableContext.validities.value(validationName);
    KCValidity validity;
    if (element.hasAttributeNS(KOdfXmlNS::table, "condition")) {
        QString valExpression = element.attributeNS(KOdfXmlNS::table, "condition", QString());
        kDebug(36003) << " element.attribute( table:condition )" << valExpression;
        //Condition ::= ExtendedTrueCondition | TrueFunction 'and' TrueCondition
        //TrueFunction ::= cell-content-is-whole-number() | cell-content-is-decimal-number() | cell-content-is-date() | cell-content-is-time()
        //ExtendedTrueCondition ::= ExtendedGetFunction | cell-content-text-length() Operator KCValue
        //TrueCondition ::= GetFunction | cell-content() Operator KCValue
        //GetFunction ::= cell-content-is-between(KCValue, KCValue) | cell-content-is-not-between(KCValue, KCValue)
        //ExtendedGetFunction ::= cell-content-text-length-is-between(KCValue, KCValue) | cell-content-text-length-is-not-between(KCValue, KCValue)
        //Operator ::= '<' | '>' | '<=' | '>=' | '=' | '!='
        //KCValue ::= NumberValue | String | KCFormula
        //A KCFormula is a formula without an equals (=) sign at the beginning. See section 8.1.3 for more information.
        //A String comprises one or more characters surrounded by quotation marks.
        //A NumberValue is a whole or decimal number. It must not contain comma separators for numbers of 1000 or greater.

        //ExtendedTrueCondition
        if (valExpression.contains("cell-content-text-length()")) {
            //"cell-content-text-length()>45"
            valExpression = valExpression.remove("oooc:cell-content-text-length()");
            kDebug(36003) << " valExpression = :" << valExpression;
            setRestriction(KCValidity::TextLength);

            loadOdfValidationCondition(valExpression, cell->sheet()->map()->parser());
        } else if (valExpression.contains("cell-content-is-text()")) {
            setRestriction(KCValidity::Text);
        }
        //cell-content-text-length-is-between(KCValue, KCValue) | cell-content-text-length-is-not-between(KCValue, KCValue) | cell-content-is-in-list( StringList )
        else if (valExpression.contains("cell-content-text-length-is-between")) {
            setRestriction(KCValidity::TextLength);
            setCondition(KCConditional::Between);
            valExpression = valExpression.remove("oooc:cell-content-text-length-is-between(");
            kDebug(36003) << " valExpression :" << valExpression;
            valExpression = valExpression.remove(')');
            QStringList listVal = valExpression.split(',', QString::SkipEmptyParts);
            loadOdfValidationValue(listVal, cell->sheet()->map()->parser());
        } else if (valExpression.contains("cell-content-text-length-is-not-between")) {
            setRestriction(KCValidity::TextLength);
            setCondition(KCConditional::Different);
            valExpression = valExpression.remove("oooc:cell-content-text-length-is-not-between(");
            kDebug(36003) << " valExpression :" << valExpression;
            valExpression = valExpression.remove(')');
            kDebug(36003) << " valExpression :" << valExpression;
            QStringList listVal = valExpression.split(',', QString::SkipEmptyParts);
            loadOdfValidationValue(listVal, cell->sheet()->map()->parser());
        } else if (valExpression.contains("cell-content-is-in-list(")) {
            setRestriction(KCValidity::List);
            valExpression = valExpression.remove("oooc:cell-content-is-in-list(");
            kDebug(36003) << " valExpression :" << valExpression;
            valExpression = valExpression.remove(')');
            setValidityList(valExpression.split(';',  QString::SkipEmptyParts));

        }
        //TrueFunction ::= cell-content-is-whole-number() | cell-content-is-decimal-number() | cell-content-is-date() | cell-content-is-time()
        else {
            if (valExpression.contains("cell-content-is-whole-number()")) {
                setRestriction(KCValidity::KCNumber);
                valExpression = valExpression.remove("oooc:cell-content-is-whole-number() and ");
            } else if (valExpression.contains("cell-content-is-decimal-number()")) {
                setRestriction(KCValidity::Integer);
                valExpression = valExpression.remove("oooc:cell-content-is-decimal-number() and ");
            } else if (valExpression.contains("cell-content-is-date()")) {
                setRestriction(KCValidity::Date);
                valExpression = valExpression.remove("oooc:cell-content-is-date() and ");
            } else if (valExpression.contains("cell-content-is-time()")) {
                setRestriction(KCValidity::Time);
                valExpression = valExpression.remove("oooc:cell-content-is-time() and ");
            }
            kDebug(36003) << "valExpression :" << valExpression;

            if (valExpression.contains("cell-content()")) {
                valExpression = valExpression.remove("cell-content()");
                loadOdfValidationCondition(valExpression, cell->sheet()->map()->parser());
            }
            //GetFunction ::= cell-content-is-between(KCValue, KCValue) | cell-content-is-not-between(KCValue, KCValue)
            //for the moment we support just int/double value, not text/date/time :(
            if (valExpression.contains("cell-content-is-between(")) {
                valExpression = valExpression.remove("cell-content-is-between(");
                valExpression = valExpression.remove(')');
                QStringList listVal = valExpression.split(',', QString::SkipEmptyParts);
                loadOdfValidationValue(listVal, cell->sheet()->map()->parser());
                setCondition(KCConditional::Between);
            }
            if (valExpression.contains("cell-content-is-not-between(")) {
                valExpression = valExpression.remove("cell-content-is-not-between(");
                valExpression = valExpression.remove(')');
                QStringList listVal = valExpression.split(',', QString::SkipEmptyParts);
                loadOdfValidationValue(listVal, cell->sheet()->map()->parser());
                setCondition(KCConditional::Different);
            }
        }
    }
    if (element.hasAttributeNS(KOdfXmlNS::table, "allow-empty-cell")) {
        kDebug(36003) << " element.hasAttribute( table:allow-empty-cell ) :" << element.hasAttributeNS(KOdfXmlNS::table, "allow-empty-cell");
        setAllowEmptyCell(((element.attributeNS(KOdfXmlNS::table, "allow-empty-cell", QString()) == "true") ? true : false));
    }
    if (element.hasAttributeNS(KOdfXmlNS::table, "base-cell-address")) {
        //todo what is it ?
    }

    KXmlElement help = KoXml::namedItemNS(element, KOdfXmlNS::table, "help-message");
    if (!help.isNull()) {
        if (help.hasAttributeNS(KOdfXmlNS::table, "title")) {
            kDebug(36003) << "help.attribute( table:title ) :" << help.attributeNS(KOdfXmlNS::table, "title", QString());
            setTitleInfo(help.attributeNS(KOdfXmlNS::table, "title", QString()));
        }
        if (help.hasAttributeNS(KOdfXmlNS::table, "display")) {
            kDebug(36003) << "help.attribute( table:display ) :" << help.attributeNS(KOdfXmlNS::table, "display", QString());
            setDisplayValidationInformation(((help.attributeNS(KOdfXmlNS::table, "display", QString()) == "true") ? true : false));
        }
        KXmlElement attrText = KoXml::namedItemNS(help, KOdfXmlNS::text, "p");
        if (!attrText.isNull()) {
            kDebug(36003) << "help text :" << attrText.text();
            setMessageInfo(attrText.text());
        }
    }

    KXmlElement error = KoXml::namedItemNS(element, KOdfXmlNS::table, "error-message");
    if (!error.isNull()) {
        if (error.hasAttributeNS(KOdfXmlNS::table, "title"))
            setTitle(error.attributeNS(KOdfXmlNS::table, "title", QString()));
        if (error.hasAttributeNS(KOdfXmlNS::table, "message-type")) {
            QString str = error.attributeNS(KOdfXmlNS::table, "message-type", QString());
            if (str == "warning")
                setAction(KCValidity::Warning);
            else if (str == "information")
                setAction(KCValidity::Information);
            else if (str == "stop")
                setAction(KCValidity::Stop);
            else
                kDebug(36003) << "validation : message type unknown  :" << str;
        }

        if (error.hasAttributeNS(KOdfXmlNS::table, "display")) {
            kDebug(36003) << " display message :" << error.attributeNS(KOdfXmlNS::table, "display", QString());
            setDisplayMessage((error.attributeNS(KOdfXmlNS::table, "display", QString()) == "true"));
        }
        KXmlElement attrText = KoXml::namedItemNS(error, KOdfXmlNS::text, "p");
        if (!attrText.isNull())
            setMessage(attrText.text());
    }
    cell->setValidity(validity);
}
Beispiel #20
0
MidiEvent& MidiEvent::operator=(const vector<int>& bytes) {
	clearVariables();
	setMessage(bytes);
	return *this;
}
int main(int argc,char* argv[])
{
	int i, j;
	CASE *pcase;
	char buffer[80];
	srand((unsigned)time(NULL)); // Pour permettre d'avoir des v. aléatoires.
	pieceEnCours.nbCases = 4;

	printf("(THREAD MAIN) Masquage de tous les signaux\n");
	sigset_t mask;
	sigfillset(&mask);
	pthread_sigmask(SIG_BLOCK, &mask, NULL);

	//Initialisation des mutex, variables de conditions et clés d'accès aux variables spécifiques
	pthread_mutex_init(&mutexMessage, NULL);
	pthread_mutex_init(&mutexCasesInserees, NULL);
	pthread_mutex_init(&mutexScore, NULL);
	pthread_mutex_init(&mutexAnalyse, NULL);
	pthread_mutex_init(&mutexTraitement, NULL);
	pthread_cond_init(&condCasesInserees, NULL);
	pthread_cond_init(&condScore, NULL);
	pthread_cond_init(&condAnalyse, NULL);
	pthread_key_create(&cle, free_case);

	// Ouverture de la grille de jeu (SDL)
	printf("(THREAD MAIN) Ouverture de la grille de jeu\n");
	fflush(stdout);
	sprintf(buffer,"!!! TETRIS ZERO GRAVITY !!!");

	if (OuvrirGrilleSDL(NB_LIGNES,NB_COLONNES,40,buffer) < 0)
	{
		printf("Erreur de OuvrirGrilleSDL\n");
		fflush(stdout);
		exit(1);
	}

// Chargement des sprites et de l'image de fond
	ChargementImages();
	DessineSprite(12,11,VOYANT_VERT);

	printf("Nombre d'arguments: %d\n", argc);
	if (argc > 1)
	{
		if ( argc != 3)
		{
			printf("Il faut executer le programme de la façon suivante : ./Tetris cleServer pseudo\n");
			exit(1);
		}

///////////////////////////////////////// Mode online /////////////////////////////////////////////
		cleServer = atoi(argv[1]);
		printf("Connexion au serveur...\n");
		if (ConnectionServeur( (key_t)cleServer, argv[2]) == 0)
		{
			printf("Connexion réussie.\n");
//Creation du thread joueurs connectés ////////////////////////////////////////////////////////////
			if (errno = pthread_create(&threadHandleJoueurs, NULL, threadJoueursConnectes, NULL) !=0 )
				perror("Erreur de lancement threadJoueursConnectes");

//Creation du thread de TopScore //////////////////////////////////////////////////////////////////
			if (errno = pthread_create(&threadHandleTopScore, NULL, threadTopScore, NULL) !=0 )
				perror("Erreur de lancement threadTopScore");
		}
		else
		{
			printf("\n---------------------------\nImpossible d'établir la connexion au serveur\n");
		}
	}

//Creation du thread de defilement du message /////////////////////////////////////////////////////

	setMessage("Bienvenue dans Tetris Zero Gravity");

	if (errno = pthread_create(&threadHandleMessage, NULL, threadDefileMessage, NULL) !=0 )
		perror("Erreur de lancement threadDefileMessage");

//Creation du thread de defilement du message /////////////////////////////////////////////////////

	if (errno = pthread_create(&threadHandlePiece, NULL, threadPiece, NULL) !=0 )
		perror("Erreur de lancement threadPiece");

//Creation du thread Event ////////////////////////////////////////////////////////////////////////

	if (errno = pthread_create(&threadHandleEvent, NULL, threadEvent, NULL) !=0 )
		perror("Erreur de lancement threadEvent");

//Creation du thread Score ////////////////////////////////////////////////////////////////////////

	if (errno = pthread_create(&threadHandleScore, NULL, threadScore, NULL) !=0 )
		perror("Erreur de lancement threadScore");

	/**/printf("(Main) Thread Score cree. errno = %d\n", (int)errno);

//Creation des threads Case ///////////////////////////////////////////////////////////////////////

	for (i = 0 ; i < NB_LIGNES ; ++i)
	{
		for (j = 0 ; j < 10 ; ++j)
		{
			pcase = (CASE*)malloc(sizeof(CASE));
			pcase->ligne = i;
			pcase->colonne = j;
			if (errno = pthread_create(&threadHandleCase[i][j], NULL, threadCase, (void*)pcase)!=0)
				perror("Erreur de lancement threadCase");
		}
	}

//Creation du thread Gravité //////////////////////////////////////////////////////////////////////

	if (errno = pthread_create(&threadHandleGravite, NULL, threadGravite, NULL) !=0 )
		perror("Erreur de lancement threadGravite");

//Creation du thread FinPartie ////////////////////////////////////////////////////////////////////

	if (errno = pthread_create(&threadHandleFinPartie, NULL, threadFinPartie, NULL) !=0 )
		perror("Erreur de lancement threadFinPartie");


///////////////////////////////////////////////////////////////////////////////////////////////////

	printf("(Main) Pret a jouer.\n");

	// Attente de la fin de la partie
	pthread_join(threadHandleFinPartie, NULL);
	terminerProgramme();
}
Beispiel #22
0
void *MsgEdit::processEvent(Event *e)
{
    if ((e->type() == EventContactChanged) && !m_bReceived){
        if (((Contact*)(e->param()))->id() != (m_userWnd->m_id))
            return NULL;
        Command cmd;
        cmd->id = m_type;
        cmd->menu_id = MenuMessage;
        cmd->param = (void*)(m_userWnd->m_id);
        Event e(EventCheckState, cmd);
        if (e.process())
            return NULL;
        Event eMenu(EventGetMenuDef, (void*)MenuMessage);
        CommandsDef *cmdsMsg = (CommandsDef*)(eMenu.process());
        CommandsList itc(*cmdsMsg, true);
        CommandDef *c;
        while ((c = ++itc) != NULL){
            c->param = (void*)(m_userWnd->m_id);
            Event eCheck(EventCheckState, c);
            if (!eCheck.process())
                continue;
            CommandDef *def;
            def = CorePlugin::m_plugin->messageTypes.find(c->id);
            if (def == NULL)
                continue;
            MessageDef *mdef = (MessageDef*)(def->param);
            if (mdef->flags & MESSAGE_SILENT)
                continue;
            if (mdef->create == NULL)
                continue;
            Message *msg = mdef->create(NULL);
            if (msg == NULL)
                continue;
            setMessage(msg, false);
            delete msg;
            break;
        }
        return NULL;
    }
    if (e->type() == EventMessageReceived){
        Message *msg = (Message*)(e->param());
        if (msg->getFlags() & MESSAGE_NOVIEW)
            return NULL;
        if ((msg->contact() == m_userWnd->id()) && (msg->type() != MessageStatus)){
            if (CorePlugin::m_plugin->getContainerMode()){
                bool bSetFocus = false;
                if (topLevelWidget() && topLevelWidget()->inherits("Container")){
                    Container *container = static_cast<Container*>(topLevelWidget());
                    if (container->wnd() == m_userWnd)
                        bSetFocus = true;
                }
                setMessage(msg, bSetFocus);
            }else{
                if (m_edit->isReadOnly())
                    QTimer::singleShot(0, this, SLOT(setupNext()));
            }
        }
    }
    if (e->type() == EventRealSendMessage){
        MsgSend *s = (MsgSend*)(e->param());
        if (s->edit == this){
            sendMessage(s->msg);
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->param == this) && (cmd->id == CmdTranslit)){
            Contact *contact = getContacts()->contact(m_userWnd->id());
            if (contact){
                TranslitUserData *data = (TranslitUserData*)(contact->getUserData(CorePlugin::m_plugin->translit_data_id));
                if (data){
                    cmd->flags &= ~COMMAND_CHECKED;
                    if (data->Translit)
                        cmd->flags |= COMMAND_CHECKED;
                }
            }
            return NULL;
        }
        if ((cmd->menu_id != MenuTextEdit) || (cmd->param != this))
            return NULL;
        cmd->flags &= ~(COMMAND_CHECKED | COMMAND_DISABLED);
        switch (cmd->id){
        case CmdUndo:
            if (m_edit->isReadOnly())
                return NULL;
            if (!m_edit->isUndoAvailable())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdRedo:
            if (m_edit->isReadOnly())
                return NULL;
            if (!m_edit->isRedoAvailable())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdCut:
            if (m_edit->isReadOnly())
                return NULL;
        case CmdCopy:
            if (!m_edit->hasSelectedText())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdPaste:
            if (m_edit->isReadOnly())
                return NULL;
            if (QApplication::clipboard()->text().isEmpty())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        case CmdClear:
            if (m_edit->isReadOnly())
                return NULL;
        case CmdSelectAll:
            if (m_edit->text().isEmpty())
                cmd->flags |= COMMAND_DISABLED;
            return e->param();
        }
        return NULL;
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->id == CmdSmile) && (cmd->param == this)){
            Event eBtn(EventCommandWidget, cmd);
            QToolButton *btnSmile = (QToolButton*)(eBtn.process());
            if (btnSmile){
                SmilePopup *popup = new SmilePopup(this);
                QSize s = popup->minimumSizeHint();
                popup->resize(s);
                connect(popup, SIGNAL(insert(int)), this, SLOT(insertSmile(int)));
                QPoint p = CToolButton::popupPos(btnSmile, popup);
                popup->move(p);
                popup->show();
            }
            return e->param();
        }
Beispiel #23
0
bool SyncRunner::syncRemoteToLocal(qint32 updateCount) {
    QLOG_TRACE_IN();

    // The sync is run in several parts.
    // Part #1: Get all remote tags, notebooks, & saved searches for
    //          a user's account.  We do this first because we want
    //          the tag & notebook naems for filling out the note table.
    //          It is just easier this way.
    // Part #2: Get all changed notes & resources.  If it is a full sync
    //          then we get the resources & notes together as one entity
    //          (the resource chunk won't have anything).  We also do not
    //          get deleted notes on a full sync.  If it is a partial sync
    //          then we get resources & notes separately (i.e. the notes chunk
    //          may reference a resource guid, but it won't have the detail and
    //          the chunk resources will have valid data.  We get deleted notes
    //          on a partial sync.
    // Part #3: Upload anything local to the user's account.
    // Part #4: Do linked notebook stuff.  Basically the same as
    //          this except we do it across multiple accounts.

    int chunkSize = 5000;
    bool more = true;

    bool rc;
    int startingSequenceNumber = updateSequenceNumber;

    while (more && keepRunning) {
        SyncChunk chunk;
        rc = comm->getSyncChunk(chunk, updateSequenceNumber, chunkSize,
                                SYNC_CHUNK_LINKED_NOTEBOOKS | SYNC_CHUNK_NOTEBOOKS |
                                SYNC_CHUNK_TAGS | SYNC_CHUNK_SEARCHES | SYNC_CHUNK_EXPUNGED,
                                fullSync);
        if (!rc) {
            QLOG_ERROR() << "Error retrieving chunk";
            error = true;
            this->communicationErrorHandler();
            QLOG_TRACE_OUT();
            return false;
        }
        QLOG_DEBUG() << "-(Pass 1)->>>>  Old USN:" << updateSequenceNumber << " New USN:" << chunk.chunkHighUSN;
        int pct = (updateSequenceNumber - startingSequenceNumber) * 100 / (updateCount - startingSequenceNumber);
        emit setMessage(tr("Download ") + QString::number(pct) + tr("% complete for notebooks, tags, & searches."),
                        defaultMsgTimeout);

        processSyncChunk(chunk);

        updateSequenceNumber = chunk.chunkHighUSN;
        if (!chunk.chunkHighUSN.isSet() || chunk.chunkHighUSN >= chunk.updateCount)
            more = false;
    }

    emit setMessage(tr("Download complete for notebooks, tags, & searches.  Downloading notes."), defaultMsgTimeout);

    comm->loadTagGuidMap();
    more = true;
    chunkSize = 50;
    updateSequenceNumber = startingSequenceNumber;
    UserTable userTable(db);


    while (more && keepRunning) {
        SyncChunk chunk;
        rc = comm->getSyncChunk(chunk, updateSequenceNumber, chunkSize, SYNC_CHUNK_NOTES | SYNC_CHUNK_RESOURCES,
                                fullSync);
        if (!rc) {
            QLOG_ERROR() << "Error retrieving chunk";
            error = true;
            this->communicationErrorHandler();
            QLOG_TRACE_OUT();
            return false;
        }
        QLOG_DEBUG() << "-(Pass 2) ->>>>  Old USN:" << updateSequenceNumber << " New USN:" << chunk.chunkHighUSN;
        int pct = (updateSequenceNumber - startingSequenceNumber) * 100 / (updateCount - startingSequenceNumber);
        emit setMessage(tr("Download ") + QString::number(pct) + tr("% complete."), defaultMsgTimeout);
        processSyncChunk(chunk);

        userTable.updateLastSyncNumber(chunk.chunkHighUSN);
        userTable.updateLastSyncDate(chunk.currentTime);

        updateSequenceNumber = chunk.chunkHighUSN;
        if (!chunk.chunkHighUSN.isSet() || chunk.chunkHighUSN >= chunk.updateCount) {
            more = false;
            userTable.updateLastSyncNumber(updateCount);
        }
    }

    emit setMessage(tr("Download complete."), defaultMsgTimeout);
    QLOG_TRACE_OUT();
    return true;
}