~ubuntu-branches/ubuntu/trusty/hardinfo/trusty-proposed

« back to all changes in this revision

Viewing changes to vendor.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-11-06 14:14:17 UTC
  • mfrom: (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091106141417-fnpdc0ya7ac8bmsx
Tags: 0.5.1-1ubuntu1
* Merge from debian testing:
  - debian/rules: Don't install anything in /usr/local, otherwise FTBFS.
* debian/control: Add homepage field.
* Add quilt patch system support.
* Add 01-truncated_description.patch to fix LP: #357189 (at least
  partially).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *    HardInfo - Displays System Information
3
 
 *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>
 
3
 *    Copyright (C) 2003-2009 Leandro A. F. Pereira <leandro@hardinfo.org>
4
4
 *
5
5
 *    List of vendors based on GtkSysInfo (c) Pissens Sebastien.
6
6
 *
20
20
 
21
21
#include <string.h>
22
22
#include <gtk/gtk.h>
 
23
 
23
24
#include "vendor.h"
 
25
#include "syncmanager.h"
 
26
#include "config.h"
 
27
#include "hardinfo.h"
24
28
 
25
29
static const Vendor vendors[] = {
26
 
    {"ATI", "ATI Technologies, Inc.", "www.ati.com"},
27
 
    {"nVidia", "NVIDIA Corporation", "www.nvidia.com"},
 
30
    {"ATI", "ATI Technologies", "www.ati.com"},
 
31
    {"nVidia", "NVIDIA", "www.nvidia.com"},
28
32
    {"3Com", "3Com", "www.3com.com"},
29
 
    {"Intel", "Intel Corp.", "www.intel.com"},
 
33
    {"Intel", "Intel", "www.intel.com"},
30
34
    {"Cirrus Logic", "Cirrus Logic", "www.cirrus.com"},
31
35
    {"VIA Technologies", "VIA Technologies", "www.via.com.tw"},
32
36
    {"VIA", "VIA Technologies", "www.via.com.tw"},
48
52
    {"Brooktree", "Conexant", "www.brooktree.com"},
49
53
    {"Atheros", "Atheros Communications", "www.atheros.com"},
50
54
    {"MATSHITA", "Panasonic", "www.panasonic.com"},
51
 
    {"Silicon Image", "Silicon Image, Inc.", "www.siliconimage.com"},
52
 
    {"Silicon Integrated Image", "Silicon Image, Inc.", "www.siliconimage.com"},
53
 
    {"KYE", "KYE Systems Corp.", "www.genius-kye.com"},
54
 
    {"Broadcom", "Broadcom Corp.", "www.broadcom.com"},
55
 
    {"Apple", "Apple Computer, Inc.", "www.apple.com"},
56
 
    {"IBM", "IBM Corp.", "www.ibm.com"},
57
 
    {"Dell", "Dell Computer Corp.", "www.dell.com"},
58
 
    {"Logitech", "Logitech International SA", "www.logitech.com"},
 
55
    {"Silicon Image", "Silicon Image", "www.siliconimage.com"},
 
56
    {"Silicon Integrated Image", "Silicon Image", "www.siliconimage.com"},
 
57
    {"KYE", "KYE Systems", "www.genius-kye.com"},
 
58
    {"Broadcom", "Broadcom", "www.broadcom.com"},
 
59
    {"Apple", "Apple", "www.apple.com"},
 
60
    {"IBM", "IBM", "www.ibm.com"},
 
61
    {"Dell", "Dell Computer", "www.dell.com"},
 
62
    {"Logitech", "Logitech International", "www.logitech.com"},
59
63
    {"FUJITSU", "Fujitsu", "www.fujitsu.com"},
60
64
    {"CDU", "Sony", "www.sony.com"},
61
65
    {"SanDisk", "SanDisk", "www.sandisk.com"},
62
66
    {"ExcelStor", "ExcelStor Technology", "www.excelstor.com"},
63
67
    {"D-Link", "D-Link", "www.dlink.com.tw"},
64
 
    {"Giga-byte", "Gigabyte", "www.gigabyte.com.tw"},
 
68
    {"Giga-byte", "Gigabyte Technology", "www.gigabyte.com.tw"},
 
69
    {"Gigabyte", "Gigabyte Technology", "www.gigabyte.com.tw"},
65
70
    {"C-Media", "C-Media Electronics", "www.cmedia.com.tw"},
66
71
    {"Avermedia", "AVerMedia Technologies", "www.aver.com"},
67
72
    {"Philips", "Philips", "www.philips.com"},
69
74
    {"Siemens", "Siemens AG", "www.siemens.com"},
70
75
    {"HP", "Hewlett-Packard", "www.hp.com"},
71
76
    {"Hewlett-Packard", "Hewlett-Packard", "www.hp.com"},
72
 
    {"TEAC", "TEAC America Inc.", "www.teac.com"},
73
 
    {"Microsoft", "Microsoft Corp.", "www.microsoft.com"},
74
 
    {"Memorex", "Memorex Products, Inc.", "www.memorex.com"},
75
 
    {"eMPIA", "eMPIA Technology, Inc.", "www.empiatech.com.tw"},
76
 
    {"Canon", "Canon Inc.", "www.canon.com"},
77
 
    {"A4Tech", "A4tech Co., Ltd.", "www.a4tech.com"},
78
 
    {NULL, NULL, NULL},
 
77
    {"TEAC", "TEAC America", "www.teac.com"},
 
78
    {"Microsoft", "Microsoft", "www.microsoft.com"},
 
79
    {"Memorex", "Memorex Products", "www.memorex.com"},
 
80
    {"eMPIA", "eMPIA Technology", "www.empiatech.com.tw"},
 
81
    {"Canon", "Canon", "www.canon.com"},
 
82
    {"A4Tech", "A4tech", "www.a4tech.com"},
 
83
    {"ALCOR", "Alcor", "www.alcor.org"},
 
84
    {"Vimicro", "Vimicro", "www.vimicro.com"},
 
85
    {"OTi", "Ours Technology", "www.oti.com.tw"},
 
86
    {"BENQ", "BenQ", "www.benq.com"},
 
87
    {"Acer", "Acer", "www.acer.com"},
 
88
    /* BIOS manufacturers */
 
89
    {"American Megatrends", "American Megatrends", "www.ami.com"},
 
90
    {"Award", "Award Software International", "www.award-bios.com"},
 
91
    {"Phoenix", "Phoenix Technologies", "www.phoenix.com"},
79
92
};
80
93
 
 
94
static GSList *vendor_list = NULL;
 
