Back to index

unity  6.0.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions
unity::dash::AlbumPreview Class Reference

#include <MusicPreviews.h>

Inheritance diagram for unity::dash::AlbumPreview:
Inheritance graph
[legend]
Collaboration diagram for unity::dash::AlbumPreview:
Collaboration graph
[legend]

List of all members.

Classes

struct  Track

Public Types

typedef std::shared_ptr
< AlbumPreview
Ptr
typedef std::vector< std::string > Genres
typedef std::vector< TrackTracks
typedef std::map< std::string,
unity::glib::Variant
Properties

Public Member Functions

 AlbumPreview (Preview::Properties &properties)
void LoadTracks (Properties &properties)

Static Public Member Functions

static Preview::Ptr PreviewForProperties (std::string const &renderer_name, Properties &properties)

Public Attributes

std::string name
std::string artist
std::string year
unsigned int length
Genres genres
Tracks tracks
std::string album_cover
std::string primary_action_name
std::string primary_action_icon_hint
std::string primary_action_uri
std::string renderer_name

Protected Member Functions

unsigned int PropertyToUnsignedInt (Properties &properties, const char *key)
std::string PropertyToString (Properties &properties, const char *key)
std::vector< std::string > PropertyToStringVector (Properties &properties, const char *key)
float PropertyToFloat (Properties &properties, const char *key)

Detailed Description

Definition at line 56 of file MusicPreviews.h.


Member Typedef Documentation

typedef std::vector<std::string> unity::dash::AlbumPreview::Genres

Definition at line 60 of file MusicPreviews.h.

typedef std::map<std::string, unity::glib::Variant> unity::dash::Preview::Properties [inherited]

Definition at line 42 of file Preview.h.

typedef std::shared_ptr<AlbumPreview> unity::dash::AlbumPreview::Ptr

Reimplemented from unity::dash::Preview.

Definition at line 59 of file MusicPreviews.h.

Definition at line 82 of file MusicPreviews.h.


Constructor & Destructor Documentation

Definition at line 44 of file MusicPreviews.cpp.

  : name(PropertyToString(properties, "name"))
  , artist(PropertyToString(properties, "artist"))
  , year(PropertyToString(properties, "year"))
  , genres(PropertyToStringVector(properties, "genres"))
  , album_cover(PropertyToString(properties, "album-cover"))
  , primary_action_name(PropertyToString(properties, "primary-action-name"))
  , primary_action_icon_hint(PropertyToString(properties, "primary-action-icon-hint"))
  , primary_action_uri(PropertyToString(properties, "primary-action-uri"))
{
  renderer_name = "preview-album";
  LoadTracks(properties);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 58 of file MusicPreviews.cpp.

{
  GVariantIter *iter = NULL;
  unsigned int track_number = 0;
  char* track_title;
  unsigned int track_length = 0;
  char* track_play_uri;
  char* track_pause_uri;

  if (properties.find("tracks") == properties.end())
    return;

  g_variant_get(properties["tracks"], "(ususs)", &iter);

  while (g_variant_iter_loop(iter, "ususs",
                             &track_number,
                             &track_title,
                             &track_length,
                             &track_play_uri,
                             &track_pause_uri))
  {
    Track track(track_number, track_title, track_length, track_play_uri, track_pause_uri);
    tracks.push_back(track);

    length += track_length;
  }

  g_variant_iter_free(iter);
}

Here is the caller graph for this function:

Preview::Ptr unity::dash::Preview::PreviewForProperties ( std::string const &  renderer_name,
Properties properties 
) [static, inherited]

Definition at line 31 of file Preview.cpp.

{
  if (renderer_name_ == "preview-application")
  {
    return Preview::Ptr(new ApplicationPreview(properties));
  }
  else if (renderer_name_ == "preview-generic")
  {
    return Preview::Ptr(new GenericPreview(properties));
  }
  else if (renderer_name_ == "preview-track")
  {
    return Preview::Ptr(new TrackPreview(properties));
  }
  else if (renderer_name_ == "preview-album")
  {
    return Preview::Ptr(new AlbumPreview(properties));
  }
  else
  {
    return Preview::Ptr(new NoPreview());
  }
}

Here is the caller graph for this function:

float unity::dash::Preview::PropertyToFloat ( Properties properties,
const char *  key 
) [protected, inherited]

Definition at line 90 of file Preview.cpp.

{
  if (properties.find(key) == properties.end())
    return 0.0f;

  return (float)g_variant_get_double(properties[key]);
}
std::string unity::dash::Preview::PropertyToString ( Properties properties,
const char *  key 
) [protected, inherited]

Definition at line 64 of file Preview.cpp.

{
  if (properties.find(key) == properties.end())
   return "";
  return g_variant_get_string(properties[key], NULL);
}
std::vector< std::string > unity::dash::Preview::PropertyToStringVector ( Properties properties,
const char *  key 
) [protected, inherited]

Definition at line 71 of file Preview.cpp.

{
  GVariantIter* iter = NULL;
  char* value = NULL;
  std::vector<std::string> property;

  if (properties.find(key) == properties.end())
    return property;

  g_variant_get(properties[key], "as", &iter);

  while (g_variant_iter_loop(iter, "s", &value))
    property.push_back(value);

  g_variant_iter_free(iter);

  return property;
}
unsigned int unity::dash::Preview::PropertyToUnsignedInt ( Properties properties,
const char *  key 
) [protected, inherited]

Definition at line 59 of file Preview.cpp.

{
  return g_variant_get_uint32(properties[key]);
}

Member Data Documentation

Definition at line 94 of file MusicPreviews.h.

Definition at line 89 of file MusicPreviews.h.

Definition at line 92 of file MusicPreviews.h.

Definition at line 91 of file MusicPreviews.h.

Definition at line 88 of file MusicPreviews.h.

Definition at line 96 of file MusicPreviews.h.

Definition at line 95 of file MusicPreviews.h.

Definition at line 97 of file MusicPreviews.h.

std::string unity::dash::Preview::renderer_name [inherited]

Definition at line 48 of file Preview.h.

Definition at line 93 of file MusicPreviews.h.

Definition at line 90 of file MusicPreviews.h.


The documentation for this class was generated from the following files: