Exemplo n.º 1
0
gboolean
prefs_store_ext_multiple(const char * module, GHashTable * pref_values)
{
  gboolean pref_changed = FALSE;
  GList * keys = NULL;

  if ( ! prefs_is_registered_protocol(module))
    return pref_changed;

  keys = g_hash_table_get_keys(pref_values);
  if ( ! keys )
    return pref_changed;

  while ( keys != NULL )
  {
    gchar * pref_name = (gchar *)keys->data;
    gchar * pref_value = (gchar *) g_hash_table_lookup(pref_values, keys->data);

    if ( pref_name && pref_value )
    {
      if ( prefs_store_ext_helper(module, pref_name, pref_value) )
        pref_changed = TRUE;
    }
    keys = g_list_next(keys);
  }

  if ( pref_changed )
  {
    prefs_main_write();
    prefs_apply_all();
    prefs_to_capture_opts();
  }

  return TRUE;
}
Exemplo n.º 2
0
static gboolean
prefs_store_ext_helper(const char * module_name, const char *pref_name, const char *pref_value)
{
  module_t * module = NULL;
  pref_t * pref = NULL;
  gboolean pref_changed = TRUE;

  if ( ! prefs_is_registered_protocol(module_name))
    return FALSE;

  module = prefs_find_module(module_name);
  if ( ! module )
    return FALSE;

  pref = prefs_find_preference(module, pref_name);

  if (!pref)
    return FALSE;

  if ( pref->type == PREF_STRING )
  {
    g_free((void *)pref->stashed_val.string);
    pref->stashed_val.string = (gchar *) g_strdup(pref_value);
    /* unstash - taken from preferences_util */
    if (strcmp(*pref->varp.string, pref->stashed_val.string) != 0)
    {
      pref_changed = TRUE;
      g_free(*pref->varp.string);
      *pref->varp.string = g_strdup(pref->stashed_val.string);
    }
  }

  return pref_changed;
}
void ProtocolPreferencesMenu::setModule(const char *module_name)
{
    QAction *action;
    int proto_id = -1;

    if (module_name) {
        proto_id = proto_get_id_by_filter_name(module_name);
    }

    clear();
    module_name_.clear();
    module_ = NULL;

    protocol_ = find_protocol_by_id(proto_id);
    const QString long_name = proto_get_protocol_long_name(protocol_);
    const QString short_name = proto_get_protocol_short_name(protocol_);
    if (!module_name || proto_id < 0 || !protocol_) {
        action = addAction(tr("No protocol preferences available"));
        action->setDisabled(true);
        return;
    }

    QAction *disable_action = new QAction(tr("Disable %1" UTF8_HORIZONTAL_ELLIPSIS).arg(short_name), this);
    connect(disable_action, SIGNAL(triggered(bool)), this, SLOT(disableProtocolTriggered()));

    module_ = prefs_find_module(module_name);
    if (!module_ || !prefs_is_registered_protocol(module_name)) {
        action = addAction(tr("%1 has no preferences").arg(long_name));
        action->setDisabled(true);
        addSeparator();
        addAction(disable_action);
        return;
    }

    module_name_ = module_name;

    action = addAction(tr("Open %1 preferences" UTF8_HORIZONTAL_ELLIPSIS).arg(long_name));
    action->setData(QString(module_name));
    connect(action, SIGNAL(triggered(bool)), this, SLOT(modulePreferencesTriggered()));
    addSeparator();

    prefs_pref_foreach(module_, add_prefs_menu_item, this);

    if (!actions().last()->isSeparator()) {
        addSeparator();
    }
    addAction(disable_action);
}