Ejemplo n.º 1
0
/**
 * Calc software version's Integer value
 */
void calc_software_version(void) {
    char const *start_addr = NULL;
    char *match_addr = NULL;
    char c_value[4] = { 0 };
    uint8_t c_length = 0, i = 0;

    start_addr = get_software_version();
    match_addr = rt_strstr((char *) start_addr, ".");
    while (match_addr != NULL) {
        c_length = match_addr - start_addr;
        rt_memcpy(c_value, start_addr, c_length);
        software_version[i++] = atoi(c_value);
        match_addr++;
        start_addr = match_addr;
        match_addr = rt_strstr((char *) start_addr, ".");
    }
    c_length = rt_strlen(start_addr);
    rt_memcpy(c_value, start_addr, c_length);
    software_version[i] = atoi(c_value);
}
Ejemplo n.º 2
0
void
gis_page_util_show_factory_dialog (GisPage *page)
{
  g_autoptr(GtkBuilder) builder = NULL;
  GtkButton *poweroff_button;
  GtkButton *testmode_button;
  GtkDialog *factory_dialog;
  GtkImage *serial_image;
  GtkLabel *image_version_label;
  GtkLabel *sdcard_label;
  GtkLabel *serial_label;
  GtkLabel *product_id_label;
  GtkLabel *version_label;
  gboolean have_serial;
  gchar *barcode;
  gchar *barcode_serial, *display_serial;
  gchar *version;
  gchar *image_version;
  gchar *sd_version = NULL;
  gchar *image_version_text;
  gchar *sd_text;
  gchar *product_id_text;

  builder = get_modals_builder ();
  if (builder == NULL) {
    g_warning ("Can't get private builder object for factory mode!");
    return;
  }

  factory_dialog = (GtkDialog *)gtk_builder_get_object (builder, "factory-dialog");
  version_label = (GtkLabel *)gtk_builder_get_object (builder, "software-version");
  product_id_label = (GtkLabel *)gtk_builder_get_object (builder, "product-id");
  image_version_label = (GtkLabel *)gtk_builder_get_object (builder, "image-version");
  sdcard_label = (GtkLabel *)gtk_builder_get_object (builder, "sd-card");
  serial_label = (GtkLabel *)gtk_builder_get_object (builder, "serial-text");
  serial_image = (GtkImage *)gtk_builder_get_object (builder, "serial-barcode");
  poweroff_button = (GtkButton *)gtk_builder_get_object (builder, "poweroff-button");
  testmode_button = (GtkButton *)gtk_builder_get_object (builder, "testmode-button");

  version = get_software_version ();
  gtk_label_set_text (version_label, version);

  product_id_text = get_product_id ();
  if (product_id_text) {
    gtk_label_set_text (product_id_label, product_id_text);
    gtk_widget_set_visible (GTK_WIDGET (product_id_label), TRUE);
    g_free (product_id_text);
  }

  have_serial = get_serial_version (&display_serial, &barcode_serial);

  if (have_serial) {
    gtk_label_set_text (serial_label, display_serial);

    barcode = create_serial_barcode (barcode_serial);
    gtk_image_set_from_file (serial_image, barcode);
  } else {
    gtk_widget_set_visible (GTK_WIDGET (serial_label), FALSE);
    gtk_widget_set_visible (GTK_WIDGET (serial_image), FALSE);
  }

  image_version = gis_page_util_get_image_version (SYSROOT_MOUNT, NULL);
  if (!image_version)
    sd_version = g_strdup (_("Unknown"));

  image_version_text = g_strdup_printf (_("Image: %s"), image_version);
  gtk_label_set_text (image_version_label, image_version_text);
  g_free (image_version);
  g_free (image_version_text);

  if (get_have_sdcard ())
    sd_version = gis_page_util_get_image_version (SD_CARD_MOUNT, NULL);

  if (!sd_version)
    sd_version = g_strdup (_("Disabled"));

  sd_text = g_strdup_printf (_("SD Card: %s"), sd_version);
  gtk_label_set_text (sdcard_label, sd_text);
  g_free (sd_version);
  g_free (sd_text);

  g_signal_connect_swapped (poweroff_button, "clicked",
                            G_CALLBACK (system_poweroff), NULL);
  g_signal_connect (testmode_button, "clicked",
                    G_CALLBACK (system_testmode), factory_dialog);

  gtk_window_set_transient_for (GTK_WINDOW (factory_dialog),
                                GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page))));
  gtk_window_set_modal (GTK_WINDOW (factory_dialog), TRUE);
  gtk_window_present (GTK_WINDOW (factory_dialog));
  g_signal_connect (factory_dialog, "delete-event",
                    G_CALLBACK (gtk_widget_hide_on_delete), NULL);

  if (have_serial) {
    g_remove (barcode);
    g_free (barcode);
    g_free (barcode_serial);
    g_free (display_serial);
  }

  g_free (version);
}