Ejemplo n.º 1
0
LassoDiscoInsertEntry*
lasso_disco_insert_entry_new(LassoDiscoResourceOffering *resourceOffering)
{
	LassoDiscoInsertEntry *insertEntry;

	g_return_val_if_fail(LASSO_IS_DISCO_RESOURCE_OFFERING(resourceOffering) == TRUE, NULL);

	insertEntry = g_object_new(LASSO_TYPE_DISCO_INSERT_ENTRY, NULL);
	lasso_assign_gobject(insertEntry->ResourceOffering, resourceOffering);

	return insertEntry;
}
Ejemplo n.º 2
0
/**
 * lasso_identity_add_resource_offering:
 * @identity: a #LassoIdentity object
 * @offering: a #LassoDiscoResourceOffering object to add
 *
 * Add a new offering to the identity object to be retrieved later by
 * lasso_identity_get_offerings() or lasso_identity_get_resource_offering().
 * It also allocate an entryId identifier for the offering, look into
 * offering->entryID to get it after this call.
 *
 * Return value: Always 0, there should not be any error (if memory is not exhausted).
 */
gint
lasso_identity_add_resource_offering(LassoIdentity *identity,
		LassoDiscoResourceOffering *offering)
{
	char entry_id_s[20];

	g_return_val_if_fail(LASSO_IS_IDENTITY(identity), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
	g_return_val_if_fail(LASSO_IS_DISCO_RESOURCE_OFFERING(offering),
		LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);

	do {
		g_snprintf(entry_id_s, 18, "%d", identity->private_data->last_entry_id);
		identity->private_data->last_entry_id++;
	} while (g_hash_table_lookup(identity->private_data->resource_offerings_map, entry_id_s));
	lasso_assign_string(offering->entryID, entry_id_s);
	g_hash_table_insert(identity->private_data->resource_offerings_map,
		g_strdup(offering->entryID), g_object_ref(offering));
	identity->is_dirty = TRUE;

	return 0;
}