Blob: dbus-common.c
Blob id: 5e2c83d52628b077116e366ba43a19b4edfc5266
Size: 2.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | // SPDX-License-Identifier: GPL-2.0-or-later /* * * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2006-2010 Nokia Corporation * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> * Copyright (C) 2005-2007 Johan Hedberg <johan.hedberg@nokia.com> * * */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <stdint.h> #include <glib.h> #include <dbus/dbus.h> #include "gdbus/gdbus.h" #include "log.h" #include "dbus-common.h" static DBusConnection *connection = NULL; void dict_append_entry(DBusMessageIter *dict, const char *key, int type, void *val) { g_dbus_dict_append_entry(dict, key, type, val); } void dict_append_array(DBusMessageIter *dict, const char *key, int type, void *val, int n_elements) { g_dbus_dict_append_array(dict, key, type, val, n_elements); } void set_dbus_connection(DBusConnection *conn) { connection = conn; } DBusConnection *btd_get_dbus_connection(void) { return connection; } const char *class_to_icon(uint32_t class) { switch ((class & 0x1f00) >> 8) { case 0x01: return "computer"; case 0x02: switch ((class & 0xfc) >> 2) { case 0x01: case 0x02: case 0x03: case 0x05: return "phone"; case 0x04: return "modem"; } break; case 0x03: return "network-wireless"; case 0x04: switch ((class & 0xfc) >> 2) { case 0x01: case 0x02: return "audio-headset"; case 0x06: return "audio-headphones"; case 0x0b: /* VCR */ case 0x0c: /* Video Camera */ case 0x0d: /* Camcorder */ return "camera-video"; default: return "audio-card"; /* Other audio device */ } break; case 0x05: switch ((class & 0xc0) >> 6) { case 0x00: switch ((class & 0x1e) >> 2) { case 0x01: case 0x02: return "input-gaming"; } break; case 0x01: return "input-keyboard"; case 0x02: switch ((class & 0x1e) >> 2) { case 0x05: return "input-tablet"; default: return "input-mouse"; } } break; case 0x06: if (class & 0x80) return "printer"; if (class & 0x20) return "camera-photo"; break; } return NULL; } const char *gap_appearance_to_icon(uint16_t appearance) { switch ((appearance & 0xffc0) >> 6) { case 0x00: return "unknown"; case 0x01: return "phone"; case 0x02: return "computer"; case 0x05: return "video-display"; case 0x0a: return "multimedia-player"; case 0x0b: return "scanner"; case 0x0f: /* HID Generic */ switch (appearance & 0x3f) { case 0x01: return "input-keyboard"; case 0x02: return "input-mouse"; case 0x03: case 0x04: return "input-gaming"; case 0x05: return "input-tablet"; case 0x08: return "scanner"; } break; } return NULL; } |