}
-
-
-
-
static void
update_device_name_from_msg (DBusMessage *message)
{
dbus_error_init (&error);
if (dbus_set_error_from_message (&error, message)) {
- g_printerr ("modest: failed to get bt name: %s\n", error.message);
+ g_printerr ("modest: failed to get bluetooth name: %s\n", error.message);
dbus_error_free (&error);
- modest_conf_set_string (modest_runtime_get_conf(),
- MODEST_CONF_DEVICE_NAME,
- MODEST_LOCAL_FOLDERS_DEFAULT_DISPLAY_NAME,
- NULL);
} else {
const gchar *device_name;
if (!dbus_message_iter_init (message, &iter)) {
g_printerr ("modest: message did not have argument\n");
return;
}
-
dbus_message_iter_get_basic (&iter, &device_name);
g_warning ("update device name: %s", device_name);
modest_conf_set_string (modest_runtime_get_conf(),
static void init_debug_g_type (void);
static void init_debug_logging (void);
static void init_default_settings (ModestConf *conf);
+static void init_device_name (ModestConf *conf);
/*
* defaults for the column headers
return FALSE;
}
+
+ /* do an initial guess for the device name */
+ init_device_name (modest_runtime_get_conf());
+
if (!modest_platform_init()) {
modest_init_uninit ();
g_printerr ("modest: failed to run platform-specific initialization\n");
modest_conf_set_bool (conf, MODEST_CONF_CONNECT_AT_STARTUP, TRUE, NULL);
}
+
+
+/* set the device name -- note this is an initial guess from /etc/hostname
+ * on maemo-device it will most probably be replaced with the Bluetooth device
+ * name later during starting (see maemo/modest-maemo-utils.[ch])
+ */
+static void
+init_device_name (ModestConf *conf)
+{
+ int len = 255; /* max len */
+ gchar *devname = NULL;
+
+ if (!g_file_get_contents("/etc/hostname", &devname, &len, NULL) || len < 2 || len > 254) {
+ g_printerr ("modest: failed to read hostname\n");
+ modest_conf_set_string (conf, MODEST_CONF_DEVICE_NAME,
+ MODEST_LOCAL_FOLDERS_DEFAULT_DISPLAY_NAME,
+ NULL);
+ } else {
+ /* remove the \n at the end */
+ if (devname[len-1] == '\n')
+ devname[len-1] = '\0';
+ else
+ devname[len] = '\0';
+
+ modest_conf_set_string (conf, MODEST_CONF_DEVICE_NAME,devname, NULL);
+ }
+
+ g_free (devname);
+}