Example #1
0
static void 
rb_ipod_db_remove_from_playlist_internal (RbIpodDb* ipod_db, 
					  Itdb_Playlist *playlist,
					  Itdb_Track *track)
{
	itdb_playlist_remove_track (playlist, track);
	rb_ipod_db_save_async (ipod_db);
}
Example #2
0
static void
rb_ipod_db_remove_track_internal (RbIpodDb *ipod_db, Itdb_Track *track)
{
	GList *it;

	for (it = track->itdb->playlists; it != NULL; it = it->next) {
		itdb_playlist_remove_track ((Itdb_Playlist *)it->data, track);
	}
	itdb_track_remove (track);

	rb_ipod_db_save_async (ipod_db);
}
Example #3
0
bool GPodDevice::RemoveTrackFromITunesDb(const QString& path,
                                         const QString& relative_to) {
  QString ipod_filename = path;
  if (!relative_to.isEmpty() && path.startsWith(relative_to))
    ipod_filename.remove(
        0, relative_to.length() + (relative_to.endsWith('/') ? -1 : 0));

  ipod_filename.replace('/', ':');

  // Find the track in the itdb, identify it by its filename
  Itdb_Track* track = nullptr;
  for (GList* tracks = db_->tracks; tracks != nullptr; tracks = tracks->next) {
    Itdb_Track* t = static_cast<Itdb_Track*>(tracks->data);

    if (t->ipod_path == ipod_filename) {
      track = t;
      break;
    }
  }

  if (track == nullptr) {
    qLog(Warning) << "Couldn't find song" << path << "in iTunesDB";
    return false;
  }

  // Remove the track from all playlists
  for (GList* playlists = db_->playlists; playlists != nullptr;
       playlists = playlists->next) {
    Itdb_Playlist* playlist = static_cast<Itdb_Playlist*>(playlists->data);

    if (itdb_playlist_contains_track(playlist, track)) {
      itdb_playlist_remove_track(playlist, track);
    }
  }

  // Remove the track from the database, this frees the struct too
  itdb_track_remove(track);

  return true;
}