Exemplo n.º 1
0
static void
_tarif_clear(gint tarif_id)
{
  GSList **tarif = NULL;
  GSList *link = NULL;
  CCL_tarifpart *tp = NULL;
  GData *freed = NULL;

  tarif = g_new0(GSList *, 1);
  *tarif = g_datalist_id_get_data(&ccl->tarifs, tarif_id);

  g_assert(NULL != tarif);
  
  g_datalist_init(&freed);

  while ((link = g_slist_last(*tarif)) && *tarif)
    {
      *tarif = g_slist_remove_link(*tarif, link);
      tp = (CCL_tarifpart *) link->data;
      if (!g_datalist_id_get_data(&freed, GPOINTER_TO_INT(tp->prices)))
	{
	  g_datalist_clear(tp->prices);
	  g_datalist_id_set_data(&freed, GPOINTER_TO_INT(tp->prices),
				 (void *)tp->prices);
	  g_free(tp->prices);
	}
      g_slist_free_1(link);
      g_free(tp);
    }
  g_datalist_clear(&freed);
  *tarif = NULL;
  g_datalist_id_remove_data(&ccl->tarifs, tarif_id);
  g_free(tarif);
}
Exemplo n.º 2
0
qq_im_format *qq_im_fmt_new_by_purple(const gchar *msg)
{
	qq_im_format *fmt;
	const gchar *start, *end, *last;
	GData *attribs;
	gchar *tmp;
	unsigned char *rgb;

	g_return_val_if_fail(msg != NULL, NULL);

	fmt = qq_im_fmt_new();

	last = msg;
	while (purple_markup_find_tag("font", last, &start, &end, &attribs)) {
		tmp = g_datalist_get_data(&attribs, "face");
		if (tmp && strlen(tmp) > 0) {
			if (fmt->font)	g_free(fmt->font);
			fmt->font_len = strlen(tmp);
			fmt->font = g_strdup(tmp);
		}

		tmp = g_datalist_get_data(&attribs, "size");
		if (tmp) {
			fmt->attr = atoi(tmp) * 3 + 1;
			fmt->attr &= 0x0f;
		}

		tmp = g_datalist_get_data(&attribs, "color");
		if (tmp && strlen(tmp) > 1) {
			rgb = purple_base16_decode(tmp + 1, NULL);
			g_memmove(fmt->rgb, rgb, 3);
			g_free(rgb);
		}

		g_datalist_clear(&attribs);
		last = end + 1;
	}

	if (purple_markup_find_tag("b", msg, &start, &end, &attribs)) {
		fmt->attr |= 0x20;
		g_datalist_clear(&attribs);
	}

	if (purple_markup_find_tag("i", msg, &start, &end, &attribs)) {
		fmt->attr |= 0x40;
		g_datalist_clear(&attribs);
	}

	if (purple_markup_find_tag("u", msg, &start, &end, &attribs)) {
		fmt->attr |= 0x80;
		g_datalist_clear(&attribs);
	}

	return fmt;
}
Exemplo n.º 3
0
/**
 * Rebuild all the tarifs from the data on the db.
 *
 * This should be used after you have initialized CCL.
 */
void
CCL_tarif_rebuild_all(void)
{
  GSList ** tarif = NULL;
  gint tarif_id;
  gint i;

  for (i = 0; -1 != (tarif_id = CCL_tarif_get_nth(i)); i++)
    _tarif_clear(tarif_id);

  g_datalist_clear(&ccl->tarifs);
  g_datalist_init(&ccl->tarifs);
  
  for (i = 0; -1 != (tarif_id = CCL_tarif_get_nth(i)); i++)
    {
      tarif = g_new0(GSList *, 1);
      *tarif = NULL;
      _tarif_rebuild(tarif_id, tarif);
      g_datalist_id_set_data(&ccl->tarifs, tarif_id, *tarif);
      g_free(tarif);
    }
#ifdef DEBUG
  printf("CCL_tarif_rebuild_all(): [ %d ] Tariffs found\n", i);
#endif
}
Exemplo n.º 4
0
static void
gca_service_proxy_finalize (GObject *object)
{
  GcaServiceProxy *proxy = GCA_SERVICE_PROXY (object);
  g_datalist_clear (&proxy->priv->qdata);
  G_OBJECT_CLASS (gca_service_proxy_parent_class)->finalize (object);
}
Exemplo n.º 5
0
/* Funcion initReceivers
 * Precondiciones:
 * Postcondiciones:
 * Entrada:
 * Salida:
 * Proceso:
 * */
