コード例 #1
0
ファイル: menu_actions-alua.c プロジェクト: byteworks-ch/esos
/*
 * Run the Remove Device Group dialog
 */
void remDevGrpDialog(CDKSCREEN *main_cdk_screen) {
    char dev_grp_name[MAX_SYSFS_ATTR_SIZE] = {0},
    attr_path[MAX_SYSFS_PATH_SIZE] = {0},
    attr_value[MAX_SYSFS_ATTR_SIZE] = {0};
    char *error_msg = NULL, *confirm_msg = NULL;
    boolean confirm = FALSE;
    int temp_int = 0;

    /* Have the user choose a SCST device group */
    getSCSTDevGrpChoice(main_cdk_screen, dev_grp_name);
    if (dev_grp_name[0] == '\0')
        return;

    /* Get a final confirmation from user before we delete */
    SAFE_ASPRINTF(&confirm_msg,
            "Are you sure you want to delete SCST device group '%s?'",
            dev_grp_name);
    confirm = confirmDialog(main_cdk_screen, confirm_msg, NULL);
    FREE_NULL(confirm_msg);
    if (confirm) {
        /* Delete the specified SCST device group */
        snprintf(attr_path, MAX_SYSFS_PATH_SIZE,
                "%s/device_groups/mgmt", SYSFS_SCST_TGT);
        snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "del %s", dev_grp_name);
        if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) {
            SAFE_ASPRINTF(&error_msg, "Couldn't delete SCST (ALUA) device group: %s",
                    strerror(temp_int));
            errorDialog(main_cdk_screen, error_msg, NULL);
            FREE_NULL(error_msg);
        }
    }

    /* Done */
    return;
}
コード例 #2
0
void SELMainLibraryWidget::showAddItemConfirmDialog(EntertainmentItem * item)
{
    QMessageBox confirmDialog(QMessageBox::Question, "Add to Library?", "",
                              QMessageBox::Ok | QMessageBox::Cancel, this);
    QString dialogText;
    bool itemOwned = controller.checkUserOwnsItem(item->getId());
    bool success;
    int dialogResult;
    
    if (!itemOwned) {
        dialogText = "Add the selected item (";
        dialogText += item->getTitle().c_str();
        dialogText += ") to your library?";
        confirmDialog.setText(dialogText);
        confirmDialog.setDefaultButton(QMessageBox::Ok);
        dialogResult = confirmDialog.exec();
        if (dialogResult == QMessageBox::Ok) {
            success = controller.addItemToUserLibrary(item->getId());
            if (success) {
                QMessageBox::information(this, "Success!", "Item added");
                userLibraryChanged = true;
            } else {
                Error::raiseError(Error::ERROR_ITEM_ADD_FAIL);
            }
        }
    } else {
        Error::raiseError(Error::ERROR_ITEM_OWNED);
    }
}
コード例 #3
0
ファイル: menu_actions-alua.c プロジェクト: byteworks-ch/esos
/*
 * Run the Remove Target from Group dialog
 */
void remTgtFromGrpDialog(CDKSCREEN *main_cdk_screen) {
    char dev_grp_name[MAX_SYSFS_ATTR_SIZE] = {0},
    tgt_grp_name[MAX_SYSFS_ATTR_SIZE] = {0},
    target_name[MAX_SYSFS_ATTR_SIZE] = {0},
    attr_path[MAX_SYSFS_PATH_SIZE] = {0},
    attr_value[MAX_SYSFS_ATTR_SIZE] = {0};
    char *error_msg = NULL, *confirm_msg = NULL;
    boolean confirm = FALSE;
    int temp_int = 0;

    /* Have the user choose a SCST device group */
    getSCSTDevGrpChoice(main_cdk_screen, dev_grp_name);
    if (dev_grp_name[0] == '\0')
        return;

    /* Get target group choice from user (based on previously
     * selected device group) */
    getSCSTTgtGrpChoice(main_cdk_screen, dev_grp_name, tgt_grp_name);
    if (tgt_grp_name[0] == '\0')
        return;

    /* Get target group choice from user (based on previously
     * selected device group) */
    getSCSTTgtGrpTgtChoice(main_cdk_screen, dev_grp_name, tgt_grp_name,
            target_name);
    if (target_name[0] == '\0')
        return;

    /* Get a final confirmation from user before we delete */
    SAFE_ASPRINTF(&confirm_msg, "target '%s' from group '%s?'",
            target_name, tgt_grp_name);
    confirm = confirmDialog(main_cdk_screen,
            "Are you sure you want to remove SCST", confirm_msg);
    FREE_NULL(confirm_msg);
    if (confirm) {
        /* Remove the SCST target from the target group (ALUA) */
        snprintf(attr_path, MAX_SYSFS_PATH_SIZE,
                "%s/device_groups/%s/target_groups/%s/mgmt",
                SYSFS_SCST_TGT, dev_grp_name, tgt_grp_name);
        snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "del %s", target_name);
        if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) {
            SAFE_ASPRINTF(&error_msg,
                    "Couldn't delete SCST (ALUA) target from target group: %s",
                    strerror(temp_int));
            errorDialog(main_cdk_screen, error_msg, NULL);
            FREE_NULL(error_msg);
        }
    }

    /* Done */
    return;
}