Example #1
0
/**
 * nm_setting_bond_add_option:
 * @setting: the #NMSettingBond
 * @name: name for the option
 * @value: value for the option
 *
 * Add an option to the table.  The option is compared to an internal list
 * of allowed options.  Option names may contain only alphanumeric characters
 * (ie [a-zA-Z0-9]).  Adding a new name replaces any existing name/value pair
 * that may already exist.
 *
 * The order of how to set several options is relevant because there are options
 * that conflict with each other.
 *
 * Returns: %TRUE if the option was valid and was added to the internal option
 * list, %FALSE if it was not.
 **/
gboolean
nm_setting_bond_add_option (NMSettingBond *setting,
                            const char *name,
                            const char *value)
{
	NMSettingBondPrivate *priv;

	g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);

	if (!value || !nm_setting_bond_validate_option (name, value))
		return FALSE;

	priv = NM_SETTING_BOND_GET_PRIVATE (setting);

	g_hash_table_insert (priv->options, g_strdup (name), g_strdup (value));

	if (   !strcmp (name, NM_SETTING_BOND_OPTION_MIIMON)
	    && strcmp (value, "0") != 0) {
		g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
		g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
	} else if (   !strcmp (name, NM_SETTING_BOND_OPTION_ARP_INTERVAL)
	           && strcmp (value, "0") != 0) {
		g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_MIIMON);
		g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_DOWNDELAY);
		g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_UPDELAY);
	}

	g_object_notify (G_OBJECT (setting), NM_SETTING_BOND_OPTIONS);

	return TRUE;
}
Example #2
0
HalProperty *
hal_property_new_string (const char *key, const char *value)
{
	HalProperty *prop;
	char *endchar;
	gboolean validated = TRUE;

	prop = g_new0 (HalProperty, 1);

	prop->type = HAL_PROPERTY_TYPE_STRING;
	prop->key = g_strdup (key);
	prop->v.str_value = g_strdup (value != NULL ? value : "");

	while (!g_utf8_validate (prop->v.str_value, -1,
				 (const char **) &endchar)) {
		validated = FALSE;
		*endchar = '?';
	}

	if (!validated) {
		HAL_WARNING (("Key '%s' has invalid UTF-8 string '%s'",
			      key, prop->v.str_value));
	}

	return prop;
}
Example #3
0
static void
gtk_file_chooser_native_add_choice (GtkFileChooser  *chooser,
                                    const char      *id,
                                    const char      *label,
                                    const char     **options,
                                    const char     **option_labels)
{
  GtkFileChooserNative *self = GTK_FILE_CHOOSER_NATIVE (chooser);
  GtkFileChooserNativeChoice *choice = find_choice (self, id);

  if (choice != NULL)
    {
      g_warning ("Choice with id %s already added to %s %p", id, G_OBJECT_TYPE_NAME (self), self);
      return;
    }

  g_assert ((options == NULL && option_labels == NULL) ||
            g_strv_length ((char **)options) == g_strv_length ((char **)option_labels));

  choice = g_new0 (GtkFileChooserNativeChoice, 1);
  choice->id = g_strdup (id);
  choice->label = g_strdup (label);
  choice->options = g_strdupv ((char **)options);
  choice->option_labels = g_strdupv ((char **)option_labels);

  self->choices = g_slist_prepend (self->choices, choice);

  gtk_file_chooser_add_choice (GTK_FILE_CHOOSER (self->dialog),
                               id, label, options, option_labels);
}
Example #4
0
static void
panel_addto_prepend_directory (GSList             **parent_list,
			       MateMenuTreeDirectory  *directory,
			       const char          *filename)
{
	PanelAddtoAppList *data;

	data = g_new0 (PanelAddtoAppList, 1);

	data->item_info.type          = PANEL_ADDTO_MENU;
	data->item_info.name          = g_strdup (matemenu_tree_directory_get_name (directory));
	data->item_info.description   = g_strdup (matemenu_tree_directory_get_comment (directory));
	data->item_info.icon          = g_strdup (matemenu_tree_directory_get_icon (directory));
	data->item_info.menu_filename = g_strdup (filename);
	data->item_info.menu_path     = matemenu_tree_directory_make_path (directory, NULL);
	data->item_info.static_data   = FALSE;

	/* We should set the iid here to something and do
	 * iid = g_strdup_printf ("MENU:%s", tfr->name)
	 * but this means we'd have to free the iid later
	 * and this would complexify too much the free
	 * function.
	 * So the iid is built when we select the row.
	 */

	*parent_list = g_slist_prepend (*parent_list, data);

	panel_addto_make_application_list (&data->children, directory, filename);
}
Example #5
0
/*
 Initializes a TMTag structure with information from a tagEntryInfo struct
 used by the ctags parsers. Note that the TMTag structure must be malloc()ed
 before calling this function. This function is called by tm_tag_new() - you
 should not need to call this directly.
 @param tag The TMTag structure to initialize
 @param file Pointer to a TMSourceFile struct (it is assigned to the file member)
 @param tag_entry Tag information gathered by the ctags parser
 @return TRUE on success, FALSE on failure
*/
static gboolean tm_tag_init(TMTag *tag, TMSourceFile *file, const tagEntryInfo *tag_entry)
{
	tag->refcount = 1;
	if (NULL == tag_entry)
		return FALSE;
		
	/* This is a normal tag entry */
	if (NULL == tag_entry->name)
		return FALSE;
	tag->name = g_strdup(tag_entry->name);
	tag->type = get_tag_type(tag_entry->kindName);
	tag->local = tag_entry->isFileScope;
	tag->pointerOrder = 0;	/* backward compatibility (use var_type instead) */
	tag->line = tag_entry->lineNumber;
	if (NULL != tag_entry->extensionFields.arglist)
		tag->arglist = g_strdup(tag_entry->extensionFields.arglist);
	if ((NULL != tag_entry->extensionFields.scope[1]) &&
		(0 != tag_entry->extensionFields.scope[1][0]))
		tag->scope = g_strdup(tag_entry->extensionFields.scope[1]);
	if (tag_entry->extensionFields.inheritance != NULL)
		tag->inheritance = g_strdup(tag_entry->extensionFields.inheritance);
	if (tag_entry->extensionFields.varType != NULL)
		tag->var_type = g_strdup(tag_entry->extensionFields.varType);
	if (tag_entry->extensionFields.access != NULL)
		tag->access = get_tag_access(tag_entry->extensionFields.access);
	if (tag_entry->extensionFields.implementation != NULL)
		tag->impl = get_tag_impl(tag_entry->extensionFields.implementation);
	if ((tm_tag_macro_t == tag->type) && (NULL != tag->arglist))
		tag->type = tm_tag_macro_with_arg_t;
	tag->file = file;
	tag->lang = file->lang;
	return TRUE;
}
void
test_load_paths (void)
{
    const gchar *config_dir;

    config_dir = g_getenv("MILTER_MANAGER_CONFIG_DIR");
    if (config_dir)
        expected_load_paths = g_list_append(expected_load_paths,
                                            g_strdup(config_dir));
    expected_load_paths = g_list_append(expected_load_paths,
                                        g_strdup(CONFIG_DIR));
    gcut_assert_equal_list_string(
        expected_load_paths,
        milter_manager_configuration_get_load_paths(config));

    expected_load_paths = g_list_append(expected_load_paths,
                                        g_strdup("append/XXX"));
    milter_manager_configuration_append_load_path(config, "append/XXX");
    gcut_assert_equal_list_string(
        expected_load_paths,
        milter_manager_configuration_get_load_paths(config));

    expected_load_paths = g_list_prepend(expected_load_paths,
                                         g_strdup("prepend/XXX"));
    milter_manager_configuration_prepend_load_path(config, "prepend/XXX");
    gcut_assert_equal_list_string(
        expected_load_paths,
        milter_manager_configuration_get_load_paths(config));


    milter_manager_configuration_clear_load_paths(config);
    gcut_assert_equal_list_string(
        NULL,
        milter_manager_configuration_get_load_paths(config));
}
void
gimp_plug_in_manager_add_menu_branch (GimpPlugInManager *manager,
                                      const gchar       *prog_name,
                                      const gchar       *menu_path,
                                      const gchar       *menu_label)
{
  GimpPlugInMenuBranch *branch;

  g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
  g_return_if_fail (prog_name != NULL);
  g_return_if_fail (menu_path != NULL);
  g_return_if_fail (menu_label != NULL);

  branch = g_slice_new (GimpPlugInMenuBranch);

  branch->prog_name  = g_strdup (prog_name);
  branch->menu_path  = plug_in_menu_path_map (menu_path);
  branch->menu_label = g_strdup (menu_label);

  manager->menu_branches = g_slist_append (manager->menu_branches, branch);

  g_signal_emit_by_name (manager, "menu-branch-added",
                         branch->prog_name,
                         branch->menu_path,
                         branch->menu_label);

#ifdef VERBOSE
  g_print ("added menu branch \"%s\" at path \"%s\"\n",
           branch->menu_label, branch->menu_path);
#endif
}
Example #8
0
/* Connect Server
 */
