Exemplo n.º 1
0
static void
facebook_photo_finalize (GObject *obj)
{
	FacebookPhoto *self;

	self = FACEBOOK_PHOTO (obj);

	g_free (self->id);
	g_free (self->secret);
	g_free (self->server);
	g_free (self->title);

	G_OBJECT_CLASS (facebook_photo_parent_class)->finalize (obj);
}
Exemplo n.º 2
0
static void
facebook_photo_finalize (GObject *obj)
{
    FacebookPhoto *self;

    self = FACEBOOK_PHOTO (obj);

    g_free (self->id);
    g_free (self->picture);
    g_free (self->source);
    g_free (self->link);
    gth_datetime_free (self->created_time);
    gth_datetime_free (self->updated_time);
    facebook_image_list_free (self->images);

    G_OBJECT_CLASS (facebook_photo_parent_class)->finalize (obj);
}
Exemplo n.º 3
0
static void
facebook_photo_set_property (GObject      *object,
                             guint         property_id,
                             const GValue *value,
                             GParamSpec   *pspec)
{
    FacebookPhoto *self;

    self = FACEBOOK_PHOTO (object);

    switch (property_id) {
    case PROP_ID:
        _g_strset (&self->id, g_value_get_string (value));
        break;
    case PROP_PICTURE:
        _g_strset (&self->picture, g_value_get_string (value));
        break;
    case PROP_SOURCE:
        _g_strset (&self->source, g_value_get_string (value));
        break;
    case PROP_WIDTH:
        self->width = g_value_get_int (value);
        break;
    case PROP_HEIGHT:
        self->height = g_value_get_int (value);
        break;
    case PROP_LINK:
        _g_strset (&self->link, g_value_get_string (value));
        break;
    case PROP_CREATED_TIME:
        gth_datetime_free (self->created_time);
        self->created_time = g_value_dup_boxed (value);
        break;
    case PROP_UPDATED_TIME:
        gth_datetime_free (self->updated_time);
        self->updated_time = g_value_dup_boxed (value);
        break;
    case PROP_IMAGES:
        facebook_image_list_free (self->images);
        self->images = g_value_dup_boxed (value);
        break;
    default:
        break;
    }
}
Exemplo n.º 4
0
static void
facebook_photo_get_property (GObject    *object,
                             guint       property_id,
                             GValue     *value,
                             GParamSpec *pspec)
{
    FacebookPhoto *self;

    self = FACEBOOK_PHOTO (object);

    switch (property_id) {
    case PROP_ID:
        g_value_set_string (value, self->id);
        break;
    case PROP_PICTURE:
        g_value_set_string (value, self->picture);
        break;
    case PROP_SOURCE:
        g_value_set_string (value, self->source);
        break;
    case PROP_WIDTH:
        g_value_set_int (value, self->width);
        break;
    case PROP_HEIGHT:
        g_value_set_int (value, self->height);
        break;
    case PROP_LINK:
        g_value_set_string (value, self->link);
        break;
    case PROP_CREATED_TIME:
        g_value_set_boxed (value, self->created_time);
        break;
    case PROP_UPDATED_TIME:
        g_value_set_boxed (value, self->updated_time);
        break;
    case PROP_IMAGES:
        g_value_set_boxed (value, self->images);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;
    }
}
Exemplo n.º 5
0
static void
facebook_photo_load_from_element (DomDomizable *base,
				DomElement   *element)
{
	FacebookPhoto *self;

	if ((element == NULL) || (g_strcmp0 (element->tag_name, "photo") != 0))
		return;

	self = FACEBOOK_PHOTO (base);

	facebook_photo_set_id (self, dom_element_get_attribute (element, "id"));
	facebook_photo_set_secret (self, dom_element_get_attribute (element, "secret"));
	facebook_photo_set_server (self, dom_element_get_attribute (element, "server"));
	facebook_photo_set_title (self, dom_element_get_attribute (element, "title"));
	facebook_photo_set_is_primary (self, dom_element_get_attribute (element, "isprimary"));
	facebook_photo_set_url_sq (self, dom_element_get_attribute (element, "url_sq"));
	facebook_photo_set_url_t (self, dom_element_get_attribute (element, "url_t"));
	facebook_photo_set_url_s (self, dom_element_get_attribute (element, "url_s"));
	facebook_photo_set_url_m (self, dom_element_get_attribute (element, "url_m"));
	facebook_photo_set_url_o (self, dom_element_get_attribute (element, "url_o"));
}
Exemplo n.º 6
0
static DomElement*
facebook_photo_create_element (DomDomizable *base,
				DomDocument  *doc)
{
	FacebookPhoto *self;
	DomElement  *element;

	self = FACEBOOK_PHOTO (base);

	element = dom_document_create_element (doc, "photo", NULL);
	if (self->id != NULL)
		dom_element_set_attribute (element, "id", self->id);
	if (self->secret != NULL)
		dom_element_set_attribute (element, "secret", self->secret);
	if (self->server != NULL)
		dom_element_set_attribute (element, "server", self->server);
	if (self->title != NULL)
		dom_element_set_attribute (element, "title", self->title);
	if (self->is_primary)
		dom_element_set_attribute (element, "isprimary", "1");

	return element;
}
Exemplo n.º 7
0
static gboolean
facebook_photo_deserialize_property (JsonSerializable *serializable,
                                     const gchar      *property_name,
                                     GValue           *value,
                                     GParamSpec       *pspec,
                                     JsonNode         *property_node)
{
    FacebookPhoto *self = FACEBOOK_PHOTO (serializable);

    if (pspec->value_type == GTH_TYPE_DATETIME) {
        GTimeVal timeval;

        if (g_time_val_from_iso8601 (json_node_get_string (property_node), &timeval)) {
            GthDateTime *datetime;

            datetime = gth_datetime_new ();
            gth_datetime_from_timeval (datetime, &timeval);
            g_object_set (self, property_name, datetime, NULL);

            gth_datetime_free (datetime);

            return TRUE;
        }

        return FALSE;
    }

    if (pspec->value_type == FACEBOOK_TYPE_IMAGE_LIST) {
        GList     *images = NULL;
        JsonArray *array;
        int        i;

        array = json_node_get_array (property_node);
        for (i = 0; i < json_array_get_length (array); i++) {
            JsonObject *image_obj;

            image_obj = json_array_get_object_element (array, i);
            if (image_obj != NULL) {
                FacebookImage *image;

                image = facebook_image_new ();
                _g_strset (&image->source, json_object_get_string_member (image_obj, "source"));
                image->width = json_object_get_int_member (image_obj, "width");
                image->height = json_object_get_int_member (image_obj, "height");

                images = g_list_prepend (images, image);
            }
        }

        images = g_list_reverse (images);
        g_object_set (self, property_name, images, NULL);

        facebook_image_list_free (images);

        return TRUE;
    }

    return json_serializable_default_deserialize_property (serializable,
            property_name,
            value,
            pspec,
            property_node);
}