gboolean
initReceivers					(GData** receiveConfig, gchar** error)
{
	
	/* Free memory and exit. */
	g_datalist_clear(receiveConfig);
	return (TRUE);
}
static void
record_logout_for_all_remaining_sessions (void)
{
  g_datalist_foreach (&humanity_by_session_id,
                      (GDataForeachFunc) record_stop_for_login,
                      NULL /* user_data */);
  g_datalist_clear (&humanity_by_session_id);
}
Exemplo n.º 7
0
/**
 * 类析构函数.
 */
SoundSystem::~SoundSystem()
{
        GstElement *pipeline;

        if ( (pipeline = GST_ELEMENT(g_datalist_get_data(&eltset, "pipeline-element"))))
                gst_element_set_state(pipeline, GST_STATE_NULL);
        g_datalist_clear(&eltset);
}
Exemplo n.º 8
0
static void instance_finalize( GbdX11emitter* self ) {
	GbdX11emitterPrivate* const priv = self->priv;
	g_clear_object( &priv->srcdata );
	g_clear_object( &priv->srcstream );

	g_datalist_clear( &priv->mapcache );

	G_OBJECT_CLASS( g_type_class_peek( G_TYPE_OBJECT ) )->finalize( G_OBJECT( self ) );
}
static void gfire_sq_gamespy_data_free(gfire_sq_gamespy_data *p_data)
{
	g_datalist_clear(&p_data->info);
	g_datalist_clear(&p_data->rules);
	g_datalist_clear(&p_data->player_data);

	while(p_data->players)
	{
		gfire_sq_gamespy_player *player = (gfire_sq_gamespy_player*)p_data->players->data;
		g_free(player->name);
		g_free(player->mesh);
		g_free(player->skin);
		g_free(player->face);
		g_free(player);
		p_data->players = g_slist_delete_link(p_data->players, p_data->players);
	}
	g_free(p_data);
}
Exemplo n.º 10
0
static void
ibus_serializable_destroy (IBusSerializable *object)
{
    IBusSerializablePrivate *priv;
    priv = IBUS_SERIALIZABLE_GET_PRIVATE (object);

    g_datalist_clear (&priv->attachments);

    parent_class->destroy (IBUS_OBJECT (object));
}
Exemplo n.º 11
0
static void gfire_sq_savage_free_server(gfire_game_server *p_server)
{
	if(p_server->data && p_server->data->proto_data)
	{
		gfire_sq_savage_data *data = (gfire_sq_savage_data*)p_server->data->proto_data;

		g_datalist_clear(&data->info);
		g_strfreev(data->players);

		g_free(data);
	}
}
Exemplo n.º 12
0
void
g_scanner_destroy (GScanner	*scanner)
{
  g_return_if_fail (scanner != NULL);
  
  g_datalist_clear (&scanner->qdata);
  g_hash_table_foreach (scanner->symbol_table, 
			g_scanner_destroy_symbol_table_entry, NULL);
  g_hash_table_destroy (scanner->symbol_table);
  g_scanner_free_value (&scanner->token, &scanner->value);
  g_scanner_free_value (&scanner->next_token, &scanner->next_value);
  g_free (scanner->config);
  g_free (scanner->buffer);
  g_free (scanner);
}
Exemplo n.º 13
0
inline void gs_set_player(player_t* player)
{
  thread_tls_initonce(&tls_player);
  thread_tls_set(&tls_player, player);

  if(!player) {
    GData* transact_data;
    thread_tls_initonce(&tls_transact_data);
    transact_data = (GData*)thread_tls_get(&tls_transact_data);

    g_datalist_clear(&transact_data);
    g_datalist_init(&transact_data);
    thread_tls_set(&tls_transact_data, transact_data);
  }
}
Exemplo n.º 14
0
/**
 * e_uri_free:
 * @uri: A pointer to the #EUri to free.
 *
 * Frees the memory of an #EUri structure.
 **/
