-#include <gio/gio.h>
-
-#include "src/interfaces/hostnamed/hostnamed-gen.c"
-
-GDBusNodeInfo *spect_data;
-
-/* handled by codegen
-static gchar *hostname;
-static gchar *pretty_hostname;
-static gchar *static_hostname;
-static gchar *icon_name;
-static gchar *chassis;
-static gchar *kernel_name;
-static gchar *kernel_release;
-static gchar *kernel_version;
-static gchar *os_prettyname;
-static gchar *os_cpe; //common platform enumeration string
-*/
-
-/* handled by codegen
-static void handle_method_call(GDBusConnection *conn,
- const gchar *sender,
- const gchar *obj_path,
- const gchar *interf_name,
- const gchar *method_name,
- GVariant *params,
- GDBusMethodInvocation *invc,
- gpointer usrdat) {
-
- if(g_strcmp0(interf_name, "org.freedesktop.DBus.Introspectable") == 0
- && g_strcmp0(method_name, "Introspect") == 0) {
-
- GVariant *xml_ret_gvar;
- GString *xml_ret;
-
- g_dbus_interface_info_generate_xml(spect_data->interfaces[0], (guint)0, xml_ret);
- xml_ret_gvar = g_variant_new_string(xml_ret->str);
- g_dbus_method_invocation_return_value(invc, xml_ret_gvar);
- }
+#include <signal.h>
+#include <string.h>
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/sensors.h>
+#include <sys/ioctl.h>
+
+#include <machine/apmvar.h>
+
+#include <glib/gprintf.h>
+#include <glib-unix.h>
+/* #include <gtk/gtk.h> */
+
+#include "hostnamed-gen.h"
+#include "hostnamed.h"
+
+/* add any sysctl strings that suggest virtualization here */
+/* format: {
+ * (1) string to be matched against runtime machine's sysctl output.
+ * can be either the exact string or a substring contained
+ * within sysctl strings. no "guesses" here, a match should
+ * reliably indicate the chassis/icon.
+ *
+ * (2) string describing chassis type divulged by (1).
+ * must be one of "desktop", "laptop", "server",
+ * "tablet", "handset", "vm", "container" or NULL
+ * if only icon string can be ascertained. "vm" refers
+ * to operating systems running on baremetal hypervisors
+ * (hardware virtualization, like XEN) while "container"
+ * refers to OSs running on shared hypervisors like
+ * virtualbox or VMware. consider the distinction carefully
+ * as common virtualization software like KVM may share
+ * characteristics of both "vm" and "container" types.
+ *
+ * (3) string specifying icon to use. follows XDG icon spec.
+ * see http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
+ * for allowed strings.
+ *
+ * (4) chassis precedence bit. TRUE if (2) is defined and
+ * we're certain it is the proper string. FALSE in the
+ * circumstance (2) may be the correct string, unless
+ * a match with this bit set to TRUE overrides it.
+ * if (2) is NULL, this bit is inconsequential.
+ *
+ * (5) icon precedence bit. see previous definition.
+ * } */
+struct SYSCTL_LOOKUP_TABLE {
+ gchar *match_string;
+ gchar *chassis;
+ gchar *icon;
+ gboolean chassis_precedence;
+ gboolean icon_precedence;
+};
+
+GPtrArray *hostnamed_freeable;
+Hostname1 *hostnamed_interf;
+
+GMainLoop *hostnamed_loop;
+
+guint bus_descriptor;
+gboolean dbus_interface_exported; /* reliable because of gdbus operational guarantees */
+
+gchar *CHASSIS, *ICON;
+
+/* TODO no specific vm or laptop icon in gnome
+ * NOTE paravirtualization on xen is only available for linuxes right now
+ * dmesg on linux systems reveals xen and virtualization method (HVM or PVM)
+ * but we will worry about those later */
+const struct SYSCTL_LOOKUP_TABLE chassis_indicator_table[] =
+{
+ { "QEMU Virtual CPU", "container", NULL, FALSE, FALSE }, /* could be QEMU running in userspace or as part of KVM */
+ { "KVM", "vm", "drive-multidisk", FALSE, FALSE },
+ { "SmartDC HVM", "vm", "drive-multidisk", TRUE, TRUE }, /* oracle solaris kvm */
+ { "VirtualBox", "container", "drive-optical", TRUE, TRUE },
+ { "VMware, Inc.", "container", "drive-optical", TRUE, TRUE },
+ { "VMware Virtual Platform", "container", "drive-optical", TRUE, TRUE },
+ { "Parallels", "container", "drive-optical", TRUE, TRUE } /* need verification */
+};
+
+/* archs to check against when determining if machine is server */
+const gchar *server_archs[] = {
+ "hppa",
+ "sparc",
+ "sparc64"
+};