ith Jyrki's patches
aboutsummaryrefslogblamecommitdiff
path: root/src/plugins/General/mpris/mpris2/player2object.cpp
blob: 3168c6c532c05078d4a5e8ac8119e8bfad220733 (plain) (tree)
1
2
                                                                            
                                                                            














                                                                            
                                                                            










                                                                             
                                  

                          
                                                                            
 
                     



                                                
                                               

                                                                               
                                                                                       
                                                                                       

                                                                                   

                                                                                               

                                                                                        
                                                                                               

                                                 












                                      
                                                             



                                         
                                                               

















                                                                                 
                                          
                       
                                              








                                                       

                                                


                                

                                                 


        

                                                 









                                           

                                                                           

                             
                                                                       
                                                                                         
     

                                                                                                       
     



                                                                              

                                                                                        
                                                  
                                                                                






                                                                                  
                                                           
                                                

                                                                           



                                                                                        


















                                             
                                                     













                                         
                                      



                                          
                                     































                                                                                               

                                                                                    

































                                                                                                       
                            












                                                                               

























                                                     



                              

                     





                                                                                                          


                                           




                                            
                                                                       
     
                                                                                                       
                                                                       





                                                 

                   
                           
     










                                                
                                                  


                                                             
                                                                                                    







                                                          

                                                            

 



                                                                              
                                                                               

 

                                    












                                                 
 
/***************************************************************************
 *   Copyright (C) 2010-2015 by Ilya Kotov                                 *
 *   forkotov02@hotmail.ru                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include <QFile>
#include <QDBusMetaType>
#include <QDBusArgument>
#include <QDBusMessage>
#include <QDBusConnection>
#include <qmmp/soundcore.h>
#include <qmmp/metadatamanager.h>
#include <qmmpui/mediaplayer.h>
#include <qmmpui/playlistmanager.h>
#include <qmmpui/qmmpuisettings.h>
#include "player2object.h"

Player2Object::Player2Object(QObject *parent) : QDBusAbstractAdaptor(parent)
{
    m_prev_track = 0;
    m_previous_pos = 0;
    m_core = SoundCore::instance();
    m_player = MediaPlayer::instance();
    m_pl_manager =  m_player->playListManager();
    m_ui_settings = QmmpUiSettings::instance();
    connect(m_core, SIGNAL(metaDataChanged ()), SLOT(updateId()));
    connect(m_core, SIGNAL(metaDataChanged ()), SLOT(emitPropertiesChanged()));
    connect(m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(checkState(Qmmp::State)));
    connect(m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(emitPropertiesChanged()));
    connect(m_core, SIGNAL(volumeChanged(int,int)), SLOT(emitPropertiesChanged()));
    connect(m_core, SIGNAL(elapsedChanged(qint64)), SLOT(checkSeeking(qint64)));
    connect(m_ui_settings, SIGNAL(repeatableListChanged(bool)), SLOT(emitPropertiesChanged()));
    connect(m_ui_settings, SIGNAL(shuffleChanged(bool)), SLOT(emitPropertiesChanged()));
    connect(m_pl_manager, SIGNAL(currentPlayListChanged(PlayListModel*,PlayListModel*)),
            SLOT(setModel(PlayListModel*,PlayListModel*)));
    connect(m_ui_settings, SIGNAL(repeatableListChanged(bool)), SLOT(emitPropertiesChanged()));
    setModel(m_pl_manager->currentPlayList(), 0);
    updateId();
    syncProperties();
}

Player2Object::~Player2Object()
{}

bool Player2Object::canControl() const
{
    return true;
}

bool Player2Object::canGoNext() const
{
    return m_pl_manager->currentPlayList()->nextTrack() != 0;
}

bool Player2Object::canGoPrevious() const
{
    return m_pl_manager->currentPlayList()->currentIndex() > 0;
}

bool Player2Object::canPause() const
{
    return (m_core->state() == Qmmp::Paused || m_core->state() == Qmmp::Playing);
}
bool Player2Object::canPlay() const
{