summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Krishnia-INTERN <nkrishnia@nvidia.com>2017-12-12 02:57:03 -0800
committerAaron Plattner <aplattner@nvidia.com>2018-01-04 10:27:59 -0800
commit2fb5615fe0ce3d9182b7ac86629022497fec4081 (patch)
tree64d1e1e3164dfaf429a2e2c2e1be52f1939e63f8
parent8bb5cbaa8978c043d29c4a05ff5828399e1b30ce (diff)
Modifications in the sensitivity of Apply/Cancel button in 'Manage License' page of nvidia-settings:
Issue: Apply/Cancel button is disabled post moving from "Quadro Virtual" "Datacenter Workstation" license edition to "Unlicensed Tesla" license edition. Fix: Apply/Cancel buttons are enabled only under following cases: * If the License Edition has changed, that is the corresponding feature type selection has changed. * If any of the textbox entry has changed. Also updating the license Acquiring, unlicensed and failed message strings on UI according to the feature type selection.
-rw-r--r--src/gtk+-2.x/ctkgridlicense.c126
-rw-r--r--src/gtk+-2.x/ctkgridlicense.h3
-rw-r--r--src/nv_grid_dbus.h13
3 files changed, 132 insertions, 10 deletions
diff --git a/src/gtk+-2.x/ctkgridlicense.c b/src/gtk+-2.x/ctkgridlicense.c
index 0100b08..f3d1d1e 100644
--- a/src/gtk+-2.x/ctkgridlicense.c
+++ b/src/gtk+-2.x/ctkgridlicense.c
@@ -734,6 +734,7 @@ static gboolean update_manage_grid_license_state_info(gpointer user_data)
gboolean ret = TRUE;
int licenseStatus = NV_GRID_UNLICENSED;
+ int licenseFeatureType = GRID_LICENSED_FEATURE_TYPE_TESLA;
/* Send license state request */
if (!(send_message_to_gridd(ctk_manage_grid_license, LICENSE_STATE_REQUEST,
@@ -741,6 +742,12 @@ static gboolean update_manage_grid_license_state_info(gpointer user_data)
ret = FALSE;
}
+ /* Send license feature type request */
+ if (!(send_message_to_gridd(ctk_manage_grid_license, LICENSE_FEATURE_TYPE_REQUEST,
+ &licenseFeatureType))) {
+ ret = FALSE;
+ }
+
/* Set default unlicensed state string if could not communicate with nvidia-gridd */
if (licenseStatus == NV_GRID_UNLICENSED)
{
@@ -760,10 +767,24 @@ static gboolean update_manage_grid_license_state_info(gpointer user_data)
/* Set correct status message when Quadro Virtual Datacenter Workstation
* checkbox selected */
if ((licenseStatus == NV_GRID_UNLICENSED_TESLA) &&
- (ctk_manage_grid_license->license_edition_gvw_selected == TRUE)) {
+ (ctk_manage_grid_license->feature_type == GRID_LICENSED_FEATURE_TYPE_GVW)) {
licenseStatus = NV_GRID_UNLICENSED_GVW_SELECTED;
}
+ /* Set correct status message when Tesla (unlicensed)
+ * checkbox selected */
+ if ((licenseStatus == NV_GRID_UNLICENSED_GVW_SELECTED) &&
+ (ctk_manage_grid_license->feature_type == GRID_LICENSED_FEATURE_TYPE_TESLA)) {
+ licenseStatus = NV_GRID_UNLICENSED_TESLA;
+ }
+
+ /* Set correct status message when Quadro Virtual Datacenter Workstation
+ * checkbox selected in licensed state.*/
+ if ((licenseStatus == NV_GRID_LICENSE_RESTART_REQUIRED) &&
+ (ctk_manage_grid_license->license_feature_type == GRID_LICENSED_FEATURE_TYPE_GVW)) {
+ licenseStatus = NV_GRID_LICENSE_ACQUIRED_GVW;
+ }
+
/* Show the message received */
switch (licenseStatus) {
case NV_GRID_UNLICENSED_VGPU:
@@ -823,6 +844,22 @@ static gboolean update_manage_grid_license_state_info(gpointer user_data)
break;
}
+ ctk_manage_grid_license->license_status = licenseStatus;
+ switch (licenseFeatureType) {
+ case NV_GRID_LICENSED_FEATURE_TYPE_TESLA:
+ licenseFeatureType = GRID_LICENSED_FEATURE_TYPE_TESLA;
+ break;
+ case NV_GRID_LICENSED_FEATURE_TYPE_VGPU:
+ licenseFeatureType = GRID_LICENSED_FEATURE_TYPE_VGPU;
+ break;
+ case NV_GRID_LICENSED_FEATURE_TYPE_GVW:
+ licenseFeatureType = GRID_LICENSED_FEATURE_TYPE_GVW;
+ break;
+ default:
+ break;
+ }
+ ctk_manage_grid_license->license_feature_type = licenseFeatureType;
+
gtk_label_set_text(GTK_LABEL(ctk_manage_grid_license->label_license_state),
licenseState);
return ret;
@@ -939,6 +976,18 @@ static void license_edition_toggled(GtkWidget *widget, gpointer user_data)
CtkManageGridLicense *ctk_manage_grid_license = CTK_MANAGE_GRID_LICENSE(user_data);
gboolean enabled;
gchar *licenseState = "";
+ NvGriddConfigParams *griddConfig;
+ const char *textBoxServerStr, *textBoxServerPortStr, *textBoxSecondaryServerStr, *textBoxSecondaryServerPortStr;
+
+ griddConfig = GetNvGriddConfigParams();
+ if (!griddConfig) {
+ return;
+ }
+
+ textBoxServerStr = gtk_entry_get_text(GTK_ENTRY(ctk_manage_grid_license->txt_server_address));
+ textBoxServerPortStr = gtk_entry_get_text(GTK_ENTRY(ctk_manage_grid_license->txt_server_port));
+ textBoxSecondaryServerStr = gtk_entry_get_text(GTK_ENTRY(ctk_manage_grid_license->txt_secondary_server_address));
+ textBoxSecondaryServerPortStr = gtk_entry_get_text(GTK_ENTRY(ctk_manage_grid_license->txt_secondary_server_port));
enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
if (!enabled) {
@@ -952,18 +1001,60 @@ static void license_edition_toggled(GtkWidget *widget, gpointer user_data)
licenseState = "You selected Quadro Virtual Datacenter Workstation Edition.";
ctk_manage_grid_license->feature_type =
GRID_LICENSED_FEATURE_TYPE_GVW;
- ctk_manage_grid_license->license_edition_gvw_selected = TRUE;
+ /* Enable Apply/Cancel button if the feature type selection has changed*/
+ if (strcmp(griddConfig->str[NV_GRIDD_FEATURE_TYPE], "2") != 0) {
+ /* Disable Apply/Cancel button if Primary server address textbox string is empty. */
+ if (strcmp(textBoxServerStr, "") == 0) {
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, FALSE);
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, FALSE);
+ } else {
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, TRUE);
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, TRUE);
+ }
+ } else {
+ /* feature type selection has not changed. But Enable Apply/Cancel button when user make changes
+ in any of the textbox entries to retain those changes. */
+ if ((strcmp(griddConfig->str[NV_GRIDD_SERVER_ADDRESS], textBoxServerStr) != 0) ||
+ ((strcmp(griddConfig->str[NV_GRIDD_BACKUP_SERVER_ADDRESS], textBoxSecondaryServerStr) != 0) ||
+ (strcmp(griddConfig->str[NV_GRIDD_BACKUP_SERVER_PORT], textBoxSecondaryServerPortStr) != 0) ||
+ (strcmp(griddConfig->str[NV_GRIDD_SERVER_PORT], textBoxServerPortStr) != 0))) {
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, TRUE);
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, TRUE);
+ } else {
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, FALSE);
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, FALSE);
+ }
+ }
+
} else if (GPOINTER_TO_INT(user_data) == GRID_LICENSED_FEATURE_TYPE_TESLA) {
gtk_widget_set_sensitive(ctk_manage_grid_license->box_server_info, FALSE);
/* force unlicensed mode */
ctk_manage_grid_license->feature_type =
GRID_LICENSED_FEATURE_TYPE_TESLA;
licenseState = "You selected Tesla (Unlicensed) mode.";
- ctk_manage_grid_license->license_edition_gvw_selected = FALSE;
+ /* Enable Apply/Cancel button if the feature type selection has changed*/
+ if (strcmp(griddConfig->str[NV_GRIDD_FEATURE_TYPE], "0") != 0) {
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, TRUE);
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, TRUE);
+ } else {
+ /* feature type selection has not changed. But Enable Apply/Cancel button when user make changes
+ in any of the textbox entries to retain those changes. */
+ if ((strcmp(griddConfig->str[NV_GRIDD_SERVER_ADDRESS], textBoxServerStr) != 0) ||
+ ((strcmp(griddConfig->str[NV_GRIDD_BACKUP_SERVER_ADDRESS], textBoxSecondaryServerStr) != 0) ||
+ (strcmp(griddConfig->str[NV_GRIDD_BACKUP_SERVER_PORT], textBoxSecondaryServerPortStr) != 0) ||
+ (strcmp(griddConfig->str[NV_GRIDD_SERVER_PORT], textBoxServerPortStr) != 0))) {
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, TRUE);
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, TRUE);
+ } else {
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, FALSE);
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, FALSE);
+ }
+ }
}
/* update status bar message */
ctk_config_statusbar_message(ctk_manage_grid_license->ctk_config,
"%s", licenseState);
+ FreeNvGriddConfigParams(griddConfig);
}
static gboolean disallow_whitespace(GtkWidget *widget, GdkEvent *event, gpointer user_data)
@@ -1240,8 +1331,8 @@ GtkWidget* ctk_manage_grid_license_new(CtrlTarget *target,
ctk_manage_grid_license->ctk_config = ctk_config;
ctk_manage_grid_license->license_edition_state = mode;
ctk_manage_grid_license->dbusData = dbusData;
- ctk_manage_grid_license->license_edition_gvw_selected = FALSE;
ctk_manage_grid_license->feature_type = 0;
+ ctk_manage_grid_license->license_status = 0;
/* set default value for feature type based on the user configured parameter or virtualization mode */
if (griddConfig) {
@@ -1496,7 +1587,6 @@ GtkWidget* ctk_manage_grid_license_new(CtrlTarget *target,
/* Apply button */
ctk_manage_grid_license->btn_apply = gtk_button_new_with_label
(" Apply ");
- gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, FALSE);
gtk_widget_set_size_request(ctk_manage_grid_license->btn_apply, 100, -1);
ctk_config_set_tooltip(ctk_config, ctk_manage_grid_license->btn_apply,
__apply_button_help);
@@ -1511,7 +1601,6 @@ GtkWidget* ctk_manage_grid_license_new(CtrlTarget *target,
/* Cancel button */
ctk_manage_grid_license->btn_cancel = gtk_button_new_with_label
(" Cancel ");
- gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, FALSE);
gtk_widget_set_size_request(ctk_manage_grid_license->btn_cancel, 100, -1);
ctk_config_set_tooltip(ctk_config, ctk_manage_grid_license->btn_cancel,
__cancel_button_help);
@@ -1533,7 +1622,6 @@ GtkWidget* ctk_manage_grid_license_new(CtrlTarget *target,
}
}
- FreeNvGriddConfigParams(griddConfig);
/* Register a timer callback to update license status info */
str = g_strdup_printf("Manage GRID License");
@@ -1543,9 +1631,31 @@ GtkWidget* ctk_manage_grid_license_new(CtrlTarget *target,
str,
(GSourceFunc) update_manage_grid_license_state_info,
(gpointer) ctk_manage_grid_license);
- g_free(str);
+
update_manage_grid_license_state_info(ctk_manage_grid_license);
+ /* Enable Apply/Cancel button if user edits feature type from nvidia-gridd in all license states except unlicensed state. */
+ if ((ctk_manage_grid_license->license_status != NV_GRID_UNLICENSED_TESLA) || (ctk_manage_grid_license->license_status != NV_GRID_UNLICENSED_GVW_SELECTED ))
+ {
+ int featureType = atoi(griddConfig->str[NV_GRIDD_FEATURE_TYPE]);
+ if (featureType != ctk_manage_grid_license->license_feature_type) {
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, TRUE);
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, TRUE);
+ }
+ else {
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, FALSE);
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, FALSE);
+ }
+ }
+ else {
+ /* Disable Apply/Cancel button. */
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_apply, FALSE);
+ gtk_widget_set_sensitive(ctk_manage_grid_license->btn_cancel, FALSE);
+ }
+
+ g_free(str);
+ FreeNvGriddConfigParams(griddConfig);
+
done:
gtk_widget_show_all(GTK_WIDGET(ctk_manage_grid_license));
diff --git a/src/gtk+-2.x/ctkgridlicense.h b/src/gtk+-2.x/ctkgridlicense.h
index 54ac6d2..b8fde06 100644
--- a/src/gtk+-2.x/ctkgridlicense.h
+++ b/src/gtk+-2.x/ctkgridlicense.h
@@ -66,8 +66,9 @@ struct _CtkManageGridLicense
DbusData *dbusData;
gint license_edition_state;
- gboolean license_edition_gvw_selected;
gint feature_type;
+ int license_status;
+ int license_feature_type;
};
struct _CtkManageGridLicenseClass
diff --git a/src/nv_grid_dbus.h b/src/nv_grid_dbus.h
index 7c4f51e..197ddaa 100644
--- a/src/nv_grid_dbus.h
+++ b/src/nv_grid_dbus.h
@@ -27,9 +27,10 @@
#define NV_GRID_DBUS_OBJECT "/nvidia/grid/license"
#define NV_GRID_DBUS_INTERFACE "nvidia.grid.license"
#define NV_GRID_DBUS_METHOD "GridLicenseState"
+#define LICENSE_DETAILS_UPDATE_SUCCESS 0
#define LICENSE_STATE_REQUEST 1
#define LICENSE_DETAILS_UPDATE_REQUEST 2
-#define LICENSE_DETAILS_UPDATE_SUCCESS 0
+#define LICENSE_FEATURE_TYPE_REQUEST 3
/*
* List of grid license states
@@ -51,4 +52,14 @@ typedef enum
NV_GRID_LICENSE_RESTART_REQUIRED, // Restart your system for Tesla Edition. Your system is currently running Quadro Virtual Datacenter Workstation Edition.
} gridLicenseStatus;
+/*
+ * List of grid license feature types
+ */
+typedef enum
+{
+ NV_GRID_LICENSED_FEATURE_TYPE_TESLA = 0,
+ NV_GRID_LICENSED_FEATURE_TYPE_VGPU,
+ NV_GRID_LICENSED_FEATURE_TYPE_GVW,
+} gridLicenseFeatureType;
+
#endif // _NVIDIA_NV_GRID_DBUS_H_