/**
 * This function launches the escalation recovery procedure
 *
 * @param [in] h reset module handler
 *
 * @return E_ERR_SUCCESS if successful
 * @return E_ERR_FAILED otherwise
 */
e_mmgr_errors_t recov_start(reset_handle_t *h)
{
    e_mmgr_errors_t ret = E_ERR_SUCCESS;
    struct timeval current_time;
    int reboot_counter = 0;
    reset_management_t *reset = (reset_management_t *)h;

    ASSERT(reset != NULL);

    if (reset->op == E_FORCE_OOS) {
        reset->level.id = E_EL_MODEM_OUT_OF_SERVICE;
        reset->op = E_FORCE_NONE;
    } else {
        gettimeofday(&current_time, NULL);

        /* If there is more than xx seconds since the last reset, consider that
         * we were in a stable state before the issue. So, reset the escalation
         * recovery variable to default. */
        if (reset->level.id != E_EL_MODEM_OUT_OF_SERVICE) {
            if (current_time.tv_sec - reset->last_reset_time.tv_sec
                > reset->reset_delay) {
                /* The modem behavior was correct during at least
                 * min_time_issue, so we can reset the reboot counter */
                LOG_DEBUG("Last reset occurred at least %ds ago",
                          reset->reset_delay);
                recov_reinit(h);
                property_set_int(PLATFORM_REBOOT_KEY, reboot_counter);
            }
        }
    }

    reset->last_reset_time = current_time;
    return ret;
}
static void
gb_option_menu_on_option_selected (GtkWidget *menu,
				   GtkWidget *option_menu)
{
  GtkWidget *active_item;
  gint item_index;
  
  if (property_get_widget () != option_menu)
    return;

  active_item = gtk_menu_get_active (GTK_MENU (menu));
  item_index = g_list_index (GTK_MENU_SHELL (menu)->children, active_item);

  property_set_auto_apply (FALSE);
  property_set_int (Choice, item_index);
  property_set_auto_apply (TRUE);
}
/**
 * This function sets the current platform reboot performed
 *
 * @param [in] reboot current performed reboot
 */