static void
panel_action_connect_server (GtkWidget *widget)
{
	GdkScreen *screen;
	char      *command;
	GError    *error;

	screen = gtk_widget_get_screen (GTK_WIDGET (widget));
	error = NULL;

	if (panel_is_program_in_path ("caja-connect-server"))
		command = g_strdup ("caja-connect-server");
	else if (panel_is_program_in_path ("nautilus-connect-server"))
		command = g_strdup ("nautilus-connect-server");
	else
		command = g_strdup ("nemo-connect-server");

	mate_gdk_spawn_command_line_on_screen (screen, command, &error);
	g_free (command);

	if (error) {
		panel_error_dialog (NULL, screen,
				    "cannot_connect_server",
				    TRUE,
				    _("Could not connect to server"),
				    error->message);
		g_clear_error (&error);
	}
}
Example #9
0
MsnSlpLink *
msn_slplink_new(MsnSession *session, const char *username)
{
	MsnSlpLink *slplink;

	g_return_val_if_fail(session != NULL, NULL);

	slplink = g_new0(MsnSlpLink, 1);

#ifdef MSN_DEBUG_SLPLINK
	purple_debug_info("msn", "slplink_new: slplink(%p)\n", slplink);
#endif

	slplink->session = session;
	slplink->slp_seq_id = rand() % 0xFFFFFF00 + 4;

	slplink->local_user = g_strdup(msn_user_get_passport(session->user));
	slplink->remote_user = g_strdup(username);

	slplink->slp_msg_queue = g_queue_new();

	session->slplinks =
		g_list_append(session->slplinks, slplink);

	return slplink;
}
static char *
shell_util_get_file_display_for_common_files (GFile *file)
{
  GFile *compare;

  compare = g_file_new_for_path (g_get_home_dir ());
  if (g_file_equal (file, compare))
    {
      g_object_unref (compare);
      /* Translators: this is the same string as the one found in
       * nautilus */
      return g_strdup (_("Home"));
    }

  compare = g_file_new_for_path ("/");
  if (g_file_equal (file, compare))
    {
      g_object_unref (compare);
      /* Translators: this is the same string as the one found in
       * nautilus */
      return g_strdup (_("File System"));
    }
  g_object_unref (compare);

  return NULL;
}
Example #11
0
static void
fetchSettingsFromConfigUI(PrettyPrintingOptions* ppo)
{
    int breakStyle;

    if (ppo == NULL) return;
    ppo->oneLineComment = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(commentOneLine));
    ppo->inlineComment = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(commentInline));
    ppo->alignComment = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(commentAlign));

    ppo->oneLineText = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(textOneLine));
    ppo->inlineText = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(textInline));
    ppo->alignText = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(textAlign));

    ppo->oneLineCdata = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cdataOneLine));
    ppo->inlineCdata = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cdataInline));
    ppo->alignCdata = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cdataAlign));

    ppo->emptyNodeStripping = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(emptyNodeStripping));
    ppo->emptyNodeStrippingSpace = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(emptyNodeStrippingSpace));
    ppo->forceEmptyNodeSplit = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(emptyNodeSplit));

    ppo->indentLength = gtk_spin_button_get_value(GTK_SPIN_BUTTON(indentationCount));
    ppo->indentChar = gtk_combo_box_get_active(GTK_COMBO_BOX(indentationChar))==0 ? '\t' : ' ';

    breakStyle = gtk_combo_box_get_active(GTK_COMBO_BOX(lineBreak));
    g_free ((gpointer)ppo->newLineChars);
    if (breakStyle == 0) ppo->newLineChars = g_strdup("\r");
    else if (breakStyle == 1) ppo->newLineChars = g_strdup("\n");
    else ppo->newLineChars = g_strdup("\r\n");
}
static void add_properties(GHashTable *ht, GKeyFile *kf,
			   const char *group) {
  g_hash_table_insert(ht,
		      g_strdup(OPENSLIDE_PROPERTY_NAME_VENDOR),
		      g_strdup("hamamatsu"));

  char **keys = g_key_file_get_keys(kf, group, NULL, NULL);
  if (keys == NULL) {
    return;
  }

  for (char **key = keys; *key != NULL; key++) {
    char *value = g_key_file_get_value(kf, group, *key, NULL);
    if (value) {
      g_hash_table_insert(ht,
			  g_strdup_printf("hamamatsu.%s", *key),
			  g_strdup(value));
      g_free(value);
    }
  }

  g_strfreev(keys);

  // this allows openslide.objective-power to have a fractional component
  // but it's better than rounding
  _openslide_duplicate_double_prop(ht, "hamamatsu.SourceLens",
                                   OPENSLIDE_PROPERTY_NAME_OBJECTIVE_POWER);
  // TODO: can we calculate MPP from PhysicalWidth/PhysicalHeight?
}
static GSList *
translate_document_list (EggDesktopFile *desktop_file, GSList *documents)
{
  gboolean accepts_uris = egg_desktop_file_accepts_uris (desktop_file);
  GSList *ret, *d;

  for (d = documents, ret = NULL; d; d = d->next)
    {
      const char *document = d->data;
      gboolean is_uri = !g_path_is_absolute (document);
      char *translated;

      if (accepts_uris)
	{
	  if (is_uri)
	    translated = g_strdup (document);
	  else
	    translated = g_filename_to_uri (document, NULL, NULL);
	}
      else
	{
	  if (is_uri)
	    translated = g_filename_from_uri (document, NULL, NULL);
	  else
	    translated = g_strdup (document);
	}

      if (translated)
	ret = g_slist_prepend (ret, translated);
    }

  return g_slist_reverse (ret);
}
Example #14
0
/*
 * Given a string of the form "<username>:<password>", as might appear
 * as an argument to a "-A" option, parse it and set the arguments in
 * question.  Return an indication of whether it succeeded or failed
 * in some fashion.
 */
