示例#1
0
END_TEST

static void _metadatas_cb(MafwSource *self, GHashTable *metadatas,
                          gboolean error_state, const GError *error)
{
    GHashTable *cur_md;
    GValue *val;
    fail_if(g_hash_table_size(metadatas) != 2);
    cur_md = g_hash_table_lookup(metadatas, "testobject");
    fail_if(!cur_md);
    fail_if(g_hash_table_size(cur_md) != 1);
    val = mafw_metadata_first(cur_md, "title");
    fail_if(val == NULL);
    cur_md = g_hash_table_lookup(metadatas, "testobject1");
    fail_if(!cur_md);
    fail_if(g_hash_table_size(cur_md) != 1);
    val = mafw_metadata_first(cur_md, "title");
    fail_if(val == NULL);
    if (!error_state)
    {
        fail_if(error != NULL);
    }
    else
    {
        fail_if(error == NULL);
        fail_if(error->code != 10);
        fail_if(strcmp(error->message, METADATAS_ERROR_MSG) != 0);
    }
}
void SinglePlaylistView::setItemMetadata(QStandardItem *item, QString objectId, GHashTable *metadata)
{
    if (metadata != NULL) {
        GValue *v;

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_TITLE);
        QString title = v ? QString::fromUtf8(g_value_get_string (v)) : tr("(unknown song)");

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_ARTIST);
        QString artist = v ? QString::fromUtf8(g_value_get_string(v)) : tr("(unknown artist)");

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_ALBUM);
        QString album = v ? QString::fromUtf8(g_value_get_string(v)) : tr("(unknown album)");

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_DURATION);
        int duration = v ? g_value_get_int (v) : Duration::Unknown;

        item->setText(title);
        item->setData(duration, UserRoleSongDuration);
        item->setData(album, UserRoleSongAlbum);
        item->setData(artist, UserRoleSongArtist);
        item->setData(objectId, UserRoleObjectID);
        item->setData(QString(title % QChar(31) % artist % QChar(31) % album), UserRoleFilterString);

    } else {
        item->setText(tr("Information not available"));
        item->setData(Duration::Blank, UserRoleSongDuration);
    }
}
示例#3
0
void SingleGenreView::browseAllGenres(uint browseId, int remainingCount, uint, QString objectId, GHashTable* metadata, QString error)
{
    if (browseId != browseGenreId) return;

    if (metadata != NULL) {
        QString title;
        int songCount = -1;
        int albumCount = -1;
        GValue *v;

        QStandardItem *item = new QStandardItem();

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_TITLE);
        title = v ? QString::fromUtf8(g_value_get_string(v)) : tr("(unknown artist)");

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_CHILDCOUNT_1);
        albumCount = v ? g_value_get_int (v) : -1;

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_CHILDCOUNT_2);
        songCount = v ? g_value_get_int (v) : -1;

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_ALBUM_ART_SMALL_URI);
        if (v != NULL) {
            const gchar* file_uri = g_value_get_string(v);
            gchar* filename = NULL;
            if (file_uri != NULL && (filename = g_filename_from_uri(file_uri, NULL, NULL)) != NULL)
                item->setIcon(QIcon(QString::fromUtf8(filename)));
        } else {
            item->setIcon(QIcon::fromTheme(defaultAlbumIcon));
        }

        if (title.isEmpty()) title = tr("(unknown artist)");

        item->setText(title);
        item->setData(songCount, UserRoleSongCount);
        item->setData(albumCount, UserRoleAlbumCount);
        item->setData(objectId, UserRoleObjectID);

        objectModel->appendRow(item);
        visibleSongs += songCount; updateSongCount();

    }

    if (!error.isEmpty())
        qDebug() << error;

    if (remainingCount == 0) {
        disconnect(mafwTrackerSource, SIGNAL(browseResult(uint,int,uint,QString,GHashTable*,QString)),
                   this, SLOT(browseAllGenres(uint,int,uint,QString,GHashTable*,QString)));
        setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
    }
