Logo Search packages:      
Sourcecode: qlix version File versions  Download package

bool MtpDevice::NewAlbum ( MTP::Track in_track,
int  in_storageID,
MTP::Album **  out_album 
)

This function creates a new album on the device, using the information from the track that is passed as a param. This function assumes that this album's name is unique on the device. The new album will be added to the album's list, be sure to notify any models before hand

Parameters:
in_track the track that is used as a template for the album's name, artist, and genre fields.
in_storageID the storage id to create the album on
out_album the newly allocated MTP::Album, if the operation fails this value is NULL
Returns:
true if successfull false otherwise

Definition at line 824 of file MtpDevice.cpp.

References MTP::Track::AlbumName(), MTP::Track::ArtistName(), MTP::Track::Genre(), processErrorStack(), and UpdateSpaceInformation().

{
  LIBMTP_album_t* newAlbum = LIBMTP_new_album_t();
  newAlbum->name = strdup(in_track->AlbumName());
  newAlbum->artist = strdup(in_track->ArtistName());
  newAlbum->genre = strdup(in_track->Genre());
  newAlbum->tracks  = NULL;
  newAlbum->parent_id = 0;
  newAlbum->storage_id = in_storageID;

  cerr << "Created new album with name: " << newAlbum->name << endl;
  cerr << "Created new album with artist: " << newAlbum->artist << endl;
  cerr << "Created new album with genre: " << newAlbum->genre << endl;
//  *(newAlbum->tracks) = in_track->ID();
//  cout << "Set the album's first track to: " << *(newAlbum->tracks) << endl;
  newAlbum->no_tracks = 0;
  newAlbum->next = NULL;
#ifndef SIMULATE_TRANSFERS
  int ret =  LIBMTP_Create_New_Album(_device, newAlbum);
  if (ret != 0)
  {
    (*out_album) = NULL;
    processErrorStack();
    return false;
  }
#endif
  UpdateSpaceInformation();
  LIBMTP_filesampledata_t sample;
  sample.size = 0;
  sample.data = NULL;
  (*out_album) = new MTP::Album(newAlbum, sample);
  return true;
}


Generated by  Doxygen 1.6.0   Back to index