usb_moded 0.86.0+mer64
usb_moded-ssu.c
Go to the documentation of this file.
1
23
24#include "usb_moded-ssu.h"
25
26#include "usb_moded-log.h"
27
28#include <ssusysinfo.h>
29
30/* ========================================================================= *
31 * Prototypes
32 * ========================================================================= */
33
34/* ------------------------------------------------------------------------- *
35 * SSU
36 * ------------------------------------------------------------------------- */
37
38static void ssu_free_handle (void);
39static ssusysinfo_t *ssu_get_handle (void);
40gchar *ssu_get_manufacturer_name(void);
41gchar *ssu_get_product_name (void);
42
43/* ========================================================================= *
44 * Data
45 * ========================================================================= */
46
48static ssusysinfo_t *ssu_instance = 0;
49
51static gboolean ssu_intialized = FALSE;
52
53/* ========================================================================= *
54 * Functions
55 * ========================================================================= */
56
58static void ssu_free_handle(void)
59{
60 LOG_REGISTER_CONTEXT;
61
62 /* Make sure instance does not get created on exit path */
63 ssu_intialized = TRUE;
64
65 /* Release existing instance */
66 ssusysinfo_delete(ssu_instance),
67 ssu_instance = 0;
68}
69
74static ssusysinfo_t *ssu_get_handle(void)
75{
76 LOG_REGISTER_CONTEXT;
77
78 /* Attempt only once */
79 if( !ssu_intialized ) {
80 ssu_intialized = TRUE;
81 ssu_instance = ssusysinfo_create();
82 atexit(ssu_free_handle);
83 }
84 return ssu_instance;
85}
86
93gchar *
95{
96 LOG_REGISTER_CONTEXT;
97
98 gchar *res = 0;
99 const char *val = ssusysinfo_device_manufacturer(ssu_get_handle());
100 if( val && strcmp(val, "UNKNOWN") )
101 res = g_strdup(val);
102 log_debug("%s() -> %s", __FUNCTION__, res ?: "N/A");
103 return res;
104}
105
112gchar *
114{
115 LOG_REGISTER_CONTEXT;
116
117 gchar *res = 0;
118 const char *val = ssusysinfo_device_pretty_name(ssu_get_handle());
119 if( val && strcmp(val, "UNKNOWN") )
120 res = g_strdup(val);
121 log_debug("%s() -> %s", __FUNCTION__, res ?: "N/A");
122 return res;
123}
gchar * ssu_get_manufacturer_name(void)
gchar * ssu_get_product_name(void)