示例#4
0
static void metadata_result(MafwSource *self, const gchar *object_id,
                            GHashTable *md, gpointer user_data,
                            const GError *error)
{
    GValue *v;

    fail_if(strcmp(object_id, SOURCE_UUID "::wherever"));
    fail_unless(md != NULL);
    v = mafw_metadata_first(md, "title");
    fail_if(strcmp(g_value_get_string(v), "Less than you"));
    v = mafw_metadata_first(md, "album");
    fail_if(strcmp(g_value_get_string(v), "Loudry service"));
    *(gboolean *)user_data = TRUE;
}
示例#5
0
static void get_metadata_cb(MafwSource* source, const gchar *objectid,
			    GHashTable *metadata, gpointer user_data,
			    const GError *error)
{
	/* Validate what we got. */
	fail_if(source != Source);
	fail_if(GPOINTER_TO_UINT(user_data) != 42);

	if (error != NULL)
	{
		fail_if(strcmp(objectid, "SOURCE::bar") != 0);
		fail_if(metadata != NULL);
		fail_if(error->domain != MAFW_RENDERER_ERROR);
		fail_if(error->code != MAFW_RENDERER_ERROR_NO_MEDIA);
		fail_if(strcmp(error->message, "Just nyt ei pysty") != 0);
	}
	else
	{
		GValue* val;
		val = mafw_metadata_first(metadata, "uri");

		fail_if(strcmp(objectid, "SOURCE::foo") != 0);
		fail_if(strcmp(g_value_get_string(val), "boo") != 0);
	}
}
static void _add_playlist_duration_cb(MafwSource *self,
				      guint browse_id,
				      gint remaining_count,
				      guint index,
				      const gchar *object_id,
				      GHashTable *metadata,
				      gpointer user_data,
				      const GError *error)
{
	GValue *gval = NULL;
        gint pls_duration;

	struct _metadatas_closure *pls_mc =
		(struct _metadatas_closure *) user_data;

	/* Get the calculated duration and add it to the results. */
	if (!error && metadata) {
		gval = mafw_metadata_first(
			metadata,
			MAFW_METADATA_KEY_DURATION);

		if (gval) {
			pls_duration = 	g_value_get_int(gval);

			gval = mafw_metadata_first(
				pls_mc->metadata_value,
				MAFW_METADATA_KEY_DURATION);

			if (gval) {
				g_value_set_int(gval, pls_duration);
			} else {
				mafw_metadata_add_int(
                                        pls_mc->metadata_value,
                                        MAFW_METADATA_KEY_DURATION,
                                        pls_duration);
			}
		}
	}

	_get_metadata_tracker_cb(pls_mc->metadata_value, (GError *) error,
				 user_data);

	mafw_metadata_release(metadata);
}
示例#7
0
void test_didl_container_cb(GUPnPDIDLLiteParser* parser, GUPnPDIDLLiteObject* didlobject,
			    gpointer user_data)
{
	gchar* value;
	gint num;
	xmlNode* res_node;
	GHashTable *mdata = mafw_metadata_new();
	GValue *val;
	GList *resources;

	fail_if(didlobject == NULL, "GUPnP is %s", "broken");

	didl_get_mimetype(mdata, TRUE, TRUE, resources);
	val = mafw_metadata_first(mdata, MAFW_METADATA_KEY_MIME);
	fail_if(val == NULL);
	fail_if(strcmp(g_value_get_string(val), MAFW_METADATA_VALUE_MIME_CONTAINER) != 0,
		"Wrong MIME for container: %s", value);

	resources = didl_get_supported_resources(didlobject);
	fail_if(resources == NULL || resources->data == NULL,
				"Unable to get a resource node");
	fail_if(g_list_length(resources) != 1, "Resource list not correct");
}
示例#8
0
void test_didl_item_cb(GUPnPDIDLLiteParser* parser, 
		       GUPnPDIDLLiteObject* didlobject,
		       gpointer user_data)
{
	GList *resources;
	GUPnPDIDLLiteResource* res_node;
	gchar* value;
	gint type;
	gint num;
	GHashTable *mdata = mafw_metadata_new();
	GValue *val;
	gboolean is_audio, is_supported = FALSE;
	MafwUPnPSource* source;

	fail_if(didlobject == NULL, "GUPnP is %s", "broken");
	
	source = MAFW_UPNP_SOURCE(mafw_upnp_source_new("name", "uuid"));
	g_assert(source != NULL);

	value= util_create_objectid(source, didlobject);
	fail_unless(strcmp(value, "uuid::18132") == 0, "Wrong object ID");
	g_free(value);
	g_object_unref(source);

	/* Protocol info stuff */
	resources = didl_get_supported_resources(didlobject);
	fail_if(resources == NULL || resources->data == NULL,
				"Unable to get a resource node");
	fail_if(g_list_length(resources) != 1, "Resource list not correct");
	
	res_node = resources->data;

	/* Properties */
	
	is_audio = didl_check_filetype(didlobject, &is_supported);
	
	fail_if(is_audio == FALSE, "Item should be audio");
	fail_if(is_supported == FALSE, "Item should be supported");
	
	didl_get_mimetype(mdata, FALSE, TRUE, resources);
	val = mafw_metadata_first(mdata, MAFW_METADATA_KEY_MIME);
	fail_if(val == NULL);
	fail_if(strcmp(g_value_get_string(val), "audio/mpeg") != 0, "Wrong MIME: %s", value);


	didl_get_http_res_uri(mdata, resources, TRUE);
	val = mafw_metadata_first(mdata, MAFW_METADATA_KEY_URI);
	fail_if(strcmp(g_value_get_string(val),
		       "http://172.23.117.242:9000/disk/music/O18132.mp3") != 0,
		"Wrong URI: %s", g_value_get_string(val));
	
	/* Fallbacks */
	type = 0;
	value = didl_fallback(didlobject, res_node, 7, &type);
	fail_if(strcmp(value, "http://foo.bar.com:31337/lyrics.txt") != 0,
		"Wrong lyrics URI: %s", value);
	fail_if(type != G_TYPE_STRING, "Wrong type");
	g_free(value);
	
	type = 0;
	value = didl_fallback(didlobject, res_node, 9, &type);
	fail_if(strcmp(value, "http://foo.bar.com:31337/albumArt.png") != 0,
		"Wrong small album art URI: %s", value);
	fail_if(type != G_TYPE_STRING, "Wrong type");
	g_free(value);

	type = 0;
	value = didl_fallback(didlobject, res_node, 10, &type);
	fail_if(strcmp(value, "http://foo.bar.com:31337/albumArt.png") != 0,
		"Wrong medium album art URI: %s", value);
	fail_if(type != G_TYPE_STRING, "Wrong type");
	g_free(value);

	type = 0;
	value = didl_fallback(didlobject, res_node, 11, &type);
	fail_if(strcmp(value, "http://foo.bar.com:31337/albumArt.png") != 0,
		"Wrong large album art URI: %s", value);
	fail_if(type != G_TYPE_STRING, "Wrong type");
	g_free(value);

	type = 0;
	value = didl_fallback(didlobject, res_node, 12, &type);
	fail_if(strcmp(value, "http://foo.bar.com:31337/disco.html") != 0,
		"Wrong artist info URI: %s", value);
	fail_if(type != G_TYPE_STRING, "Wrong type");
	g_free(value);

	type = 0;
	value = didl_fallback(didlobject, res_node, 13, &type);
	fail_if(strcmp(value, "31337") != 0,
		"Wrong audio bitrate: %s", value);
	fail_if(type != G_TYPE_INT, "Wrong type");
	g_free(value);
	
	type = 0;
	value = didl_fallback(didlobject, res_node, 14, &type);
	fail_if(strcmp(value, "31337") != 0,
		"Wrong video bitrate: %s", value);
	fail_if(type != G_TYPE_INT, "Wrong type");
	g_free(value);

	type = 0;
	value = didl_fallback(didlobject, res_node, 17, &type);
	fail_if(strcmp(value, "32") != 0, "Wrong BPP: %s", value);
	fail_if(type != G_TYPE_INT, "Wrong type");
	g_free(value);
}
示例#9
0
void VideosWindow::browseAllVideos(uint browseId, int remainingCount, uint index, QString objectId, GHashTable *metadata)
{
    if (this->browseId != browseId) return;

    if (index == 0) {
        recordingsBufferList.clear();
        filmsBufferList.clear();

        if (sortByDate->isChecked()) {
            int delta = remainingCount+1 - objectModel->rowCount();
            if (delta > 0)
                for (int i = 0; i < delta; i++)
                    objectModel->appendRow(new QStandardItem());
            else
                for (int i = delta; i < 0; i++)
                    objectModel->removeRow(objectModel->rowCount()-1);
        }
    }

    if (metadata != NULL) {
        GValue *v;

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_TITLE);
        QString title = v ? QString::fromUtf8(g_value_get_string (v)) : tr("(unknown clip)");

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_VIDEO_SOURCE);
        QString source = v ? QString::fromUtf8(g_value_get_string (v)) : QString();

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_DURATION);
        int duration = v ? g_value_get_int (v) : Duration::Unknown;

        QStandardItem *item = sortByCategory->isChecked() ? new QStandardItem() : objectModel->item(index);

        v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_PAUSED_THUMBNAIL_URI);
        if (v != NULL) {
            const gchar* filename = g_value_get_string(v); // the uri is really a filename
            if (filename != NULL)
                item->setIcon(QIcon(QString::fromUtf8(filename)));
        } else {
            v = mafw_metadata_first(metadata, MAFW_METADATA_KEY_THUMBNAIL_URI);
            if (v != NULL) {
                const gchar* file_uri = g_value_get_string(v); // here uri is a uri
                gchar* filename;
                if (file_uri != NULL && (filename = g_filename_from_uri(file_uri, NULL, NULL)) != NULL)
                    item->setIcon(QIcon(QString::fromUtf8(filename)));
            } else {
                item->setIcon(QIcon::fromTheme(defaultVideoIcon));
            }
        }

        item->setData(objectId, UserRoleObjectID);
        item->setData(title, UserRoleTitle);

        if (sortByCategory->isChecked()) {
            item->setData(duration, UserRoleSongDuration);
            (source.startsWith("noki://") ? recordingsBufferList : filmsBufferList).append(item);
        }
        else { // sortByDate->isChecked()
            if (duration != Duration::Unknown) {
                QTime t(0, 0);
                t = t.addSecs(duration);
                item->setData(t.toString("h:mm:ss"), UserRoleValueText);
            } else
                item->setData("-:--:--", UserRoleValueText);
        }
    }

    if (remainingCount == 0) {
        disconnect(mafwTrackerSource, SIGNAL(browseResult(uint,int,uint,QString,GHashTable*,QString)),
                   this, SLOT(browseAllVideos(uint,int,uint,QString,GHashTable*)));

        if (sortByCategory->isChecked()) {
            bool drawHeaders = !recordingsBufferList.isEmpty() && !filmsBufferList.isEmpty();
            int delta = recordingsBufferList.size() + filmsBufferList.size() - objectModel->rowCount();
            if (drawHeaders) delta += 2;

            if (delta > 0)
                for (int i = 0; i < delta; i++)
                    objectModel->appendRow(new QStandardItem());
            else
                for (int i = delta; i < 0; i++)
                    objectModel->removeRow(objectModel->rowCount()-1);

            int i = 0;

            if (!recordingsBufferList.isEmpty()) {
                if (drawHeaders) {
                    objectModel->item(i)->setData(true, UserRoleHeader);
                    objectModel->item(i)->setData(tr("Recorded by device camera"), UserRoleTitle);
                    objectModel->item(i)->setData(Duration::Blank, UserRoleSongDuration);
                    ++i;
                }

                while (!recordingsBufferList.isEmpty()) {
                    objectModel->item(i)->setData(false, UserRoleHeader);
                    objectModel->item(i)->setData(recordingsBufferList.first()->data(UserRoleTitle), UserRoleTitle);
                    objectModel->item(i)->setData(recordingsBufferList.first()->data(UserRoleObjectID), UserRoleObjectID);
                    objectModel->item(i)->setData(recordingsBufferList.first()->data(UserRoleSongDuration), UserRoleSongDuration);
                    objectModel->item(i)->setIcon(recordingsBufferList.first()->icon());
                    delete recordingsBufferList.takeFirst();
                    ++i;
                }
            }

            if (!filmsBufferList.isEmpty()) {
                if (drawHeaders) {
                    objectModel->item(i)->setData(true, UserRoleHeader);
                    objectModel->item(i)->setData(tr("Films"), UserRoleTitle);
                    objectModel->item(i)->setData(Duration::Blank, UserRoleSongDuration);
                    ++i;
                }

                while (!filmsBufferList.isEmpty()) {
                    objectModel->item(i)->setData(false, UserRoleHeader);
                    objectModel->item(i)->setData(filmsBufferList.first()->data(UserRoleTitle), UserRoleTitle);
                    objectModel->item(i)->setData(filmsBufferList.first()->data(UserRoleObjectID), UserRoleObjectID);
                    objectModel->item(i)->setData(filmsBufferList.first()->data(UserRoleSongDuration), UserRoleSongDuration);
                    objectModel->item(i)->setIcon(filmsBufferList.first()->icon());
                    delete filmsBufferList.takeFirst();
                    ++i;
                }
            }
        }

        this->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
    }