void recov_set_reboot(int reboot)
{
    property_set_int(PLATFORM_REBOOT_KEY, reboot);
}
Exemple #4
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_image_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gfloat xalign, yalign;
  gint xpad, ypad, i, pixel_size;
  gboolean set_alignment = FALSE, set_padding = FALSE, apply_icon_size;
  GtkIconSize icon_size = GTK_ICON_SIZE_BUTTON;
  gchar *icon_size_string, *icon, *icon_name;

  icon_size = GTK_IMAGE (widget)->icon_size;

  if (data->action == GB_APPLYING)
    {
      icon_size_string = gb_widget_input_choice (data, IconSize);
      apply_icon_size = data->apply;
      if (data->apply)
	{
	  for (i = 0; i < GladeIconSizeChoicesSize; i++)
	    {
	      if (!strcmp (icon_size_string, GladeIconSizeChoices[i])
		  || !strcmp (icon_size_string, GladeIconSizeSymbols[i]))
		{
		  icon_size = GladeIconSizeValues[i];
		  break;
		}
	    }
	}
    }
  else
    {
      /* We have to save the size as an integer, which sucks a bit.
	 The integer is the GtkIconSize enum value, not the actual size.*/
      int new_size = gb_widget_input_int (data, IconSize);
      apply_icon_size = data->apply;
      if (data->apply)
	icon_size = new_size;
    }

  /* When loading we use different names. */
  if (data->action == GB_LOADING)
    {
      icon = gb_widget_input_icon (data, "stock");
      if (!data->apply)
	icon = gb_widget_input_icon (data, "pixbuf");
    }
  else
    {
      icon = gb_widget_input_icon (data, Icon);
    }

  if (data->apply)
    {
      gboolean is_stock_icon = glade_util_check_is_stock_id (icon);

      /* Remove the old icon stored in the widget data, and remove the
	 pixmap from the project, if necessary. */
      gb_image_clear_pixmap (widget, data->project);

      gtk_object_set_data_full (GTK_OBJECT (widget), GladeIconKey,
				g_strdup (icon), icon ? g_free : NULL);

      if (is_stock_icon)
	{
	  GtkIconSize new_icon_size;

	  new_icon_size = check_icon_size (icon, icon_size);

	  /* If we are showing this widget's properties, we need to update
	     the sizes option menu. */
	  if (property_get_widget () == widget)
	    {
	      /* We set it sensitive before changing the value, so the child
		 menu item is changed from insensitive to sensitive if needed.
		 Otherwise it may remain insensitive. */
	      property_set_sensitive (IconSize, TRUE);
	      property_set_sensitive (PixelSize, FALSE);

	      property_set_auto_apply (FALSE);

	      check_visible_sizes (icon, FALSE);

	      /* Check the icon size is valid for the stock item, and if not
		 pick the first valid size. */
	      for (i = 0; i < GladeIconSizeChoicesSize; i++)
		{
		  if (GladeIconSizeValues[i] == new_icon_size)
		    {
		      property_set_choice (IconSize, i);
		    }
		}

	      property_set_named_icon (IconName, NULL);

	      property_set_auto_apply (TRUE);
	    }

	  gtk_image_set_from_stock (GTK_IMAGE (widget), icon,
				    new_icon_size);
	}
      else
	{
	  /* If an icon filename is set, use that, otherwise use the icon
	     we use for the palette. */
	  if (icon)
	    {
	      gtk_image_set_from_file (GTK_IMAGE (widget), icon);
	      glade_project_add_pixmap (data->project, icon);
	    }
	  else
	    {
	      gtk_image_set_from_pixmap (GTK_IMAGE (widget),
					 gbwidget.gdkpixmap, gbwidget.mask);
	    }

	  if (property_get_widget () == widget)
	    {
	      /* The icon size isn't relevant to non-stock icons. */
	      property_set_sensitive (IconSize, FALSE);
	      property_set_sensitive (PixelSize, FALSE);

	      property_set_auto_apply (FALSE);
	      property_set_named_icon (IconName, NULL);
	      property_set_auto_apply (TRUE);
	    }
	}

      /* We've recreated the icon with the new size above, so we don't need
	 to apply the size again. */
      apply_icon_size = FALSE;
    }

  /* This is for the named/themed icon. */
  icon_name = gb_widget_input_named_icon (data, IconName);
  if (data->apply)
    {
      /* Clear any stock icon or icon from a file. */
      gb_image_clear_pixmap (widget, data->project);

      gtk_image_set_from_icon_name (GTK_IMAGE (widget), icon_name,
				    icon_size);

      if (property_get_widget () == widget)
	{
	  property_set_sensitive (IconSize, TRUE);
	  property_set_sensitive (PixelSize, TRUE);

	  /* Clear the Icon property. */
	  property_set_auto_apply (FALSE);
	  property_set_icon (Icon, NULL);
	  property_set_auto_apply (TRUE);
	}

      /* We've recreated the icon with the new size above, so we don't need
	 to apply the size again. */
      apply_icon_size = FALSE;
    }

  /* When we set the icon size, we reset the pixel size to -1, otherwise it
     overrides the icon size. */
  if (apply_icon_size)
    {
      gtk_image_set_pixel_size (GTK_IMAGE (widget), -1);
      g_object_set (widget, "icon_size", icon_size, NULL);

      if (property_get_widget () == widget)
	{
	  property_set_auto_apply (FALSE);
	  property_set_int (PixelSize, -1);
	  property_set_auto_apply (TRUE);
	}
    }

  /* GtkImage doesn't like a pixel size of 0 so we just skip that. */
  pixel_size = gb_widget_input_int (data, PixelSize);
  if (data->apply && pixel_size != 0)
    gtk_image_set_pixel_size (GTK_IMAGE (widget), pixel_size);

  xalign = gb_widget_input_float (data, XAlign);
  if (data->apply)
    set_alignment = TRUE;
  else
    xalign = GTK_MISC (widget)->xalign;

  yalign = gb_widget_input_float (data, YAlign);
  if (data->apply)
    set_alignment = TRUE;
  else
    yalign = GTK_MISC (widget)->yalign;

  if (set_alignment)
    gtk_misc_set_alignment (GTK_MISC (widget), xalign, yalign);

  xpad = gb_widget_input_int (data, XPad);
  if (data->apply)
    set_padding = TRUE;
  else
    xpad = GTK_MISC (widget)->xpad;

  ypad = gb_widget_input_int (data, YPad);
  if (data->apply)
    set_padding = TRUE;
  else
    ypad = GTK_MISC (widget)->ypad;

  if (set_padding)
    gtk_misc_set_padding (GTK_MISC (widget), xpad, ypad);
}