void
e_uri_free (EUri *uri)
{
	if (uri) {
		g_free (uri->protocol);
		g_free (uri->user);
		g_free (uri->authmech);
		g_free (uri->passwd);
		g_free (uri->host);
		g_free (uri->path);
		g_datalist_clear (&uri->params);
		g_free (uri->query);
		g_free (uri->fragment);

		g_free (uri);
	}
}
Exemplo n.º 15
0
static void
static_finalize (GObject *object)
{
  TpStaticHandleRepo *self = TP_STATIC_HANDLE_REPO (object);
  guint i;

  if (self->datalists)
    {
      for (i = 0; i < self->last_handle; i++)
        {
          g_datalist_clear (self->datalists + i);
        }
    }

  g_strfreev (self->handle_names);

  G_OBJECT_CLASS (tp_static_handle_repo_parent_class)->finalize (object);
}
Exemplo n.º 16
0
static void
static_set_property (GObject *object,
    guint property_id,
    const GValue *value,
    GParamSpec *pspec)
{
  TpStaticHandleRepo *self = TP_STATIC_HANDLE_REPO (object);
  TpHandle i;

  switch (property_id)
    {
    case PROP_HANDLE_TYPE:
      self->handle_type = g_value_get_uint (value);
      break;

    case PROP_HANDLE_NAMES:

      if (self->datalists)
        {
          for (i = 0; i < self->last_handle; i++)
            {
              g_datalist_clear (self->datalists + i);
            }
        }

      g_strfreev (self->handle_names);
      self->handle_names = g_strdupv (g_value_get_boxed (value));
      i = 0;
      while (self->handle_names[i] != NULL)
        {
          i++;
        }
      self->last_handle = i;

      g_free (self->datalists);
      self->datalists = NULL;

      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}
Exemplo n.º 17
0
static void free_ase_data(gfire_sq_ase_data *p_data)
{
	g_free(p_data->game_name);
	g_free(p_data->server_name);
	g_free(p_data->game_type);
	g_free(p_data->map);
	g_free(p_data->version);

	if(p_data->rules)
		g_datalist_clear(&p_data->rules);

	while(p_data->players)
	{
		free_ase_player(p_data->players->data);
		p_data->players = g_slist_delete_link(p_data->players, p_data->players);
	}

	g_free(p_data);
}
static void
gst_v4l2_empty_lists (GstV4l2Object * v4l2object)
{
  GST_DEBUG_OBJECT (v4l2object->element, "deleting enumerations");

  g_list_foreach (v4l2object->channels, (GFunc) g_object_unref, NULL);
  g_list_free (v4l2object->channels);
  v4l2object->channels = NULL;

  g_list_foreach (v4l2object->norms, (GFunc) g_object_unref, NULL);
  g_list_free (v4l2object->norms);
  v4l2object->norms = NULL;

  g_list_foreach (v4l2object->colors, (GFunc) g_object_unref, NULL);
  g_list_free (v4l2object->colors);
  v4l2object->colors = NULL;

  g_datalist_clear (&v4l2object->controls);
}
Exemplo n.º 19
0
/**
 * camel_url_free:
 * @url: a #CamelURL
 *
 * Frees @url.
 **/
void
camel_url_free (CamelURL *url)
{
	if (url) {
		if (url->user)
			memset (url->user, 0, strlen (url->user));
		if (url->host)
			memset (url->host, 0, strlen (url->host));
		g_free (url->protocol);
		g_free (url->user);
		g_free (url->authmech);
		g_free (url->host);
		g_free (url->path);
		g_datalist_clear (&url->params);
		g_free (url->query);
		g_free (url->fragment);

		g_free (url);
	}
}
Exemplo n.º 20
0
static void gfire_sq_gamespy2_free_server(gfire_game_server *p_server)
{
	if(p_server->data && p_server->data->proto_data)
	{
		gfire_sq_gamespy2_data *data = (gfire_sq_gamespy2_data*)p_server->data->proto_data;

		g_datalist_clear(&data->info);

		while(data->players)
		{
			gfire_sq_gamespy2_player *player = (gfire_sq_gamespy2_player*)data->players->data;
			g_free(player->name);
			g_free(player);

			data->players = g_slist_delete_link(data->players, data->players);
		}

		g_free(data);
	}
}
Exemplo n.º 21
0
static void
ec_target_free(EImport *ep, EImportTarget *t)
{
	switch (t->type) {
	case E_IMPORT_TARGET_URI: {
		EImportTargetURI *s = (EImportTargetURI *)t;

		g_free(s->uri_src);
		g_free(s->uri_dest);
		break; }
	case E_IMPORT_TARGET_HOME: {
		EImportTargetHome *s = (EImportTargetHome *)t;

		g_free(s->homedir);
		break; }
	}

	g_datalist_clear(&t->data);
	g_free(t);
	g_object_unref(ep);
}
Exemplo n.º 22
0
gboolean qq_im_smiley_none(const gchar *msg)
{
	const gchar *start, *end, *last;
	GData *attribs;
	gchar *tmp;
	gboolean ret = FALSE;

	g_return_val_if_fail(msg != NULL, TRUE);

	last = msg;
	while (purple_markup_find_tag("font", last, &start, &end, &attribs)) {
		tmp = g_datalist_get_data(&attribs, "sml");
		if (tmp && strlen(tmp) > 0) {
			if (strcmp(tmp, "none") == 0) {
				ret = TRUE;
				break;
			}
		}
		g_datalist_clear(&attribs);
		last = end + 1;
	}
	return ret;
}
Exemplo n.º 23
0
int        S57_doneData   (_S57_geo *geoData, gpointer user_data)
{
    // quiet line overlap analysis that trigger a bunch of harmless warning
    if (NULL!=user_data && NULL==geoData)
        return FALSE;

#ifdef S52_USE_WORLD
    {
        S57_geo *geoDataNext = NULL;
        if (NULL != (geoDataNext = S57_getNextPoly(geoData))) {
            S57_doneData(geoDataNext, user_data);
        }
    }
#endif


#ifndef S52_USE_GV
    // data from OGR is a copy --so this need to be deleted
    _doneGeoData(geoData);
#endif

    S57_donePrimGeo(geoData);

    if (NULL != geoData->name)
        g_string_free(geoData->name, TRUE);

    if (NULL != geoData->attribs)
        g_datalist_clear(&geoData->attribs);

    if (NULL != geoData->centroid)
        g_array_free(geoData->centroid, TRUE);

    g_free(geoData);

    return TRUE;
}
Exemplo n.º 24
0
static gboolean
crank_composite_def_remove_compositable (CrankComposite     *composite,
                                         CrankCompositable  *compositable,
                                         GError            **error)
{
  CrankCompositePrivate *priv = crank_composite_get_instance_private (composite);
  gint i = crank_composite_index_of_compositable (composite, compositable);

  // First check a compositable exists.
  if (i == -1)
    {
      g_set_error (error, CRANK_COMPOSITE_ERROR,
                   CRANK_COMPOSITE_ERROR_NOT_HAVE_COMPOSITABLE,
                   "Compositable is not in the compositable.\n"
                   "%s@%p <= %s@%p",
                   G_OBJECT_TYPE_NAME (composite), composite,
                   G_OBJECT_TYPE_NAME (compositable), compositable);
      return FALSE;
    }

  // Do adding
  else if (crank_compositable_removing (compositable, composite, error))
    {
      Percompositable *percompositable =
          & g_array_index (priv->data, Percompositable, i);

      g_datalist_clear (& percompositable->dictionary);
      g_object_unref (compositable);

      g_array_remove_index (priv->data, i);
      g_object_notify_by_pspec ((GObject*)composite, pspecs[PROP_NCOMPOSITABLES]);
      return TRUE;
    }

  return FALSE;
}
Exemplo n.º 25
0
Arquivo: scripts.c Projeto: IR4T4/xqf
void scripts_done() {
	g_datalist_clear(&scriptdata);
}
Exemplo n.º 26
0
int PurpleLine::send_message(std::string to, const char *markup) {
    // Parse markup and send message as parts if it contains images

    bool any_sent = false;
	std::cout << "debug ---> " << std::endl;
	std::cout << to << std::endl;
	std::cout << markup << std::endl;

    for (const char *p = markup; p && *p; ) {
        const char *start, *end;
		const char *filestart, *fileend;
        GData *attributes;
		GData *fileattributes;

		std::cout << "Sending LINE Message..." << std::endl;
        bool img_found = purple_markup_find_tag("IMG", p, &start, &end, &attributes);
		bool imgfile_found = purple_markup_find_tag("FILE", p, &filestart, &fileend, &fileattributes);
		std::cout << "---Image file ? " << std::endl;
		std::cout << img_found << std::endl;
		std::cout << imgfile_found << std::endl;

        std::string text;

        if (img_found) {
            // Image found but there's text before it, store it

            text = std::string(p, start - p);
            p = end + 1;
        } else {
            // No image found, store the rest of the text

            text = std::string(p);

            // Break the loop

            p = NULL;
        }

        // If the text is not all whitespace, send it as a text message
        if (text.find_first_not_of("\t\n\r ") != std::string::npos && !imgfile_found)
        {
            line::Message msg;

            msg.contentType = line::ContentType::NONE;
            msg.from = profile.mid;
            msg.to = to;
            msg.text = markup_unescape(text);

            send_message(msg);

            any_sent = true;
        }

		if (imgfile_found) {
			std::cout << "Start upload file!!" << std::endl;
			char *path = (char *)g_datalist_get_data(&fileattributes, "path");
			std::cout << path << std::endl;

			gchar *data = NULL;
			size_t len;
			GError *err = NULL;

			if (!g_file_get_contents(path, &data, &len, &err))
			{
				std::cout << "Error get file contents!!" << std::endl;
				continue;
			}
			std::cout << "Success get file content!!" << std::endl;

			PurpleStoredImage *img =
				purple_imgstore_add(data, len, path);
			if (!img)
			{
				std::cout << "Error image stored add!!" << std::endl;
				continue;
			}
			std::cout << "Success image stored add!!" << std::endl;
			std::string img_data(
					(const char *)purple_imgstore_get_data(img),
					purple_imgstore_get_size(img));

            line::Message msg;
            msg.contentType = line::ContentType::IMAGE;
            msg.from = profile.mid;
            msg.to = to;

			send_message(msg, [this, img_data](line::Message &msg_back) {
				upload_media(msg_back.id, "image", img_data);
			});

            any_sent = true;
		}

        if (img_found) {
            // Image test

            int image_id = std::stoi((char *)g_datalist_get_data(&attributes, "id"));
            g_datalist_clear(&attributes);

            std::stringstream ss;
            ss << "(img ID: " << image_id << ")";

            PurpleStoredImage *img = purple_imgstore_find_by_id(image_id);
            if (!img) {
                purple_debug_warning("line", "Tried to send non-existent image: %d\n", image_id);
                continue;
            }

            std::string img_data(
                (const char *)purple_imgstore_get_data(img),
                purple_imgstore_get_size(img));

            line::Message msg;

            msg.contentType = line::ContentType::IMAGE;
            msg.from = profile.mid;
            msg.to = to;

            send_message(msg, [this, img_data](line::Message &msg_back) {
                upload_media(msg_back.id, "image", img_data);
            });

            any_sent = true;
        }
    }

    return any_sent ? 1 : 0;
}
Exemplo n.º 27
0
SilcDList silcpurple_image_message(const char *msg, SilcMessageFlags *mflags)
{
	SilcMime mime = NULL, p;
	SilcDList list, parts = NULL;
	const char *start, *end, *last;
	GData *attribs;
	char *type;
	gboolean images = FALSE;

	last = msg;
	while (last && *last && purple_markup_find_tag("img", last, &start,
						     &end, &attribs)) {
		PurpleStoredImage *image = NULL;
		const char *id;

		/* Check if there is text before image */
		if (start - last) {
			char *text, *tmp;
			p = silc_mime_alloc();

			/* Add content type */
			silc_mime_add_field(p, "Content-Type",
					    "text/plain; charset=utf-8");

			tmp = g_strndup(last, start - last);
			text = purple_unescape_html(tmp);
			g_free(tmp);

			/* Add text */
			silc_mime_add_data(p, (const unsigned char *)text, strlen(text));
			g_free(text);

			if (!parts)
				parts = silc_dlist_init();
			silc_dlist_add(parts, p);
		}

		id = g_datalist_get_data(&attribs, "id");
		if (id && (image = purple_imgstore_find_by_id(atoi(id)))) {
			unsigned long imglen = purple_imgstore_get_size(image);
			gconstpointer img = purple_imgstore_get_data(image);

			p = silc_mime_alloc();

			/* Add content type */
			type = silcpurple_file2mime(purple_imgstore_get_filename(image));
			if (!type) {
				g_datalist_clear(&attribs);
				last = end + 1;
				continue;
			}
			silc_mime_add_field(p, "Content-Type", type);
			g_free(type);

			/* Add content transfer encoding */
			silc_mime_add_field(p, "Content-Transfer-Encoding", "binary");

			/* Add image data */
			silc_mime_add_data(p, img, imglen);

			if (!parts)
				parts = silc_dlist_init();
			silc_dlist_add(parts, p);
			images = TRUE;
		}

		g_datalist_clear(&attribs);

		/* Continue after tag */
		last = end + 1;
	}

	/* Check for text after the image(s) */
	if (images && last && *last) {
		char *tmp = purple_unescape_html(last);
		p = silc_mime_alloc();

		/* Add content type */
		silc_mime_add_field(p, "Content-Type",
				    "text/plain; charset=utf-8");

		/* Add text */
		silc_mime_add_data(p, (const unsigned char *)tmp, strlen(tmp));
		g_free(tmp);

		if (!parts)
			parts = silc_dlist_init();
		silc_dlist_add(parts, p);
	}

	/* If there weren't any images, don't return anything. */
	if (!images) {
		if (parts)
			silc_dlist_uninit(parts);
		return NULL;
	}

	if (silc_dlist_count(parts) > 1) {
		/* Multipart MIME message */
		char b[32];
		mime = silc_mime_alloc();
		silc_mime_add_field(mime, "MIME-Version", "1.0");
		g_snprintf(b, sizeof(b), "b%4X%4X",
			   (unsigned int)time(NULL),
			   silc_dlist_count(parts));
		silc_mime_set_multipart(mime, "mixed", b);
		silc_dlist_start(parts);
		while ((p = silc_dlist_get(parts)) != SILC_LIST_END)
			silc_mime_add_multipart(mime, p);
	} else {
		/* Simple MIME message */
		silc_dlist_start(parts);
		mime = silc_dlist_get(parts);
		silc_mime_add_field(mime, "MIME-Version", "1.0");
	}

	*mflags &= ~SILC_MESSAGE_FLAG_UTF8;
	*mflags |= SILC_MESSAGE_FLAG_DATA;

	/* Encode message. Fragment if it is too large */
	list = silc_mime_encode_partial(mime, 0xfc00);

	silc_dlist_uninit(parts);

	/* Added multiparts gets freed here */
	silc_mime_free(mime);

	return list;
}
Exemplo n.º 28
0
void
qipu_destroy (qipu_t *qipu)
{
  g_datalist_clear (&qipu->tv_list);
  free (qipu);
}