static void
infd_note_plugin_text_session_write_foreach_user_func(InfUser* user,
                                                      gpointer user_data)
{
  xmlNodePtr parent;
  xmlNodePtr node;

  parent = (xmlNodePtr)user_data;
  node = xmlNewChild(parent, NULL, (const xmlChar*)"user", NULL);

  inf_xml_util_set_attribute_uint(node, "id", inf_user_get_id(user));
  inf_xml_util_set_attribute(node, "name", inf_user_get_name(user));
  inf_xml_util_set_attribute_double(
    node,
    "hue",
    inf_text_user_get_hue(INF_TEXT_USER(user))
  );
}
/**
 * infd_acl_account_info_to_xml:
 * @info: A #InfdAclAccountInfo.
 * @xml: XML node to write the account information to.
 *
 * Serializes a #InfdAclAccountInfo object into an XML node. The account
 * information can be deserialized again with
 * infd_acl_account_info_from_xml().
 */
void
infd_acl_account_info_to_xml(const InfdAclAccountInfo* info,
                             xmlNodePtr xml)
{
  guint i;

  gnutls_datum_t datum;
  size_t out_size;
  gchar* out;
  int res;

  g_return_if_fail(info != NULL);
  g_return_if_fail(xml != NULL);

  inf_acl_account_to_xml(&info->account, xml);

  for(i = 0; i < info->n_certificates; ++i)
  {
    xmlNewChild(
      xml,
      NULL,
      (const xmlChar*)"certificate",
      (const xmlChar*)info->certificates[i]
    );
  }

  if(info->password_salt != NULL)
  {
    datum.data = info->password_salt;
    datum.size = 32;

    res = gnutls_hex_encode(&datum, NULL, &out_size);
    g_assert(res == GNUTLS_E_SHORT_MEMORY_BUFFER);

    out = g_malloc(out_size + 1);
    res = gnutls_hex_encode(&datum, out, &out_size);
    g_assert(res == GNUTLS_E_SUCCESS);

    out[out_size] = '\0';
    inf_xml_util_set_attribute(xml, "password-salt", out);
    g_free(out);
  }

  if(info->password_hash != NULL)
  {
    datum.data = info->password_hash;
    datum.size = gnutls_hash_get_len(GNUTLS_DIG_SHA256);

    res = gnutls_hex_encode(&datum, NULL, &out_size);
    g_assert(res == GNUTLS_E_SHORT_MEMORY_BUFFER);

    out = g_malloc(out_size + 1);
    res = gnutls_hex_encode(&datum, out, &out_size);
    g_assert(res == GNUTLS_E_SUCCESS);

    out[out_size] = '\0';
    inf_xml_util_set_attribute(xml, "password-hash", out);
    g_free(out);
  }

  if(info->first_seen != 0)
  {
    inf_xml_util_set_attribute_double(
      xml,
      "first-seen",
      info->first_seen / 1e6
    );
  }

  if(info->last_seen != 0)
  {
    inf_xml_util_set_attribute_double(
      xml,
      "last-seen",
      info->last_seen / 1e6
    );
  }
}