95
 
 
96
void vendor_init(void)
 
97
{
 
98
    gint i;
 
99
    gchar *path;
 
100
    static SyncEntry se = {
 
101
       .fancy_name = "Update vendor list",
 
102
       .name = "RecvVendorList",
 
103
       .save_to = "vendor.conf",
 
104
       .get_data = NULL
 
105
    };
 
106
 
 
107
    DEBUG("initializing vendor list");
 
108
    sync_manager_add_entry(&se);
 
109
    
 
110
    path = g_build_filename(g_get_home_dir(), ".hardinfo", "vendor.conf", NULL);
 
111
    if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
 
112
      DEBUG("local vendor.conf not found, trying system-wise");
 
113
      g_free(path);
 
114
      path = g_build_filename(params.path_data, "vendor.conf", NULL);
 
115
    }
 
116
    
 
117
    if (g_file_test(path, G_FILE_TEST_EXISTS)) {
 
118
      GKeyFile *vendors;
 
119
      gchar *tmp;
 
120
      gint num_vendors;
 
121
      
 
122
      DEBUG("loading %s", path);
 
123
      
 
124
      vendors = g_key_file_new();
 
125
      if (g_key_file_load_from_file(vendors, path, 0, NULL)) {
 
126
        num_vendors = g_key_file_get_integer(vendors, "vendors", "number", NULL);
 
127
        
 
128
        for (i = num_vendors - 1; i >= 0; i--) {
 
129
          Vendor *v = g_new0(Vendor, 1);
 
130
          
 
131
          tmp = g_strdup_printf("vendor%d", i);
 
132
          
 
133
          v->id   = g_key_file_get_string(vendors, tmp, "id", NULL);
 
134
          v->name = g_key_file_get_string(vendors, tmp, "name", NULL);
 
135
          v->url  = g_key_file_get_string(vendors, tmp, "url", NULL);
 
136
          
 
137
          vendor_list = g_slist_prepend(vendor_list, v);
 
138
          
 
139
          g_free(tmp);
 
140
        }
 
141
      }
 
142
      
 
143
      g_key_file_free(vendors);
 
144
    } else {
 
145
      DEBUG("system-wise vendor.conf not found, using internal database");
 
146
      
 
147
      for (i = G_N_ELEMENTS(vendors) - 1; i >= 0; i--) {
 
148
        vendor_list = g_slist_prepend(vendor_list, (gpointer) &vendors[i]);
 
149
      }
 
150
    } 
 
151
 
 
152
    g_free(path);
 
153
}
 
154
 
81
155
const gchar *vendor_get_name(const gchar * id)
82
156
{
 
157
    GSList *vendor;
83
158
    int i;
84
 
 
85
 
    for (i = 0; vendors[i].id; i++) {
86
 
        if (strstr(id, vendors[i].id))
87
 
            return vendors[i].name;
 
159
    
 
160
    if (!id) {
 
161
      return NULL;
 
162
    }
 
163
    
 
164
    for (vendor = vendor_list; vendor; vendor = vendor->next) {
 
165
      Vendor *v = (Vendor *)vendor->data;
 
166
      
 
167
      if (v && v->id && strstr(id, v->id)) {
 
168
        return g_strdup(v->name);
 
169
      }
88
170
    }
89
171
 
90
172
    return id;
92
174
 
93
175
const gchar *vendor_get_url(const gchar * id)
94
176
{
 
177
    GSList *vendor;
95
178
    int i;
96
179
 
97
 
    for (i = 0; vendors[i].id; i++) {
98
 
        if (strstr(id, vendors[i].id))
99
 
            return vendors[i].url;
 
180
    if (!id) {
 
181
      return NULL;
 
182
    }
 
183
    
 
184
    for (vendor = vendor_list; vendor; vendor = vendor->next) {
 
185
      Vendor *v = (Vendor *)vendor->data;
 
186
      
 
187
      if (v && v->id && strstr(id, v->id)) {
 
188
        return g_strdup(v->url);
 
189
      }
100
190
    }
101
191
 
102
192
    return NULL;