static gboolean
get_auth_arguments(capture_options *capture_opts, const char *arg)
{
    gchar *p = NULL, *colonp;

    colonp = strchr(arg, ':');
    if (colonp == NULL)
        return FALSE;

    p = colonp;
    *p++ = '\0';

    while (isspace((guchar)*p))
        p++;

    if (capture_opts->ifaces->len > 0) {
        interface_options interface_opts;

        interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
        capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
        interface_opts.auth_type = CAPTURE_AUTH_PWD;
        interface_opts.auth_username = g_strdup(arg);
        interface_opts.auth_password = g_strdup(p);
        g_array_append_val(capture_opts->ifaces, interface_opts);
    } else {
        capture_opts->default_options.auth_type = CAPTURE_AUTH_PWD;
        capture_opts->default_options.auth_username = g_strdup(arg);
        capture_opts->default_options.auth_password = g_strdup(p);
    }
    *colonp = ':';
    return TRUE;
}
Example #15
0
enclosurePtr
enclosure_from_string (const gchar *str)
{
	gchar 		**fields;
	enclosurePtr	enclosure;
	
	enclosure = g_new0 (struct enclosure, 1);
	
	/* legacy URL, migration case... */
	if (strstr (str, "enc:") != str) {
		enclosure->url = g_strdup (str);
		return enclosure;
	}
	
	fields = g_regex_split_simple ("^enc:([01]?):([^:]*):(\\d+):(.*)", str, 0, 0);
	if (6 > g_strv_length (fields)) {
		debug2 (DEBUG_PARSING, "Dropping incorrectly encoded enclosure: >>>%s<<< (nr of fields=%d)\n", str, g_strv_length (fields));
		enclosure_free (enclosure);
		return NULL;
	}
	
	enclosure->downloaded = ('1' == *fields[1]);
	if (strlen (fields[2]))
		enclosure->mime = g_strdup (fields[2]);
	if (strlen (fields[3]))
		enclosure->size = atol (fields[3]);
	enclosure->url = g_strdup (fields[4]);

	g_strfreev (fields);

	return enclosure;
}
Example #16
0
/* Called with lock held */
static gchar *
gst_time_overlay_get_text (GstTextOverlay * overlay, GstBuffer * video_frame)
{
  GstClockTime time = GST_BUFFER_TIMESTAMP (video_frame);
  gchar *time_str, *txt, *ret;

  overlay->need_render = TRUE;

  if (!GST_CLOCK_TIME_IS_VALID (time)) {
    GST_DEBUG ("buffer without valid timestamp");
    return g_strdup ("");
  }

  GST_DEBUG ("buffer with timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (time));

  txt = g_strdup (overlay->default_text);

  time_str = gst_time_overlay_render_time (GST_TIME_OVERLAY (overlay), time);
  if (txt != NULL && *txt != '\0') {
    ret = g_strdup_printf ("%s %s", txt, time_str);
  } else {
    ret = time_str;
    time_str = NULL;
  }

  g_free (txt);
  g_free (time_str);

  return ret;
}
Example #17
0
static node_t*
node_new (node_t* parent, const gchar* basename)
{
	node_t *f = NULL;

    g_assert (basename && basename[0]);

    if ((f = g_new0(node_t, 1)) != NULL) {
        if (parent) {
            NODE_NAME(f) = g_build_filename(NODE_NAME(parent), basename, NULL);
        } else {
            NODE_NAME(f) = g_strdup(G_DIR_SEPARATOR_S);
        }
        f->basename = g_strdup (basename);
        /* f->children = g_hash_table_new_full (g_str_hash, g_str_equal, */
        /*   NULL, (GDestroyNotify)node_delete); */
        f->children = g_hash_table_new_full (g_str_hash, g_str_equal,
          NULL, NULL);
#ifdef GIO_COMPILATION
        f->gfile = g_file_new_for_path (NODE_NAME(f));
#endif
        FN_W ("%s 0x%p %s\n", __func__, f, NODE_NAME(f));
    }
	return f;
}
Example #18
0
/* FIXME: we probably want to return a GIcon, that would be built with
 * g_themed_icon_new_with_default_fallbacks() since we can get an icon like
 * "folder-music", where "folder" is the safe fallback. */
char *
panel_util_get_icon_for_uri (const char *text_uri)
{
	const char *icon;
	GFile      *file;
	GFileInfo  *info;
	GIcon      *gicon;
	char       *retval;

	/* Here's what we do:
	 *  + check for known file: URI
	 *  + x-caja-search: URI
	 *  + override burn: URI icon
	 *  + check if the URI is a mount
	 *  + override trash: URI icon for subfolders
	 *  + check for application/x-mate-saved-search mime type and override
	 *    icon of the GFile
	 *  + use icon of the GFile
	 */

	/* this only checks file: URI */
	icon = panel_util_get_icon_for_uri_known_folders (text_uri);
	if (icon)
		return g_strdup (icon);

	if (g_str_has_prefix (text_uri, "x-caja-search:"))
		return g_strdup (PANEL_ICON_SAVED_SEARCH);
	/* gvfs doesn't give us a nice icon, so overriding */
	if (g_str_has_prefix (text_uri, "burn:"))
		return g_strdup (PANEL_ICON_BURNER);

	file = g_file_new_for_uri (text_uri);

	retval = panel_util_get_file_icon_name_if_mount (file);
	if (retval)
		return retval;

	/* gvfs doesn't give us a nice icon for subfolders of the trash, so
	 * overriding */
	if (g_str_has_prefix (text_uri, "trash:")) {
		GFile *root;

		root = panel_util_get_gfile_root (file);
		g_object_unref (file);
		file = root;
	}

	info = g_file_query_info (file, "standard::icon",
				  G_FILE_QUERY_INFO_NONE, NULL, NULL);
	g_object_unref (file);

	if (!info)
		return NULL;

	gicon = g_file_info_get_icon (info);
	retval = panel_util_get_icon_name_from_g_icon (gicon);
	g_object_unref (info);

	return retval;
}
Example #19
0
void build_package_paths(void)
{
#ifdef WINNT

    gchar* prefix;
    prefix = g_win32_get_package_installation_directory_of_module(NULL);

#ifndef TEST
    glade_dir = g_build_filename(prefix, "share", PACKAGE, "glade", NULL);
#else
    glade_dir = g_build_filename(prefix, "..", "..", "data", NULL);
#endif
    locale_dir = g_build_filename(prefix, "share", "locale", NULL);

    g_free(prefix);

#else /* WINNT */

#ifndef TEST
    glade_dir = g_strdup(GLADEDIR);
#else
    glade_dir = g_build_filename(LOCALPATH, "data", NULL);
#endif
    locale_dir = g_strdup(NETWORK_TRAFFIC_LOCALEDIR);

#endif /* WINNT */
}
Example #20
0
char *
panel_util_make_exec_uri_for_desktop (const char *exec)
{
	GString    *str;
	const char *c;

	if (!exec)
		return g_strdup ("");

	if (!strchr (exec, ' '))
		return g_strdup (exec);

	str = g_string_new_len (NULL, strlen (exec));

	str = g_string_append_c (str, '"');
	for (c = exec; *c != '\0'; c++) {
		/* FIXME: GKeyFile will add an additional backslach so we'll
		 * end up with toto\\" instead of toto\"
		 * We could use g_key_file_set_value(), but then we don't
		 * benefit from the other escaping that glib is doing...
		 */
		if (*c == '"')
			str = g_string_append (str, "\\\"");
		else
			str = g_string_append_c (str, *c);
	}
	str = g_string_append_c (str, '"');

	return g_string_free (str, FALSE);
}
Example #21
0
static void
panel_addto_name_change (PanelAddtoDialog *dialog,
			 const char       *name)
{
	char *title;
	char *label;

	label = NULL;

	if (!PANEL_GLIB_STR_EMPTY (name))
		label = g_strdup_printf (_("Find an _item to add to \"%s\":"),
					 name);

	if (panel_toplevel_get_is_attached (dialog->panel_widget->toplevel)) {
		title = g_strdup_printf (_("Add to Drawer"));
		if (label == NULL)
			label = g_strdup (_("Find an _item to add to the drawer:"));
	} else {
		title = g_strdup_printf (_("Add to Panel"));
		if (label == NULL)
			label = g_strdup (_("Find an _item to add to the panel:"));
	}

	gtk_window_set_title (GTK_WINDOW (dialog->addto_dialog), title);
	g_free (title);

	gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->label), label);
	g_free (label);
}
Example #22
0
/* erstellt ein neues Koordinatensystem */
CoordSystem *coord_system_new(GtkWidget *darea,
                              const gchar *x_title, const gchar *x_unit,
                              const gchar *y_title, const gchar *y_unit,
                              gboolean fract_x, gboolean fract_y,
                              gdouble min_x, gdouble max_x,
                              gdouble min_y, gdouble max_y)
{
    CoordSystem *coord;

    /* bricht ab, wenn der größte Wert niedriger als der
       Kleinste ist, oder umgekehrt */
    if (min_x >= max_x || min_y >= max_y)
        return NULL;

    coord = (CoordSystem *) g_malloc(sizeof(CoordSystem));

    coord->x_title = g_strdup(x_title);
    coord->y_title = g_strdup(y_title);

    coord->x_unit = g_strdup(x_unit);
    coord->y_unit = g_strdup(y_unit);

    coord->fract_x = fract_x;
    coord->fract_y = fract_y;

    coord->graphs = NULL;

    coord_system_adjust(coord, darea,
                        min_x, max_x, min_y, max_y);

    return coord;
}
Example #23
0
PurplePounce *
purple_pounce_new(const char *ui_type, PurpleAccount *pouncer,
				const char *pouncee, PurplePounceEvent event,
				PurplePounceOption option)
{
	PurplePounce *pounce;
	PurplePounceHandler *handler;

	g_return_val_if_fail(ui_type != NULL, NULL);
	g_return_val_if_fail(pouncer != NULL, NULL);
	g_return_val_if_fail(pouncee != NULL, NULL);
	g_return_val_if_fail(event   != 0,    NULL);

	pounce = g_new0(PurplePounce, 1);

	pounce->ui_type  = g_strdup(ui_type);
	pounce->pouncer  = pouncer;
	pounce->pouncee  = g_strdup(pouncee);
	pounce->events   = event;
	pounce->options  = option;

	pounce->actions  = g_hash_table_new_full(g_str_hash, g_str_equal,
											 g_free, free_action_data);

	handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);

	if (handler != NULL && handler->new_pounce != NULL)
		handler->new_pounce(pounce);

	pounces = g_list_append(pounces, pounce);

	schedule_pounces_save();

	return pounce;
}
static void read_config(void)
{
	gchar *path;
	gboolean initial = FALSE;

	debug_print("autoenc: read_config\n");
	path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "autoencrc", NULL);
	if (!is_file_exist(path)) {
		initial = TRUE;
		prefs_set_default(param);
	} else {
		prefs_read_config(param, "AutoEncrypt", path, NULL);
	}

	if (!config.autoenc_template_subject) {
		config.autoenc_template_subject =
			g_strdup(_("Password of encrypted file"));
	}
	if (!config.autoenc_template_body) {
		config.autoenc_template_body =
			g_strdup(_("Subject: %s\\n"
				   "Date: %d\\n"
				   "The password of the encrypted file attached in the above mail is as follows:\\n"
				   "\\n"
				   "File name: %z\\n"
				   "Password: %p"));
	}

	if (initial) {
		write_config();
	}

	g_free(path);
}
Example #25
0
static void ppp_connect(const char *iface, const char *local, const char *peer,
                        const char *dns1, const char *dns2,
                        gpointer user_data)
{
    DBusConnection *conn = ofono_dbus_get_connection();
    struct dundee_device *device = user_data;
    const char *dns[3] = { dns1, dns2, 0 };

    DBG("%p", device);
    DBG("Network Device: %s\n", iface);
    DBG("IP Address: %s\n", local);
    DBG("Peer IP Address: %s\n", peer);
    DBG("Primary DNS Server: %s\n", dns1);
    DBG("Secondary DNS Server: %s\n", dns2);

    if (device->connect_timeout > 0) {
        g_source_remove(device->connect_timeout);
        device->connect_timeout = 0;
    }

    g_free(device->settings.interface);
    device->settings.interface = g_strdup(iface);
    if (device->settings.interface == NULL)
        goto err;

    g_free(device->settings.ip);
    device->settings.ip = g_strdup(local);
    if (device->settings.ip == NULL)
        goto err;

    g_strfreev(device->settings.nameservers);
    device->settings.nameservers = g_strdupv((gchar **)dns);
    if (device->settings.nameservers == NULL)
        goto err;

    __ofono_dbus_pending_reply(&device->pending,
                               dbus_message_new_method_return(device->pending));
    device->pending = NULL;

    device->active = TRUE;

    settings_changed(device);
    ofono_dbus_signal_property_changed(conn, device->path,
                                       DUNDEE_DEVICE_INTERFACE, "Active",
                                       DBUS_TYPE_BOOLEAN, &device->active);

    return;

err:
    g_free(device->settings.interface);
    g_free(device->settings.ip);
    g_strfreev(device->settings.nameservers);
    device->settings.interface = NULL;
    device->settings.ip = NULL;
    device->settings.nameservers = NULL;

    __ofono_dbus_pending_reply(&device->pending,
                               __dundee_error_failed(device->pending));
    device->pending = NULL;
}
Example #26
0
void debug_print_log_string ( gchar *prefixe,
                        gchar *file,
                        gint line,
                        const char *function,
                        const gchar *msg )
{
    gchar *tmp_str;
    gchar *message;

    if ( debug_file == NULL )
        return;

    if ( msg && strlen ( msg ) )
        message = g_strdup ( msg );
    else
        message = g_strdup ( "(null)" );

    tmp_str = g_strdup_printf(_("%s, %2f : %s - %s:%d:%s - %s\n"),
                        get_debug_time ( ),
                        (double ) clock ( )/ CLOCKS_PER_SEC,
                        prefixe,
                        file,
                        line,
                        function,
                        message );

    fwrite ( tmp_str, sizeof (gchar), strlen ( tmp_str ), debug_file );
    fflush ( debug_file );

    g_free ( tmp_str );
    g_free ( message );
}
static void
__add_join (Psh *holder)
{
    MidgardCRCoreQueryExecutor *executor = MIDGARD_CR_CORE_QUERY_EXECUTOR (holder->executor);
    GdaSqlStatement *sql_stm = executor->priv->stmt;
    GdaSqlStatementSelect *select = (GdaSqlStatementSelect *) sql_stm->contents;
    GdaSqlSelectFrom *from = select->from;
    GdaSqlSelectJoin *join = gda_sql_select_join_new (GDA_SQL_ANY_PART (from));
    join->type = GDA_SQL_SELECT_JOIN_LEFT;

    GdaSqlExpr *expr = gda_sql_expr_new (GDA_SQL_ANY_PART (join));
    expr->value = gda_value_new (G_TYPE_STRING);
    g_value_take_string (expr->value, g_strdup_printf ("%s.%s = %s.%s",
                         holder->table_alias, holder->colname, holder->target_table_alias, holder->target_colname));
    join->expr = expr;
    join->position = ++executor->priv->joinid;

    gda_sql_select_from_take_new_join (from , join);

    GdaSqlSelectTarget *s_target = gda_sql_select_target_new (GDA_SQL_ANY_PART (from));
    s_target->table_name = g_strdup (holder->target_table);
    s_target->as = g_strdup (holder->target_table_alias);
    gda_sql_select_from_take_new_target (from, s_target);

    /* Set target expression */
    GdaSqlExpr *texpr = gda_sql_expr_new (GDA_SQL_ANY_PART (s_target));
    GValue *tval = g_new0 (GValue, 1);
    g_value_init (tval, G_TYPE_STRING);
    g_value_set_string (tval, s_target->table_name);
    texpr->value = tval;
    s_target->expr = texpr;
}
Example #28
0
static gchar *get_v4l2_device_name(gchar *filename)
{
    gchar *device_name;
    int fd = 0;

    fd = open(filename, O_RDWR);

    if (fd <= 0) {
        g_warning("v4l: failed to open %s", filename);

        device_name = g_strdup(filename);

        return NULL;
    } else {
        struct v4l2_capability vcap;

        if (v4l2_ioctl(fd, VIDIOC_QUERYCAP, &vcap) < 0) {
            g_warning("v4l: failed to query %s", filename);

            device_name = g_strdup(filename);
        } else {
            device_name = g_strdup((const gchar *)vcap.card);
        }
    }

    g_warning("v4l: found device: %s", device_name);

    close(fd);

    return device_name;
}
static void
parse_header_lines (const gchar *hbeg, const gchar *hend, GHashTable **result)
{
	gchar **lines, **l;
	gchar *line, *name, *value;
	gchar *copy;
	
	copy = g_strndup (hbeg, hend - hbeg);
	lines = g_strsplit (copy, "\n", 0);
	g_free (copy);
	
	for (l = lines; l && *l; ++l) {
		line = *l;
		g_strstrip (line);
		
        	/* Look for the break between name: value */
        	value = strchr (line, ':');
        	if (value == NULL)
        		continue;
        		
        	*value = 0;
        	value = g_strdup (value + 1);
        	g_strstrip (value);
        	
        	name = g_strdup (line);
        	g_strstrip (name);
        	
        	if (!*result)
        		*result = egg_openssl_headers_new ();
        	g_hash_table_replace (*result, name, value);
	}

	g_strfreev (lines);
} 
Example #30
0
gulong
purple_media_manager_set_output_window(PurpleMediaManager *manager,
		PurpleMedia *media, const gchar *session_id,
		const gchar *participant, gulong window_id)
{
#ifdef USE_VV
	PurpleMediaOutputWindow *output_window;

	g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager), FALSE);
	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);

	output_window = g_new0(PurpleMediaOutputWindow, 1);
	output_window->id = manager->priv->next_output_window_id++;
	output_window->media = media;
	output_window->session_id = g_strdup(session_id);
	output_window->participant = g_strdup(participant);
	output_window->window_id = window_id;

	manager->priv->output_windows = g_list_prepend(
			manager->priv->output_windows, output_window);

	if (purple_media_get_tee(media, session_id, participant) != NULL)
		purple_media_manager_create_output_window(manager,
				media, session_id, participant);

	return output_window->id;
#else
	return 0;
#endif
}