gboolean capture_remote_combo_add_recent(const gchar *s) { GList *vals = prefs_get_string_list (s); GList *valp = vals; gint auth_type; char *p; struct remote_host *rh; if (valp == NULL) return FALSE; if (remote_host_list == NULL) { remote_host_list = g_hash_table_new (g_str_hash, g_str_equal); } rh = g_malloc (sizeof (*rh)); /* First value is the host */ rh->r_host = g_strdup (valp->data); if (strlen(rh->r_host) == 0) { /* Empty remote host */ g_free(rh->r_host); g_free(rh); return FALSE; } rh->auth_type = CAPTURE_AUTH_NULL; valp = valp->next; if (valp) { /* Found value 2, this is the port number */ rh->remote_port = g_strdup (valp->data); valp = valp->next; } else { /* Did not find a port number */ rh->remote_port = g_strdup (""); } if (valp) { /* Found value 3, this is the authentication type */ auth_type = (gint)strtol(valp->data, &p, 0); if (p != valp->data && *p == '\0') { rh->auth_type = auth_type; } } /* Do not store username and password */ rh->auth_username = g_strdup (""); rh->auth_password = g_strdup (""); prefs_clear_string_list(vals); g_hash_table_insert (remote_host_list, g_strdup(rh->r_host), rh); return TRUE; }
void WiresharkApplication::storeCustomColorsInRecent() { if (QColorDialog::customCount()) { prefs_clear_string_list(recent.custom_colors); recent.custom_colors = NULL; for (int i = 0; i < QColorDialog::customCount(); i++) { #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) QRgb rgb = QColorDialog::customColor(i); #else QRgb rgb = QColorDialog::customColor(i).rgb(); #endif recent.custom_colors = g_list_append(recent.custom_colors, g_strdup_printf("%08x", rgb)); } } }