Ejemplo n.º 1
0
PodcastService::PodcastService(Application* app, InternetModel* parent)
    : InternetService(kServiceName, app, parent, parent),
      use_pretty_covers_(true),
      icon_loader_(new StandardItemIconLoader(app->album_cover_loader(), this)),
      backend_(app->podcast_backend()),
      model_(new PodcastServiceModel(this)),
      proxy_(new PodcastSortProxyModel(this)),
      context_menu_(nullptr),
      root_(nullptr),
      organise_dialog_(new OrganiseDialog(app_->task_manager())) {
  icon_loader_->SetModel(model_);
  proxy_->setSourceModel(model_);
  proxy_->setDynamicSortFilter(true);
  proxy_->sort(0);

  connect(backend_, SIGNAL(SubscriptionAdded(Podcast)),
          SLOT(SubscriptionAdded(Podcast)));
  connect(backend_, SIGNAL(SubscriptionRemoved(Podcast)),
          SLOT(SubscriptionRemoved(Podcast)));
  connect(backend_, SIGNAL(EpisodesAdded(PodcastEpisodeList)),
          SLOT(EpisodesAdded(PodcastEpisodeList)));
  connect(backend_, SIGNAL(EpisodesUpdated(PodcastEpisodeList)),
          SLOT(EpisodesUpdated(PodcastEpisodeList)));

  connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)),
          SLOT(CurrentSongChanged(Song)));
}
Ejemplo n.º 2
0
void PodcastBackend::Unsubscribe(const Podcast& podcast) {
  // If this podcast is not already in the database, do nothing
  if (!podcast.is_valid()) {
    return;
  }

  QMutexLocker l(db_->Mutex());
  QSqlDatabase db(db_->Connect());
  ScopedTransaction t(&db);

  // Remove the podcast.
  QSqlQuery q("DELETE FROM podcasts WHERE ROWID = :id", db);
  q.bindValue(":id", podcast.database_id());
  q.exec();
  if (db_->CheckErrors(q)) return;

  // Remove all episodes in the podcast
  q = QSqlQuery("DELETE FROM podcast_episodes WHERE podcast_id = :id", db);
  q.bindValue(":id", podcast.database_id());
  q.exec();
  if (db_->CheckErrors(q)) return;

  t.Commit();

  emit SubscriptionRemoved(podcast);
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// CCFContextManager::RemoveSubscription
//-----------------------------------------------------------------------------
//
TBool CCFContextManager::RemoveSubscriptions(
    MCFContextSubscriptionListener* aListener)
    {
    FUNC_LOG;

    TBool cleanupElement( EFalse );

    TInt i = iSubscriptions.Count() - 1;
    while ( i >= 0 )
        {
        if ( i >= iSubscriptions.Count() )
            {
            // Context source has removed subscriptions via synchronous call
            // e.g. from managers call to source's NoSubscribers() function.
            i = iSubscriptions.Count() - 1;
            }

        if ( i < 0 )
            {
            INFO( "All subscriptions removed" );
            break;
            }

        CCFContextSubscriptionImpl* subscription = iSubscriptions[ i ];
        if ( &( subscription->SubscriptionListener() ) == aListener )
            {
            iSubscriptions.Remove( i );
            if ( SubscriptionRemoved( *subscription ) )
                {
                cleanupElement = ETrue;
                }
            delete subscription;
            subscription = NULL;
            }
        --i;
        }

    return cleanupElement;
    }
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
// CCFContextManager::RemoveSubscription
//-----------------------------------------------------------------------------
//
TBool CCFContextManager::RemoveSubscription(
    CCFContextSubscription& aSubscription,
    MCFContextSubscriptionListener& aListener )
    {
    FUNC_LOG;

    TBool cleanupElement( EFalse );
   	CCFContextSubscriptionImpl* subscriptionImpl =
   	    static_cast<CCFContextSubscriptionImpl*>( &aSubscription );

    subscriptionImpl->SetSubscriptionListener( aListener );
    TBool deleteSubscriptionImpl( EFalse );

    TInt i = iSubscriptions.Count() - 1;
    while ( i >= 0 )
        {
        if ( i >= iSubscriptions.Count() )
            {
            // Context source has removed subscriptions via synchronous call
            // e.g. from managers call to source's NoSubscribers() function.
            i = iSubscriptions.Count() - 1;
            }

        if ( i < 0 )
            {
            INFO( "All subscriptions removed" );
            break;
            }

        if ( iSubscriptions[ i ]->IsSame( *subscriptionImpl ) )
            {
            CCFContextSubscriptionImpl* subscription = iSubscriptions[ i ];
            iSubscriptions.Remove( i );
            INFO_2( "CCFContextManager::RemoveSubscription - Subscription [%S: %S] removed",
                    &subscription->ContextSource(),
                    &subscription->ContextType() );
            if ( SubscriptionRemoved( *subscription ) )
                {
                cleanupElement = ETrue;
                }
            if ( subscription != subscriptionImpl )
                {
                delete subscription;
                }
            else
                {
                // Delay deleting when the same subscription instance is used
                // internally for both subscribe and unsubscribe.
                deleteSubscriptionImpl = ETrue;
                }
            }
        --i;
        }

    if ( deleteSubscriptionImpl )
        {
        delete subscriptionImpl;
        }

    return cleanupElement;
    }