static void
gss_program_init (GssProgram * program)
{
  guint8 uuid[16];

  program->metrics = gss_metrics_new ();

  program->enable_streaming = TRUE;

  program->state = DEFAULT_STATE;
  program->enabled = DEFAULT_ENABLED;
  gss_uuid_create (uuid);
  program->uuid = gss_uuid_to_string (uuid);
  program->description = g_strdup (DEFAULT_DESCRIPTION);
  program->safe_description = gss_html_sanitize_entity (program->description);

  gss_object_set_title (GSS_OBJECT (program), program->uuid);
  gss_object_set_name (GSS_OBJECT (program), program->uuid);
}
static void
gss_program_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GssProgram *program;

  program = GSS_PROGRAM (object);

  switch (prop_id) {
    case PROP_ENABLED:
      gss_program_set_enabled (program, g_value_get_boolean (value));
      break;
    case PROP_DESCRIPTION:
      g_free (program->description);
      program->description = g_value_dup_string (value);
      g_free (program->safe_description);
      program->safe_description =
          gss_html_sanitize_entity (program->description);
      break;
    default:
      g_assert_not_reached ();
      break;
  }
}
コード例 #3
0
static void
gss_config_get_resource (GssTransaction * t)
{
  GString *s = g_string_new ("");
  GList *g;

  t->s = s;

  gss_html_header (t);

  g_string_append (s, "<h1>Configuration</h1>\n");
  g_string_append (s, "<br>\n");

  /* FIXME do not work */
  gss_html_append_button (s, "Download", "download", "download");
  gss_html_append_button (s, "Upload", "upload", "upload");
  gss_html_append_button (s, "Reset", "reset", "reset");

  g_string_append (s, "<br>\n");
  g_string_append (s, "<table class='table table-striped table-bordered "
      "table-condensed'>\n");
  g_string_append (s, "<thead>\n");
  g_string_append (s, "<tr>\n");
  g_string_append (s, "<th>Parameter</th>\n");
  g_string_append (s, "<th>Value</th>\n");
  g_string_append (s, "</tr>\n");
  g_string_append (s, "</thead>\n");
  g_string_append (s, "<tbody>\n");

  for (g = config_list; g; g = g_list_next (g)) {
    GObject *object = g->data;
    GParamSpec **pspecs;
    int n_properties;
    int i;

    pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (object),
        (guint *) & n_properties);

    for (i = 0; i < n_properties; i++) {
      const GParamSpec *pspec = pspecs[i];
      char *value_string;
      char *safe;
      gboolean is_default;

      if (!(pspec->flags & G_PARAM_WRITABLE))
        continue;
      if (!(pspec->flags & G_PARAM_READABLE))
        continue;
      if (strcmp (pspec->name, "name") == 0)
        continue;

      is_default = g_object_property_is_default (object, pspec);

      g_string_append (s, "<tr>\n");
      g_string_append (s, "<td>\n");
      if (!is_default)
        g_string_append (s, "<b>");
      g_string_append_printf (s, "%s.%s\n", GST_OBJECT_NAME (object),
          pspec->name);
      g_string_append (s, "</td>\n");
      if (!is_default)
        g_string_append (s, "</b>");
      g_string_append (s, "<td>");
      if (!is_default)
        g_string_append (s, "<b>");
      g_string_append (s, "<pre class='pre-table'>");

      value_string = g_object_get_as_string (object, pspec);
      safe = gss_html_sanitize_entity (value_string);
      g_string_append (s, safe);
      g_free (safe);
      g_free (value_string);

      g_string_append (s, "</pre>");
      if (!is_default)
        g_string_append (s, "</b>");
      g_string_append (s, "</td>\n");
      g_string_append (s, "</tr>\n");
    }

    g_free (pspecs);
  }

  g_string_append (s, "</tbody>\n");
  g_string_append (s, "</table>\n");

  gss_html_footer (t);
}