+/* archs to check against when determining if machine is server */
+const gchar *server_archs[] = {
+ "hppa",
+ "sparc",
+ "sparc64"
+};
+
+/* --- begin method/property/dbus signal code --- */
+
+/* TODO the extra boolean passed to these funcs is for policykit auth */
+/* TODO complete call with error, message, etc */
+static gboolean
+on_handle_set_hostname(Hostname1 *hn1_passed_interf,
+ GDBusMethodInvocation *invoc,
+ const gchar *greet,
+ gpointer data) {
+ GVariant *params;
+ gchar *proposed_hostname, *valid_hostname_buf;
+ gboolean policykit_auth, ret;
+ size_t check_length;
+
+ proposed_hostname = NULL;
+ ret = FALSE;
+
+ params = g_dbus_method_invocation_get_parameters(invoc);
+ g_variant_get(params, "(sb)", &proposed_hostname, &policykit_auth);
+
+ if(proposed_hostname && (valid_hostname_buf = g_hostname_to_ascii(proposed_hostname))) {
+
+ check_length = strnlen(proposed_hostname, MAXHOSTNAMELEN + 1);
+
+ if(check_length > MAXHOSTNAMELEN)
+ g_dbus_method_invocation_return_dbus_error(invoc, "org.freedesktop.hostname1.Error.ENAMETOOLONG", "Hostname string exceeded maximum length.");
+
+ else if(sethostname(proposed_hostname, check_length))
+ g_dbus_method_invocation_return_dbus_error(invoc, "org.freedesktop.hostname1.Error.EACCES", "Insufficient permissions to change hostname.");
+
+ else {
+ HOSTNAME = proposed_hostname;
+ hostname1_set_hostname(hn1_passed_interf, HOSTNAME);
+ ret = TRUE;
+ hostname1_complete_set_hostname(hn1_passed_interf, invoc);
+ }
+ }
+
+ if(proposed_hostname)
+ g_free(proposed_hostname);
+ if(valid_hostname_buf)
+ g_free(valid_hostname_buf);
+
+ return ret;
+}
+
+static gboolean
+on_handle_set_static_hostname(Hostname1 *hn1_passed_interf,
+ GDBusMethodInvocation *invoc,
+ const gchar *greet,
+ gpointer data) {
+ return FALSE;
+}
+
+static gboolean
+on_handle_set_pretty_hostname(Hostname1 *hn1_passed_interf,
+ GDBusMethodInvocation *invoc,
+ const gchar *greet,
+ gpointer data) {
+ return FALSE;
+}
+
+static gboolean
+on_handle_set_chassis(Hostname1 *hn1_passed_interf,
+ GDBusMethodInvocation *invoc,
+ const gchar *greet,
+ gpointer data) {
+ return FALSE;
+}
+
+static gboolean
+on_handle_set_icon_name(Hostname1 *hn1_passed_interf,
+ GDBusMethodInvocation *invoc,
+ const gchar *greet,
+ gpointer data) {
+ return FALSE;
+}
+
+/* note: all hostnamed/hostname1's properties are read-only,
+ * and do not need set_ functions, gdbus-codegen realized
+ * this from the XML and handled the to-be error of trying
+ * to set a read-only property's value
+ */
+
+const gchar *
+our_get_hostname() {
+
+ gchar *hostname_buf;
+ hostname_buf = (gchar *)g_malloc0(MAXHOSTNAMELEN);
+
+ if(gethostname(hostname_buf, MAXHOSTNAMELEN))
+ return "localhost.home.network"; /* TODO bomb out here probably */
+
+ else if(!g_strcmp0(HOSTNAME, hostname_buf)) {
+
+ g_free(hostname_buf);
+ return HOSTNAME;
+ }
+
+ g_ptr_array_add(hostnamed_freeable, hostname_buf);
+ HOSTNAME = hostname_buf;
+ hostname1_set_hostname(hostnamed_interf, HOSTNAME);
+
+ return HOSTNAME;
+}
+
+const gchar *
+our_get_static_hostname() {
+
+ if(STATIC_HOSTNAME && g_strcmp0(STATIC_HOSTNAME, ""))
+ return STATIC_HOSTNAME;
+ else if(HOSTNAME)
+ return HOSTNAME;
+
+ return "localhost.home.network";
+}
+
+const gchar *
+our_get_pretty_hostname() {
+
+ if(PRETTY_HOSTNAME)
+ return PRETTY_HOSTNAME;
+
+ return "";
+}
+
+const gchar *
+our_get_chassis() {
+
+ if(CHASSIS)
+ return CHASSIS;
+
+ return "desktop"; /* this leads to the most generic beheivor in the unlikely case its returned */
+}
+
+const gchar *
+our_get_icon_name() {
+
+ if(ICON)
+ return ICON;
+
+ return "";
+}
+
+const gchar *
+our_get_kernel_name() {
+
+ if(KERN_NAME)
+ return KERN_NAME;
+
+ return "";
+}
+
+const gchar *
+our_get_kernel_version() {
+
+ if(KERN_VERS)
+ return KERN_VERS;
+
+ return "";
+}
+
+const gchar *
+our_get_kernel_release() {
+
+ if(KERN_RELEASE)
+ return KERN_RELEASE;
+
+ return "";
+}
+
+const gchar *
+our_get_os_cpename() {
+
+ return "ONEDAY";
+}
+
+const gchar *
+our_get_os_pretty_name() {
+
+ return "OpenBSD";
+}
+
+/* --- end method/property/dbus signal code, begin bus/name handlers --- */
+
+static void hostnamed_on_bus_acquired(GDBusConnection *conn,