Ejemplo n.º 1
0
MsnObject *
msn_object_new_from_string(const gchar *str)
{
    MsnObject *obj;
    gchar *tag, *c;

    g_return_val_if_fail(str != NULL, NULL);

    if (strncmp(str, "<msnobj ", 8))
        return NULL;

    obj = msn_object_new();

    GET_STRING_TAG(creator,  "Creator");
    GET_INT_TAG(size,        "Size");
    GET_INT_TAG(type,        "Type");
    GET_STRING_TAG(location, "Location");
    GET_STRING_TAG(friendly, "Friendly");
    GET_STRING_TAG(sha1d,    "SHA1D");
    GET_STRING_TAG(sha1c,    "SHA1C");

    /* If we are missing any of the required elements then discard the object */
    /* SHA1C is not always sent anymore */
    if (obj->creator == NULL || obj->size == 0 || obj->type == 0
        || obj->location == NULL || obj->friendly == NULL
        || obj->sha1d == NULL /*|| obj->sha1c == NULL*/) {
        pecan_error ("discarding: str=[%s]", str);
        msn_object_destroy(obj);
        obj = NULL;
    }

    return obj;
}
Ejemplo n.º 2
0
MsnObject *
msn_object_new_from_string(const char *str)
{
	MsnObject *obj;
	char *tag, *c;

	g_return_val_if_fail(str != NULL, NULL);

	if (strncmp(str, "<msnobj ", 8))
		return NULL;

	obj = msn_object_new();

	GET_STRING_TAG(creator,  "Creator");
	GET_INT_TAG(size,        "Size");
	GET_INT_TAG(type,        "Type");
	GET_STRING_TAG(location, "Location");
	GET_STRING_TAG(friendly, "Friendly");
	GET_STRING_TAG(sha1d,    "SHA1D");
	GET_STRING_TAG(sha1c,    "SHA1C");
	GET_STRING_TAG(url,      "Url");
	GET_STRING_TAG(url1,     "Url1");

	/* If we are missing any of the required elements then discard the object */
	if (obj->creator == NULL || obj->size == 0 || obj->type == 0
	 || obj->sha1d == NULL) {
		purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
		msn_object_destroy(obj, FALSE);
		return NULL;
	}

	if (obj->location == NULL || obj->friendly == NULL) {
		/* Location/friendly are required for non-buddyicon objects */
		if (obj->type != MSN_OBJECT_USERTILE) {
			purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
			msn_object_destroy(obj, FALSE);
			return NULL;
		/* Buddy icon object can contain Url/Url1 instead */
		} else if (obj->url == NULL || obj->url1 == NULL) {
			purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str);
			msn_object_destroy(obj, FALSE);
			return NULL;
		}
	}

	return obj;
}