printers: Don't restrict PPD list

Don't restrict PPD list to PPDs with DeviceIDs only.
Extend dictionary of manufacturers names.
This commit is contained in:
Marek Kasik 2012-08-02 11:47:39 +02:00
parent 1cffa8e206
commit c272aa5eb5
2 changed files with 115 additions and 57 deletions

View file

@ -2127,12 +2127,18 @@ select_ppd_in_dialog (GtkMenuItem *menuitem,
if (!manufacturer) if (!manufacturer)
manufacturer = get_tag_value (device_id, "manufacturer"); manufacturer = get_tag_value (device_id, "manufacturer");
} }
else
if (manufacturer == NULL)
{ {
manufacturer = manufacturer =
get_ppd_attribute (priv->ppd_file_names[priv->current_dest], get_ppd_attribute (priv->ppd_file_names[priv->current_dest],
"Manufacturer"); "Manufacturer");
} }
if (manufacturer == NULL)
{
manufacturer = g_strdup ("Raw");
}
} }
priv->pp_ppd_selection_dialog = pp_ppd_selection_dialog_new ( priv->pp_ppd_selection_dialog = pp_ppd_selection_dialog_new (

View file

@ -3814,20 +3814,37 @@ static const struct {
const char *normalized_name; const char *normalized_name;
const char *display_name; const char *display_name;
} manufacturers_names[] = { } manufacturers_names[] = {
{ "alps", "Alps" },
{ "anitech", "Anitech" },
{ "apple", "Apple" },
{ "apollo", "Apollo" }, { "apollo", "Apollo" },
{ "brother", "Brother" }, { "brother", "Brother" },
{ "canon", "Canon" }, { "canon", "Canon" },
{ "citizen", "Citizen" },
{ "citoh", "Citoh" },
{ "compaq", "Compaq" },
{ "dec", "DEC" },
{ "dell", "Dell" }, { "dell", "Dell" },
{ "dnp", "DNP" },
{ "dymo", "Dymo" },
{ "epson", "Epson" }, { "epson", "Epson" },
{ "gelsprinter", "GelSprinter" }, { "fujifilm", "Fujifilm" },
{ "fujitsu", "Fujitsu" },
{ "gelsprinter", "Ricoh" },
{ "generic", "Generic" }, { "generic", "Generic" },
{ "genicom", "Genicom" },
{ "gestetner", "Gestetner" }, { "gestetner", "Gestetner" },
{ "hewlett packard", "Hewlett-Packard" }, { "hewlett packard", "Hewlett-Packard" },
{ "heidelberg", "Heidelberg" },
{ "hitachi", "Hitachi" },
{ "hp", "Hewlett-Packard" }, { "hp", "Hewlett-Packard" },
{ "ibm", "IBM" }, { "ibm", "IBM" },
{ "imagen", "Imagen" },
{ "imagistics", "Imagistics" }, { "imagistics", "Imagistics" },
{ "infoprint", "InfoPrint" }, { "infoprint", "InfoPrint" },
{ "infotec", "Infotec" }, { "infotec", "Infotec" },
{ "intellitech", "Intellitech" },
{ "kodak", "Kodak" },
{ "konica minolta", "Minolta" }, { "konica minolta", "Minolta" },
{ "kyocera", "Kyocera" }, { "kyocera", "Kyocera" },
{ "kyocera mita", "Kyocera" }, { "kyocera mita", "Kyocera" },
@ -3836,20 +3853,37 @@ static const struct {
{ "lexmark", "Lexmark" }, { "lexmark", "Lexmark" },
{ "minolta", "Minolta" }, { "minolta", "Minolta" },
{ "minolta qms", "Minolta" }, { "minolta qms", "Minolta" },
{ "mitsubishi", "Mitsubishi" },
{ "nec", "NEC" }, { "nec", "NEC" },
{ "nrg", "NRG" }, { "nrg", "NRG" },
{ "oce", "Oce" }, { "oce", "Oce" },
{ "oki", "Oki" }, { "oki", "Oki" },
{ "oki data corp", "Oki" }, { "oki data corp", "Oki" },
{ "olivetti", "Olivetti" },
{ "olympus", "Olympus" },
{ "panasonic", "Panasonic" }, { "panasonic", "Panasonic" },
{ "pcpi", "PCPI" },
{ "pentax", "Pentax" },
{ "qms", "QMS" },
{ "raven", "Raven" },
{ "raw", "Raw" },
{ "ricoh", "Ricoh" }, { "ricoh", "Ricoh" },
{ "samsung", "Samsung" }, { "samsung", "Samsung" },
{ "savin", "Savin" }, { "savin", "Savin" },
{ "seiko", "Seiko" },
{ "sharp", "Sharp" }, { "sharp", "Sharp" },
{ "shinko", "Shinko" },
{ "sipix", "SiPix" },
{ "sony", "Sony" }, { "sony", "Sony" },
{ "star", "Star" },
{ "tally", "Tally" },
{ "tektronix", "Tektronix" }, { "tektronix", "Tektronix" },
{ "texas instruments", "Texas Instruments" },
{ "toshiba", "Toshiba" },
{ "toshiba tec corp.", "Toshiba" }, { "toshiba tec corp.", "Toshiba" },
{ "xante", "Xante" },
{ "xerox", "Xerox" }, { "xerox", "Xerox" },
{ "zebra", "Zebra" },
}; };
static gpointer static gpointer
@ -3867,6 +3901,7 @@ get_all_ppds_func (gpointer user_data)
gchar *ppd_device_id; gchar *ppd_device_id;
gchar *ppd_name; gchar *ppd_name;
gchar *ppd_product; gchar *ppd_product;
gchar *ppd_make;
gchar *mfg; gchar *mfg;
gchar *mfg_normalized; gchar *mfg_normalized;
gchar *mdl; gchar *mdl;
@ -3883,7 +3918,7 @@ get_all_ppds_func (gpointer user_data)
* This hash contains names of manufacturers as keys and * This hash contains names of manufacturers as keys and
* values are GLists of PPD names. * values are GLists of PPD names.
*/ */
ppds_hash = g_hash_table_new (g_str_hash, g_str_equal); ppds_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
/* /*
* This hash contains all possible names of manufacturers as keys * This hash contains all possible names of manufacturers as keys
@ -3912,6 +3947,10 @@ get_all_ppds_func (gpointer user_data)
ppd_make_and_model = NULL; ppd_make_and_model = NULL;
ppd_name = NULL; ppd_name = NULL;
ppd_product = NULL; ppd_product = NULL;
ppd_make = NULL;
mfg = NULL;
mfg_normalized = NULL;
mdl = NULL;
while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
{ {
@ -3927,23 +3966,61 @@ get_all_ppds_func (gpointer user_data)
else if (g_strcmp0 (attr->name, "ppd-product") == 0 && else if (g_strcmp0 (attr->name, "ppd-product") == 0 &&
attr->value_tag == IPP_TAG_TEXT) attr->value_tag == IPP_TAG_TEXT)
ppd_product = attr->values[0].string.text; ppd_product = attr->values[0].string.text;
else if (g_strcmp0 (attr->name, "ppd-make") == 0 &&
attr->value_tag == IPP_TAG_TEXT)
ppd_make = attr->values[0].string.text;
attr = attr->next; attr = attr->next;
} }
if (ppd_make_and_model && ppd_name && ppd_product && ppd_device_id) /* Get manufacturer's name */
if (ppd_device_id && ppd_device_id[0] != '\0')
{ {
mfg = get_tag_value (ppd_device_id, "mfg"); mfg = get_tag_value (ppd_device_id, "mfg");
if (!mfg) if (!mfg)
mfg = get_tag_value (ppd_device_id, "manufacturer"); mfg = get_tag_value (ppd_device_id, "manufacturer");
mfg_normalized = normalize (mfg); mfg_normalized = normalize (mfg);
}
if (mfg_normalized) if (!mfg &&
ppd_make &&
ppd_make[0] != '\0')
{
mfg = g_strdup (ppd_make);
mfg_normalized = normalize (ppd_make);
}
/* Get model */
if (ppd_make_and_model &&
ppd_make_and_model[0] != '\0')
{
mdl = g_strdup (ppd_make_and_model);
}
if (!mdl &&
ppd_product &&
ppd_product[0] != '\0')
{
mdl = g_strdup (ppd_product);
}
if (!mdl &&
ppd_device_id &&
ppd_device_id[0] != '\0')
{
mdl = get_tag_value (ppd_device_id, "mdl");
if (!mdl)
mdl = get_tag_value (ppd_device_id, "model");
}
if (ppd_name && ppd_name[0] != '\0' &&
mdl && mdl[0] != '\0' &&
mfg && mfg[0] != '\0')
{ {
manufacturer_display_name = g_hash_table_lookup (manufacturers_hash, mfg_normalized); manufacturer_display_name = g_hash_table_lookup (manufacturers_hash, mfg_normalized);
if (!manufacturer_display_name) if (!manufacturer_display_name)
{ {
g_hash_table_insert (manufacturers_hash, mfg_normalized, mfg); g_hash_table_insert (manufacturers_hash, g_strdup (mfg_normalized), g_strdup (mfg));
} }
else else
{ {
@ -3953,35 +4030,7 @@ get_all_ppds_func (gpointer user_data)
item = g_new0 (PPDName, 1); item = g_new0 (PPDName, 1);
item->ppd_name = g_strdup (ppd_name); item->ppd_name = g_strdup (ppd_name);
item->ppd_display_name = g_strdup (mdl);
mdl = get_tag_value (ppd_device_id, "mdl");
if (!mdl)
mdl = get_tag_value (ppd_device_id, "model");
if (!item->ppd_display_name &&
ppd_make_and_model &&
ppd_make_and_model[0] != '\0')
{
item->ppd_display_name = g_strdup (ppd_make_and_model);
}
if (!item->ppd_display_name &&
ppd_product &&
ppd_product[0] != '\0')
{
item->ppd_display_name = g_strdup (ppd_product);
}
if (!item->ppd_display_name &&
mdl && mdl[0] != '\0')
{
item->ppd_display_name = mdl;
}
else
{
g_free (mdl);
}
item->ppd_match_level = -1; item->ppd_match_level = -1;
list = g_hash_table_lookup (ppds_hash, mfg_normalized); list = g_hash_table_lookup (ppds_hash, mfg_normalized);
@ -3992,11 +4041,14 @@ get_all_ppds_func (gpointer user_data)
else else
{ {
list = g_list_append (list, item); list = g_list_append (list, item);
g_hash_table_insert (ppds_hash, mfg_normalized, list); g_hash_table_insert (ppds_hash, g_strdup (mfg_normalized), list);
}
} }
} }
g_free (mdl);
g_free (mfg);
g_free (mfg_normalized);
if (attr == NULL) if (attr == NULL)
break; break;
} }