RocketStorageInfoDialog::RocketStorageInfoDialog(RocketPlugin *plugin, const QString &title, MeshmoonStorageOperationMonitor *_monitor) :
    plugin_(plugin),
    monitor(_monitor)
{
    ui.setupUi(this);

    setWindowModality(Qt::ApplicationModal);
    setWindowFlags(Qt::SplashScreen);
    setModal(true);
    
    ui.labelTitle->setText(title);
    ui.labelInputTitle->hide();
    ui.lineEditInput->hide();
    ui.labelText->hide();
    hide();

    connect(ui.buttonOk, SIGNAL(clicked()), SIGNAL(AcceptClicked()));
    connect(ui.buttonCancel, SIGNAL(clicked()), SLOT(reject()));
    connect(this, SIGNAL(rejected()), plugin_->Notifications(), SLOT(ClearForeground()));
    connect(this, SIGNAL(rejected()), SIGNAL(Rejected()));
}
Example #2
0
/*
 * Challenger side of the SASL conversation
 */
static AJ_Status Challenge(AJ_SASL_Context* context, char* inStr, char* outStr, uint32_t outLen)
{
    AJ_Status status = AJ_OK;
    AJ_AuthResult result;
    const char* rsp = outStr;
    const char* cmd = ParseCmd(&inStr);

    /*
     * The ERROR command is handled the same in all states.
     */
    if (cmd == CMD_ERROR || ((cmd == CMD_CANCEL) && (context->state != AJ_SASL_WAIT_FOR_AUTH))) {
        status = Rejected(context, outStr, outLen);
        if (status == AJ_OK) {
            status = AppendCRLF(outStr, outLen);
        }
        context->state = AJ_SASL_WAIT_FOR_AUTH;
        return status;
    }

    switch (context->state) {
    case AJ_SASL_WAIT_FOR_AUTH:
        if (cmd == CMD_AUTH) {
            context->mechanism = MatchMechanism(context, &inStr);
            if (!context->mechanism) {
                result = AJ_AUTH_STATUS_RETRY;
                status = Rejected(context, outStr, outLen);
                break;
            } else {
                status = context->mechanism->Init(AJ_AUTH_CHALLENGER, context->pwdFunc);
                /*
                 * Initialization must succeed
                 */
                if (status != AJ_OK) {
                    break;
                }
            }
            /*
             * Data following an AUTH command is handled sames as DATA command
             */
            if ((*inStr) || (strcmp(context->mechanism->name, "ANONYMOUS") == 0)) {
                cmd = CMD_DATA;
            } else {
                break;
            }
        }
    /* Falling through */

    case AJ_SASL_WAIT_FOR_DATA:
        if (cmd == CMD_DATA) {
            if (strcmp(context->mechanism->name, "ANONYMOUS") != 0) {
                status = HexDecode(inStr);
            }
            if (status == AJ_OK) {
                result = context->mechanism->Challenge(inStr, outStr, outLen);
                if (result == AJ_AUTH_STATUS_SUCCESS) {
                    AJ_GUID localGuid;
                    AJ_GetLocalGUID(&localGuid);
                    status = AJ_GUID_ToString(&localGuid, outStr, outLen);
                    if (status == AJ_OK) {
                        status = PrependStr(CMD_OK, outStr, outLen, FALSE);
                    }
                    context->state = AJ_SASL_WAIT_FOR_BEGIN;
                } else if (result == AJ_AUTH_STATUS_CONTINUE) {
                    status = PrependStr(CMD_DATA, outStr, outLen, TRUE);
                    context->state = AJ_SASL_WAIT_FOR_DATA;
                } else if (result == AJ_AUTH_STATUS_RETRY) {
                    status = Rejected(context, outStr, outLen);
                } else if (result == AJ_AUTH_STATUS_FAILURE) {
                    status = AJ_ERR_SECURITY;
                } else {
                    rsp = CMD_ERROR;
                }
            }
        } else if (cmd == CMD_BEGIN) {
            status = AJ_ERR_SECURITY;
        } else {
            rsp = CMD_ERROR;
        }
        break;

    case AJ_SASL_WAIT_FOR_BEGIN:
        if (cmd == CMD_BEGIN) {
            context->state = AJ_SASL_AUTHENTICATED;
        } else {
            rsp = CMD_ERROR;
        }
        break;

    default:
        status = AJ_ERR_UNEXPECTED;
    }

    if (status == AJ_OK) {
        if (rsp != outStr) {
            status = SetStr(rsp, outStr, outLen);
        }
    }

    /* The Challenger does not send out any SASL message once the state is AJ_SASL_AUTHENTICATED
       i.e after the BEGIN command is received. So we should not append the CRLF. This results
       in unwanted bytes being put in the tx buffer which gets sent out to the Responder. */
    if ((status == AJ_OK) && (context->state != AJ_SASL_AUTHENTICATED)) {
        status = AppendCRLF(outStr, outLen);
    }
    return status;
}