aboutsummaryrefslogtreecommitdiff
path: root/vendor.c
diff options
context:
space:
mode:
Diffstat (limited to 'vendor.c')
-rw-r--r--vendor.c144
1 files changed, 117 insertions, 27 deletions
diff --git a/vendor.c b/vendor.c
index f75e4e38..0897341a 100644
--- a/vendor.c
+++ b/vendor.c
@@ -1,6 +1,6 @@
/*
* HardInfo - Displays System Information
- * Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>
+ * Copyright (C) 2003-2009 Leandro A. F. Pereira <leandro@hardinfo.org>
*
* List of vendors based on GtkSysInfo (c) Pissens Sebastien.
*
@@ -20,13 +20,17 @@
#include <string.h>
#include <gtk/gtk.h>
+
#include "vendor.h"
+#include "syncmanager.h"
+#include "config.h"
+#include "hardinfo.h"
static const Vendor vendors[] = {
- {"ATI", "ATI Technologies, Inc.", "www.ati.com"},
- {"nVidia", "NVIDIA Corporation", "www.nvidia.com"},
+ {"ATI", "ATI Technologies", "www.ati.com"},
+ {"nVidia", "NVIDIA", "www.nvidia.com"},
{"3Com", "3Com", "www.3com.com"},
- {"Intel", "Intel Corp.", "www.intel.com"},
+ {"Intel", "Intel", "www.intel.com"},
{"Cirrus Logic", "Cirrus Logic", "www.cirrus.com"},
{"VIA Technologies", "VIA Technologies", "www.via.com.tw"},
{"VIA", "VIA Technologies", "www.via.com.tw"},
@@ -48,20 +52,21 @@ static const Vendor vendors[] = {
{"Brooktree", "Conexant", "www.brooktree.com"},
{"Atheros", "Atheros Communications", "www.atheros.com"},
{"MATSHITA", "Panasonic", "www.panasonic.com"},
- {"Silicon Image", "Silicon Image, Inc.", "www.siliconimage.com"},
- {"Silicon Integrated Image", "Silicon Image, Inc.", "www.siliconimage.com"},
- {"KYE", "KYE Systems Corp.", "www.genius-kye.com"},
- {"Broadcom", "Broadcom Corp.", "www.broadcom.com"},
- {"Apple", "Apple Computer, Inc.", "www.apple.com"},
- {"IBM", "IBM Corp.", "www.ibm.com"},
- {"Dell", "Dell Computer Corp.", "www.dell.com"},
- {"Logitech", "Logitech International SA", "www.logitech.com"},
+ {"Silicon Image", "Silicon Image", "www.siliconimage.com"},
+ {"Silicon Integrated Image", "Silicon Image", "www.siliconimage.com"},
+ {"KYE", "KYE Systems", "www.genius-kye.com"},
+ {"Broadcom", "Broadcom", "www.broadcom.com"},
+ {"Apple", "Apple", "www.apple.com"},
+ {"IBM", "IBM", "www.ibm.com"},
+ {"Dell", "Dell Computer", "www.dell.com"},
+ {"Logitech", "Logitech International", "www.logitech.com"},
{"FUJITSU", "Fujitsu", "www.fujitsu.com"},
{"CDU", "Sony", "www.sony.com"},
{"SanDisk", "SanDisk", "www.sandisk.com"},
{"ExcelStor", "ExcelStor Technology", "www.excelstor.com"},
{"D-Link", "D-Link", "www.dlink.com.tw"},
- {"Giga-byte", "Gigabyte", "www.gigabyte.com.tw"},
+ {"Giga-byte", "Gigabyte Technology", "www.gigabyte.com.tw"},
+ {"Gigabyte", "Gigabyte Technology", "www.gigabyte.com.tw"},
{"C-Media", "C-Media Electronics", "www.cmedia.com.tw"},
{"Avermedia", "AVerMedia Technologies", "www.aver.com"},
{"Philips", "Philips", "www.philips.com"},
@@ -69,22 +74,99 @@ static const Vendor vendors[] = {
{"Siemens", "Siemens AG", "www.siemens.com"},
{"HP", "Hewlett-Packard", "www.hp.com"},
{"Hewlett-Packard", "Hewlett-Packard", "www.hp.com"},
- {"TEAC", "TEAC America Inc.", "www.teac.com"},
- {"Microsoft", "Microsoft Corp.", "www.microsoft.com"},
- {"Memorex", "Memorex Products, Inc.", "www.memorex.com"},
- {"eMPIA", "eMPIA Technology, Inc.", "www.empiatech.com.tw"},
- {"Canon", "Canon Inc.", "www.canon.com"},
- {"A4Tech", "A4tech Co., Ltd.", "www.a4tech.com"},
- {NULL, NULL, NULL},
+ {"TEAC", "TEAC America", "www.teac.com"},
+ {"Microsoft", "Microsoft", "www.microsoft.com"},
+ {"Memorex", "Memorex Products", "www.memorex.com"},
+ {"eMPIA", "eMPIA Technology", "www.empiatech.com.tw"},
+ {"Canon", "Canon", "www.canon.com"},
+ {"A4Tech", "A4tech", "www.a4tech.com"},
+ {"ALCOR", "Alcor", "www.alcor.org"},
+ {"Vimicro", "Vimicro", "www.vimicro.com"},
+ {"OTi", "Ours Technology", "www.oti.com.tw"},
+ {"BENQ", "BenQ", "www.benq.com"},
+ {"Acer", "Acer", "www.acer.com"},
+ /* BIOS manufacturers */
+ {"American Megatrends", "American Megatrends", "www.ami.com"},
+ {"Award", "Award Software International", "www.award-bios.com"},
+ {"Phoenix", "Phoenix Technologies", "www.phoenix.com"},
};
+static GSList *vendor_list = NULL;
+
+void vendor_init(void)
+{
+ gint i;
+ gchar *path;
+ static SyncEntry se = {
+ .fancy_name = "Update vendor list",
+ .name = "RecvVendorList",
+ .save_to = "vendor.conf",
+ .get_data = NULL
+ };
+
+ DEBUG("initializing vendor list");
+ sync_manager_add_entry(&se);
+
+ path = g_build_filename(g_get_home_dir(), ".hardinfo", "vendor.conf", NULL);
+ if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
+ DEBUG("local vendor.conf not found, trying system-wise");
+ g_free(path);
+ path = g_build_filename(params.path_data, "vendor.conf", NULL);
+ }
+
+ if (g_file_test(path, G_FILE_TEST_EXISTS)) {
+ GKeyFile *vendors;
+ gchar *tmp;
+ gint num_vendors;
+
+ DEBUG("loading %s", path);
+
+ vendors = g_key_file_new();
+ if (g_key_file_load_from_file(vendors, path, 0, NULL)) {
+ num_vendors = g_key_file_get_integer(vendors, "vendors", "number", NULL);
+
+ for (i = num_vendors - 1; i >= 0; i--) {
+ Vendor *v = g_new0(Vendor, 1);
+
+ tmp = g_strdup_printf("vendor%d", i);
+
+ v->id = g_key_file_get_string(vendors, tmp, "id", NULL);
+ v->name = g_key_file_get_string(vendors, tmp, "name", NULL);
+ v->url = g_key_file_get_string(vendors, tmp, "url", NULL);
+
+ vendor_list = g_slist_prepend(vendor_list, v);
+
+ g_free(tmp);
+ }
+ }
+
+ g_key_file_free(vendors);
+ } else {
+ DEBUG("system-wise vendor.conf not found, using internal database");
+
+ for (i = G_N_ELEMENTS(vendors) - 1; i >= 0; i--) {
+ vendor_list = g_slist_prepend(vendor_list, (gpointer) &vendors[i]);
+ }
+ }
+
+ g_free(path);
+}
+
const gchar *vendor_get_name(const gchar * id)
{
+ GSList *vendor;
int i;
-
- for (i = 0; vendors[i].id; i++) {
- if (strstr(id, vendors[i].id))
- return vendors[i].name;
+
+ if (!id) {
+ return NULL;
+ }
+
+ for (vendor = vendor_list; vendor; vendor = vendor->next) {
+ Vendor *v = (Vendor *)vendor->data;
+
+ if (v && v->id && strstr(id, v->id)) {
+ return g_strdup(v->name);
+ }
}
return id;
@@ -92,11 +174,19 @@ const gchar *vendor_get_name(const gchar * id)
const gchar *vendor_get_url(const gchar * id)
{
+ GSList *vendor;
int i;
- for (i = 0; vendors[i].id; i++) {
- if (strstr(id, vendors[i].id))
- return vendors[i].url;
+ if (!id) {
+ return NULL;
+ }
+
+ for (vendor = vendor_list; vendor; vendor = vendor->next) {
+ Vendor *v = (Vendor *)vendor->data;
+
+ if (v && v->id && strstr(id, v->id)) {
+ return g_strdup(v->url);
+ }
}
return NULL;