コード例 #1
0
void WizardWelcome::serialInvalidHandle()
{
    qDebug() << Q_FUNC_INFO;
    ConfirmDialog* dialog = new ConfirmDialog(this,tr("There is an error with the Serial Number ") + "(" + DeviceInfo::getInstance()->getSerialNumber() + ")" + tr(". Please contact with support."));
    QBookApp::instance()->getStatusBar()->setSpinner(false);
    Screen::getInstance()->setMode(Screen::MODE_SAFE,true,FLAG_IGNORE_QUEUE,Q_FUNC_INFO);
    dialog->exec();
    delete dialog;
    QBookApp::instance()->goToHome();
}
コード例 #2
0
void WizardWelcome::headersProblem()
{
    qDebug() << Q_FUNC_INFO;

    ConfirmDialog* dialog = new ConfirmDialog(this,tr("There is a problem in wizard. Please contact with support."));
    QBookApp::instance()->getStatusBar()->setSpinner(false);
    Screen::getInstance()->setMode(Screen::MODE_SAFE,true,FLAG_IGNORE_QUEUE,Q_FUNC_INFO);
    dialog->exec();
    delete dialog;

    ConnectionManager::getInstance()->removeAll();
    goToWifi();
}
コード例 #3
0
void WizardWelcome::connectivityProblem()
{
    qDebug() << Q_FUNC_INFO;

    ConfirmDialog* dialog = new ConfirmDialog(this,tr("Connection problem. Please, select another WiFi."));
    QBookApp::instance()->getStatusBar()->setSpinner(false);
    Screen::getInstance()->setMode(Screen::MODE_SAFE,true,FLAG_IGNORE_QUEUE,Q_FUNC_INFO);
    dialog->exec();
    delete dialog;

    ConnectionManager::getInstance()->removeAll();
    goToWifi();
}
コード例 #4
0
void WizardWelcome::showRegisterFailed()
{
    qDebug() << Q_FUNC_INFO;

    ConfirmDialog* dialog = new ConfirmDialog(this,tr("Credit Card Register failed."));
    Screen::getInstance()->setMode(Screen::MODE_SAFE,true,Q_FUNC_INFO);
    dialog->exec();
    delete dialog;

    QBookApp::instance()->popForm(QBookApp::instance()->browserWizard());

    if(!m_elfFinishWizard)
    {
        m_elfFinishWizard = new WizardFinish(this);
        connect(m_elfFinishWizard, SIGNAL(closeWizard()), this, SLOT(goToCloseWizard()));
    }
    showElement(m_elfFinishWizard);
}
コード例 #5
0
ファイル: tradehandler.cpp プロジェクト: TonyRice/mana
void TradeHandler::handleMessage(Net::MessageIn &msg)
{
    switch (msg.getId())
    {
        case GPMSG_TRADE_REQUEST:
        {
            Being *being = actorSpriteManager->findBeing(msg.readInt16());
            if (!being || !mAcceptTradeRequests)
            {
                respond(false);
                break;
            }
            mTrading = true;
            tradePartnerName = being->getName();
            tradePartnerID = being->getId();
            ConfirmDialog *dlg = new ConfirmDialog(_("Request for Trade"),
                    strprintf(_("%s wants to trade with you, do you accept?"),
                            tradePartnerName.c_str()));
            dlg->addActionListener(&listener);
        }   break;

        case GPMSG_TRADE_ADD_ITEM:
        {
            int type = msg.readInt16();
            int amount = msg.readInt8();
            tradeWindow->addItem(type, false, amount);
        }   break;

        case GPMSG_TRADE_SET_MONEY:
            tradeWindow->setMoney(msg.readInt32());
            break;

        case GPMSG_TRADE_START:
            tradeWindow->reset();
            tradeWindow->setCaption(strprintf(_("Trading with %s"),
                                              tradePartnerName.c_str()));
            tradeWindow->setVisible(true);
            break;

        case GPMSG_TRADE_BOTH_CONFIRM:
            tradeWindow->receivedOk(false);
            break;

        case GPMSG_TRADE_AGREED:
            tradeWindow->receivedOk(false);
            break;

        case GPMSG_TRADE_CANCEL:
            SERVER_NOTICE(_("Trade canceled."))
            tradeWindow->setVisible(false);
            tradeWindow->reset();
            mTrading = false;
            break;

        case GPMSG_TRADE_COMPLETE:
            SERVER_NOTICE(_("Trade completed."))
            tradeWindow->setVisible(false);
            tradeWindow->reset();
            mTrading = false;
            break;
    }
}
コード例 #6
0
void TradeHandler::handleMessage(Net::MessageIn &msg)
{
    switch (msg.getId())
    {
        case SMSG_TRADE_REQUEST:
                // If a trade window or request window is already open, send a
                // trade cancel to any other trade request.
                //
                // Note that it would be nice if the server would prevent this
                // situation, and that the requesting player would get a
                // special message about the player being occupied.
                tradePartnerName = msg.readString(24);

                if (player_relations.hasPermission(tradePartnerName,
                                                   PlayerRelation::TRADE))
                {
                    if (!player_node->tradeRequestOk())
                    {
                        Net::getTradeHandler()->respond(false);
                        break;
                    }

                    player_node->setTrading(true);
                    ConfirmDialog *dlg;
                    dlg = new ConfirmDialog(_("Request for Trade"),
                            strprintf(_("%s wants to trade with you, do you "
                                    "accept?"), tradePartnerName.c_str()));
                    dlg->addActionListener(&listener);
                }
                else
                {
                    Net::getTradeHandler()->respond(false);
                    break;
                }
            break;

        case SMSG_TRADE_RESPONSE:
            switch (msg.readInt8())
            {
                case 0: // Too far away
                    localChatTab->chatLog(_("Trading isn't possible. Trade "
                            "partner is too far away."), BY_SERVER);
                    break;
                case 1: // Character doesn't exist
                    localChatTab->chatLog(_("Trading isn't possible. Character "
                            "doesn't exist."), BY_SERVER);
                    break;
                case 2: // Invite request check failed...
                    localChatTab->chatLog(_("Trade cancelled due to an unknown "
                            "reason."), BY_SERVER);
                    break;
                case 3: // Trade accepted
                    tradeWindow->reset();
                    tradeWindow->setCaption(strprintf(_("Trade: You and %s"),
                            tradePartnerName.c_str()));
                    tradeWindow->setVisible(true);
                    break;
                case 4: // Trade cancelled
                    if (player_relations.hasPermission(tradePartnerName,
                                                       PlayerRelation::SPEECH_LOG))
                        localChatTab->chatLog(strprintf(_("Trade with %s "
                                "cancelled."), tradePartnerName.c_str()),
                                BY_SERVER);
                    // otherwise ignore silently

                    tradeWindow->setVisible(false);
                    player_node->setTrading(false);
                    break;
                default: // Shouldn't happen as well, but to be sure
                    localChatTab->chatLog(_("Unhandled trade cancel packet."),
                            BY_SERVER);
                    break;
            }
            break;

        case SMSG_TRADE_ITEM_ADD:
            {
                int amount = msg.readInt32();
                int type = msg.readInt16();
                msg.readInt8();  // identified flag
                msg.readInt8();  // attribute
                msg.readInt8();  // refine
                msg.skip(8);     // card (4 shorts)

                // TODO: handle also identified, etc
                if (type == 0) {
                    tradeWindow->setMoney(amount);
                } else {
                    tradeWindow->addItem(type, false, amount, false);
                }
            }
            break;

        case SMSG_TRADE_ITEM_ADD_RESPONSE:
            // Trade: New Item add response (was 0x00ea, now 01b1)
            {
                const int index = msg.readInt16() - INVENTORY_OFFSET;
                Item *item = player_node->getInventory()->getItem(index);
                if (!item)
                {
                    tradeWindow->receivedOk(true);
                    return;
                }
                int quantity = msg.readInt16();

                switch (msg.readInt8())
                {
                    case 0:
                        // Successfully added item
                        if (item->isEquipment() && item->isEquipped())
                        {
                            Net::getInventoryHandler()->unequipItem(item);
                        }
                        tradeWindow->addItem(item->getId(), true, quantity,
                                item->isEquipment());
                        item->increaseQuantity(-quantity);
                        break;
                    case 1:
                        // Add item failed - player overweighted
                        localChatTab->chatLog(_("Failed adding item. Trade "
                                "partner is over weighted."), BY_SERVER);
                        break;
                    case 2:
                         // Add item failed - player has no free slot
                         localChatTab->chatLog(_("Failed adding item. Trade "
                                 "partner has no free slot."), BY_SERVER);
                         break;
                    default:
                        localChatTab->chatLog(_("Failed adding item for "
                                "unknown reason."), BY_SERVER);
                        break;
                }
            }
            break;

        case SMSG_TRADE_OK:
            // 0 means ok from myself, 1 means ok from other;
            tradeWindow->receivedOk(msg.readInt8() == 0);
            break;

        case SMSG_TRADE_CANCEL:
            localChatTab->chatLog(_("Trade canceled."), BY_SERVER);
            tradeWindow->setVisible(false);
            tradeWindow->reset();
            player_node->setTrading(false);
            break;

        case SMSG_TRADE_COMPLETE:
            localChatTab->chatLog(_("Trade completed."), BY_SERVER);
            tradeWindow->setVisible(false);
            tradeWindow->reset();
            player_node->setTrading(false);
            break;
    }
}
コード例 #7
0
void SettingsDictionariesMenu::activateExtraDicts()
{
    qDebug() << Q_FUNC_INFO;
    bqDeviceServices* services = QBookApp::instance()->getDeviceServices();
    services->processSyncCanceled();
    b_downloadCanceled = false;

    if(!downloadDialog)
    {
        downloadDialog = new ProgressDialog(this,tr("Downloading dictionary, please wait for a few minutes."));
        downloadDialog->setHideBtn(false);
        downloadDialog->setTextValue(false);
        downloadDialog->setModal(true);
        connect(downloadDialog, SIGNAL(cancel()),               this,          SLOT(downloadCanceled()), Qt::UniqueConnection);
        connect(services,       SIGNAL(downloadProgress(int)), downloadDialog, SLOT(setProgressBar(int)), Qt::UniqueConnection);
    }

    downloadDialog->setProgressBar(0);
    bool installingPending = false;
    newDictionaryNames.clear();

    QList<DictionaryParams>::const_iterator it = pendingDictsList.constBegin();
    QList<DictionaryParams>::const_iterator itEnd = pendingDictsList.constEnd();
    while(it != itEnd)
    {
        Screen::getInstance()->setMode(Screen::MODE_SAFE,true,FLAG_FULLSCREEN_UPDATE,Q_FUNC_INFO);
        downloadDialog->show();

        if(!(*it).activationState)
        {
            int dixioSize = (*it).dixFileSize * 1024 * 1024;
            int downloadComplementSize = (*it).compFileSize * 1024 * 1024;

            QString downloadPath = Storage::getInstance()->getPrivatePartition()->getMountPoint() + QDir::separator() + "dictionaries" + QDir::separator();
            newDictionaryNames.append(downloadPath + QString((*it).downloadFileName));
            bool downloaded = services->downloadDictionary((*it).downloadUrl, downloadPath + QString((*it).downloadFileName),dixioSize);

            if(downloaded)
            {
                installingPending = true;
                if((*it).downloadUrlComp.size())
                {
                    qDebug() << Q_FUNC_INFO << "downloadUrlComp: " << (*it).downloadUrlComp;
                    downloadDialog->setText(tr("Downloading complements, please wait for a few minutes."));
                    Screen::getInstance()->refreshScreen();
                    newDictionaryNames.append(downloadPath + QString((*it).downloadFileNameComp));
                    if(!services->downloadDictionary((*it).downloadUrlComp, downloadPath + QString((*it).downloadFileNameComp), downloadComplementSize))
                    {
                        downloaded = false;
                        installingPending = false;
                    }
                }
            }

            if(!downloaded && !b_downloadCanceled)
            {
                delete downloadDialog;
                downloadDialog = NULL;
                deleteDictionaryFiles(newDictionaryNames);
                ConfirmDialog* confirmDialog = new ConfirmDialog(this,tr("Download failed. Please try again."));
                Screen::getInstance()->resetQueue();
                Screen::getInstance()->setMode(Screen::MODE_SAFE,true,FLAG_FULLSCREEN_UPDATE|FLAG_IGNORE_QUEUE,Q_FUNC_INFO);
                confirmDialog->exec();
                delete confirmDialog;
                Screen::getInstance()->refreshScreen();
                return;
            }
        }
        it++;
    }

    if(installingPending) {
        downloadDialog->setText(tr("Installing..."));
        downloadDialog->hideCancelButton();
        Screen::getInstance()->refreshScreen();
    } else {
        if(downloadDialog) {
            delete downloadDialog;
            downloadDialog = NULL;
        }
        return;
    }

    QString dixioKey = Dictionary::instance()->getDixioKey();
    qDebug() << Q_FUNC_INFO << "dixioKey: " << dixioKey;
    QString callUrl;
    QString postParameters;
    QString activationResponse;
    bool installingError = false;

    // Get activation data
    if(Dictionary::instance()->getActivation(dixioKey, callUrl, postParameters))
    {
        QString activationRequest = postParameters.split("activationRequest=")[1];
        if(services->callActivationDictionary(activationResponse, activationRequest))
        {
            qDebug() << Q_FUNC_INFO << "activationResponse: " << activationResponse;
            QString activation = QString::fromStdString(Dictionary::instance()->setActivation(dixioKey, activationResponse));
            qDebug() << Q_FUNC_INFO << "activation: " << activation;
            installingError = activation.contains("error");
        } else
            installingError = true;
    } else
        installingError = true;

    delete downloadDialog;
    downloadDialog = NULL;
    ConfirmDialog* confirmDialog;
    if(!installingError)
    {
        confirmDialog = new ConfirmDialog(this,tr("Installing success. Now the system will be turned off."));
        Screen::getInstance()->setMode(Screen::MODE_SAFE,true,FLAG_FULLSCREEN_UPDATE,Q_FUNC_INFO);
        confirmDialog->exec();
        delete confirmDialog;
        QBook::settings().setValue("setting/dictionaryAvailable", false);
        QBook::settings().sync();
        Screen::getInstance()->refreshScreen(Screen::MODE_SAFE,true);
        PowerManager::powerOffDevice(false);
    } else
    {
        deleteDictionaryFiles(newDictionaryNames);
        confirmDialog = new ConfirmDialog(this,tr("Install failed. Please try again."));
        Screen::getInstance()->setMode(Screen::MODE_SAFE,true,FLAG_FULLSCREEN_UPDATE,Q_FUNC_INFO);
        confirmDialog->exec();
        delete confirmDialog;
        Screen::getInstance()->refreshScreen();
    }
}