File indexing completed on 2024-10-06 04:26:00
0001 /* 0002 SPDX-FileCopyrightText: 2010 Michal Malek <michalm@jabster.pl> 0003 SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "k3bjobinterface.h" 0009 #include "k3bjobinterfaceadaptor.h" 0010 #include "k3bjob.h" 0011 0012 #include <QDBusConnection> 0013 #include <QDataStream> 0014 0015 namespace K3b { 0016 0017 0018 JobInterface::JobInterface( Job* job ) 0019 : 0020 QObject( job ), 0021 m_job( job ), 0022 m_lastProgress( 0 ), 0023 m_lastSubProgress( 0 ) 0024 { 0025 if( m_job ) { 0026 connect( m_job, SIGNAL(newTask(QString)), this, SIGNAL(newTask(QString)) ); 0027 connect( m_job, SIGNAL(newSubTask(QString)), this, SIGNAL(newSubTask(QString)) ); 0028 connect( m_job, SIGNAL(infoMessage(QString,int)), this, SIGNAL(infoMessage(QString,int)) ); 0029 connect( m_job, SIGNAL(finished(bool)), this, SIGNAL(finished(bool)) ); 0030 connect( m_job, SIGNAL(started()), this, SIGNAL(started()) ); 0031 connect( m_job, SIGNAL(canceled()), this, SIGNAL(canceled()) ); 0032 connect( m_job, SIGNAL(percent(int)), this, SLOT(slotProgress(int)) ); 0033 connect( m_job, SIGNAL(subPercent(int)), this, SLOT(slotSubProgress(int)) ); 0034 connect( m_job, SIGNAL(nextTrack(int,int)), this, SIGNAL(nextTrack(int,int)) ); 0035 0036 if( m_job->inherits( "K3b::BurnJob" ) ) { 0037 connect( m_job, SIGNAL(bufferStatus(int)), this, SIGNAL(buffer(int)) ); 0038 connect( m_job, SIGNAL(deviceBuffer(int)), this, SIGNAL(deviceBuffer(int)) ); 0039 } 0040 } 0041 0042 new K3bJobInterfaceAdaptor( this ); 0043 QDBusConnection::sessionBus().registerObject( "/job", this ); 0044 } 0045 0046 0047 JobInterface::~JobInterface() 0048 { 0049 QDBusConnection::sessionBus().unregisterObject( "/job" ); 0050 } 0051 0052 0053 bool JobInterface::jobRunning() const 0054 { 0055 return ( m_job && m_job->active() ); 0056 } 0057 0058 0059 QString JobInterface::jobDescription() const 0060 { 0061 if( m_job ) 0062 return m_job->jobDescription(); 0063 else 0064 return QString(); 0065 } 0066 0067 0068 QString JobInterface::jobDetails() const 0069 { 0070 if( m_job ) 0071 return m_job->jobDetails(); 0072 else 0073 return QString(); 0074 } 0075 0076 0077 void JobInterface::slotProgress( int val ) 0078 { 0079 if( m_lastProgress != val ) 0080 Q_EMIT progress( val ); 0081 } 0082 0083 0084 void JobInterface::slotSubProgress( int val ) 0085 { 0086 if( m_lastSubProgress != val ) 0087 Q_EMIT subProgress( val ); 0088 } 0089 0090 } // namespace K3b 0091 0092 #include "moc_k3bjobinterface.cpp"