예제 #1
0
void
MediaOutput::setVolume( qreal newVolume )
{
    tDebug() << "Set volume for media output " << &m_audioOutput << " to " << newVolume;

    if (fadingAvailable)
    {
        // This is only a workaround because the gstreamer volume control
        // changes sometimes the volume of the wrong output
        // (if seek is used bevore on the next call the right volume will be changed)
        m_mediaFader.setVolume( newVolume );
        currentVolume = newVolume;

        emit volumeChanged( newVolume );
    }
    else
        m_audioOutput.setVolume( newVolume );
}
예제 #2
0
DatabaseImpl::~DatabaseImpl()
{
    tDebug() << "Shutting down database connection.";

/*
#ifdef TOMAHAWK_QUERY_ANALYZE
    TomahawkSqlQuery q = newquery();

    q.exec( "ANALYZE" );
    q.exec( "SELECT * FROM sqlite_stat1" );
    while ( q.next() )
    {
        tLog( LOGSQL ) << q.value( 0 ).toString() << q.value( 1 ).toString() << q.value( 2 ).toString();
    }

#endif
*/
}
예제 #3
0
void TupNetSocket::readed(const QString &readed)
{
    #ifdef K_DEBUG
        tDebug("net") << "TupNetSocket::readed() - PACKAGE ARRIVING: ";
        tWarning("net")  << readed;
    #endif

    QDomDocument doc;
    
    if (doc.setContent(readed)) {
        QString root = doc.documentElement().tagName();
        m_handler->handlePackage(root, readed);
    } else {
        #ifdef K_DEBUG
               tError() << "TupNetSocket::readed() - Error: Package isn't a DOM document";
        #endif
    }
}
예제 #4
0
void
Connection::actualShutdown()
{
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << m_actually_shutting_down << id();
    if ( m_actually_shutting_down )
    {
        return;
    }
    m_actually_shutting_down = true;

    if ( !m_sock.isNull() && m_sock->isOpen() )
    {
        m_sock->disconnectFromHost();
    }

//    qDebug() << "EMITTING finished()";
    emit finished();
}
예제 #5
0
void
ScanManager::scannerFinished()
{
    tDebug() << "deleting scanner";
    if ( !m_scanner.isNull() )
    {
        m_musicScannerThreadController->quit();
        m_musicScannerThreadController->wait( 60000 );

        delete m_scanner.data();
        delete m_musicScannerThreadController;
        m_musicScannerThreadController = 0;
    }

    m_scanTimer->start();
    SourceList::instance()->getLocal()->scanningFinished( 0 );
    emit finished();
}
예제 #6
0
void
Connection::actualShutdown()
{
    Q_D( Connection );
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << d->actually_shutting_down << id();
    if ( d->actually_shutting_down )
    {
        return;
    }
    d->actually_shutting_down = true;

    if ( !d->sock.isNull() && d->sock->isOpen() )
    {
        d->sock->disconnectFromHost();
    }

//    qDebug() << "EMITTING finished()";
    emit finished();
}
예제 #7
0
void
InboxView::onMenuTriggered( int action )
{
    if ( action == Tomahawk::ContextMenu::ActionMarkListened )
    {
        tDebug() << Q_FUNC_INFO << "Mark as Listened";
        InboxModel* inboxModel = qobject_cast< InboxModel* >( model() );
        if ( inboxModel != 0 )
        {
            QModelIndexList sourceIndexes;
            foreach ( const QModelIndex& index, selectedIndexes() )
            {
                if ( index.column() )
                    continue;

                sourceIndexes << proxyModel()->mapToSource( index );
            }
            inboxModel->markAsListened( sourceIndexes );
        }
예제 #8
0
MediaOutput::MediaOutput()
    : totalTimeInMSec(0)
    , prefinishMark( 0 )
    , currentVolume( 1.0 )
    , m_audioOutput( Phonon::MusicCategory, this )
    , m_mediaFader()
{
    m_mediaFader.setFadeCurve( Phonon::VolumeFaderEffect::Fade12Decibel );

    Phonon::Path path = Phonon::createPath( this, &m_audioOutput );

    fadingAvailable = path.insertEffect( &m_mediaFader );

    tDebug() << "Connect media output " << &m_audioOutput;
    connect( &m_audioOutput, SIGNAL( volumeChanged( qreal ) ), SLOT( onVolumeChanged( qreal ) ) );
    connect( this, SIGNAL( tick( qint64 ) ), SLOT( checkPrefinishMark( qint64 ) ) );

    blockSignals( true );
}
예제 #9
0
bool
TwitterAccount::refreshTwitterAuth()
{
    qDebug() << Q_FUNC_INFO << " begin";
    if( !m_twitterAuth.isNull() )
        delete m_twitterAuth.data();

    Q_ASSERT( TomahawkUtils::nam() != 0 );
    tDebug() << Q_FUNC_INFO << " with nam " << TomahawkUtils::nam();
    m_twitterAuth = QPointer< TomahawkOAuthTwitter >( new TomahawkOAuthTwitter( TomahawkUtils::nam(), this ) );

    if( m_twitterAuth.isNull() )
      return false;

    m_twitterAuth.data()->setOAuthToken( credentials()[ "oauthtoken" ].toString().toLatin1() );
    m_twitterAuth.data()->setOAuthTokenSecret( credentials()[ "oauthtokensecret" ].toString().toLatin1() );

    return true;
}
예제 #10
0
void
Connection::sendMsg_now( msg_ptr msg )
{
    Q_ASSERT( QThread::currentThread() == thread() );
//    Q_ASSERT( this->isRunning() );

    if ( m_sock.isNull() || !m_sock->isOpen() || !m_sock->isWritable() )
    {
        tDebug() << "***** Socket problem, whilst in sendMsg(). Cleaning up. *****";
        shutdown( false );
        return;
    }

    if ( !msg->write( m_sock.data() ) )
    {
        //qDebug() << "Error writing to socket in sendMsg() *************";
        shutdown( false );
        return;
    }
}
예제 #11
0
void
FdoNotifyPlugin::dbusCapabiltiesReplyReceived( const QDBusMessage& reply )
{
    if ( reply.type() != QDBusMessage::ReplyMessage )
    {
        tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Did not receive a ReplyMessage";
    }

    const QStringList &list = reply.arguments().at( 0 ).toStringList();
    QListIterator<QString> iter( list );
    while ( iter.hasNext() )
    {
        QString capabilty = iter.next();
        if ( capabilty.compare( "body-markup" ) == 0 )
        {
            m_wmSupportsBodyMarkup = true;
            break;
        }
    }
}
예제 #12
0
Database::~Database()
{
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO;

    m_idWorker->stop();
    delete m_idWorker;

    if ( m_workerRW )
    {
        // Ensure event loop was started so quit() has any effect.
        m_workerRW->waitForEventLoopStart();
        m_workerRW.data()->quit();
    }
    foreach ( QPointer< DatabaseWorkerThread > workerThread, m_workerThreads )
    {
        // Ensure event loop was started so quit() has any effect.
        workerThread->waitForEventLoopStart();
        // If event loop already was killed, the following is just a no-op.
        workerThread->quit();
    }
예제 #13
0
AudioOutput::~AudioOutput()
{
    tDebug() << Q_FUNC_INFO;

    if ( m_vlcPlayer != nullptr )
    {
        libvlc_media_player_stop( m_vlcPlayer );
        libvlc_media_player_release( m_vlcPlayer );
        m_vlcPlayer = nullptr;
    }
    if ( m_vlcMedia != nullptr )
    {
        libvlc_media_release( m_vlcMedia );
        m_vlcMedia = nullptr;
    }
    if ( m_vlcInstance != nullptr )
    {
        libvlc_release( m_vlcInstance );
    }
}
예제 #14
0
void
SocialWidget::accept()
{
    tDebug() << "Sharing social link!";
    
    QVariantMap shareInfo;
    Tomahawk::InfoSystem::InfoStringHash trackInfo;

    trackInfo["title"] = m_query->track();
    trackInfo["artist"] = m_query->artist();
    trackInfo["album"] = m_query->album();

    shareInfo["trackinfo"] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
    shareInfo["message"] = ui->textEdit->toPlainText();
    shareInfo["accountlist"] = QStringList( "all" );

    Tomahawk::InfoSystem::InfoPushData pushData( uuid(), Tomahawk::InfoSystem::InfoShareTrack, shareInfo, Tomahawk::InfoSystem::PushNoFlag );
    Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );

    deleteLater();
}
예제 #15
0
void
Tomahawk::InfoSystem::XmppInfoPlugin::audioStarted(const Tomahawk::InfoSystem::InfoStringHash& info)
{
    tDebug() << Q_FUNC_INFO << m_sipPlugin->m_client->jid().full() << info;

    Jreen::Tune::Ptr tune( new Jreen::Tune() );

    tune->setTitle( info.value( "title" ) );
    tune->setArtist( info.value( "artist" ) );
    tune->setLength( info.value("duration").toInt() );
    tune->setTrack( info.value("albumpos") );
    tune->setUri( GlobalActionManager::instance()->openLink( info.value( "title" ), info.value( "artist" ), info.value( "album" ) ) );

    //TODO: provide a rating once available in Tomahawk
    tune->setRating( 10 );

    //TODO: it would be nice to set Spotify, Dilandau etc here, but not the jabber ids of friends
    tune->setSource( "Tomahawk" );

    m_pubSubManager->publishItems( QList<Jreen::Payload::Ptr>() << tune, Jreen::JID() );
}
예제 #16
0
bool
HatchetSipPlugin::sendBytes( const QVariantMap& jsonMap ) const
{
    if ( m_sipState == Closed )
    {
        tLog() << Q_FUNC_INFO << "was told to send bytes on a closed connection, not gonna do it";
        return false;
    }

    QJson::Serializer serializer;
    QByteArray bytes = serializer.serialize( jsonMap );
    if ( bytes.isEmpty() )
    {
        tLog() << Q_FUNC_INFO << "could not serialize register structure to JSON";
        return false;
    }

    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Sending bytes of size" << bytes.size();
    emit rawBytes( bytes );
    return true;
}
예제 #17
0
void
TwitterAccount::connectAuthVerifyReply( const QTweetUser &user )
{
    m_isAuthenticating = false;
    if ( user.id() == 0 )
    {
        qDebug() << "TwitterAccount could not authenticate to Twitter";
        deauthenticate();
    }
    else
    {
        tDebug() << "TwitterAccount successfully authenticated to Twitter as user " << user.screenName();
        QVariantHash config = configuration();
        config[ "screenname" ] = user.screenName();
        setConfiguration( config );
        sync();

        sipPlugin()->connectPlugin();

        m_isAuthenticated = true;
        emit nowAuthenticated( m_twitterAuth, user );
    }
}
예제 #18
0
파일: tupscene.cpp 프로젝트: nanox/tupi
TupSoundLayer *TupScene::createSoundLayer(int position, bool loaded)
{
    #ifdef K_DEBUG
           T_FUNCINFO << position;
    #endif

    if (position < 0 || position > k->soundLayers.count()) {
        tDebug() << "TupScene::createSoundLayer() - [ Fatal Error ] - Index incorrect!";
        return 0;
    }

    TupSoundLayer *layer = new TupSoundLayer(this);
    k->layerCount++;

    layer->setLayerName(tr("Sound layer %1").arg(k->layerCount));

    k->soundLayers.insert(position, layer);

    if (loaded)
        TupProjectLoader::createSoundLayer(objectIndex(), position, layer->layerName(), project());

    return layer;
}
예제 #19
0
void
Database::enqueue( const QSharedPointer<DatabaseCommand>& lc )
{
    Q_ASSERT( m_ready );
    if ( lc->doesMutates() )
    {
        tDebug( LOGVERBOSE ) << "Enqueueing command to rw thread:" << lc->commandname();
        if ( m_workerRW && m_workerRW.data()->worker() )
            m_workerRW.data()->worker().data()->enqueue( lc );
    }
    else
    {
        // find thread for commandname with lowest amount of outstanding jobs and enqueue job
        int busyThreads = 0;
        QPointer< DatabaseWorkerThread > workerThread;
        QPointer< DatabaseWorker > happyWorker;
        for ( int i = 0; i < m_workerThreads.count(); i++ )
        {
            workerThread = m_workerThreads.at( i );

            if ( workerThread && workerThread.data()->worker() && !workerThread.data()->worker().data()->busy() )
            {
                happyWorker = workerThread.data()->worker();
                break;
            }
            busyThreads++;

            if ( ( !happyWorker && workerThread && workerThread.data()->worker() ) ||
                 ( workerThread && workerThread.data()->worker() && workerThread.data()->worker().data()->outstandingJobs() < happyWorker.data()->outstandingJobs() ) )
                happyWorker = workerThread.data()->worker();
        }

//        tDebug( LOGVERBOSE ) << "Enqueueing command to thread:" << happyThread << busyThreads << lc->commandname();
        Q_ASSERT( happyWorker );
        happyWorker.data()->enqueue( lc );
    }
}
예제 #20
0
void
FdoNotifyPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
{
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "showing notification:" << TomahawkSettings::instance()->songChangeNotificationEnabled();

    if ( !TomahawkSettings::instance()->songChangeNotificationEnabled() )
        return;

    QVariant inputData = pushData.infoPair.second;

    switch ( pushData.type )
    {
        case Tomahawk::InfoSystem::InfoTrackUnresolved:
            notifyUser( tr( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track from this source." ) );
            return;

        case Tomahawk::InfoSystem::InfoNotifyUser:
            notifyUser( pushData.infoPair.second.toString() );
            return;

        case Tomahawk::InfoSystem::InfoNowStopped:
            notifyUser( tr( "Tomahawk is stopped." ) );
            return;

        case Tomahawk::InfoSystem::InfoNowPlaying:
            nowPlaying( pushData.infoPair.second );
            return;

        case Tomahawk::InfoSystem::InfoInboxReceived:
            inboxReceived( pushData.infoPair.second );
            return;

        default:
            return;
    }

}
예제 #21
0
void
SnoreNotifyPlugin::inboxReceived( const QVariant& input )
{
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
    if ( !input.canConvert< QVariantMap >() )
        return;

    QVariantMap map = input.toMap();

    if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
        return;
    if ( !map.contains( "sourceinfo" ) || !map[ "sourceinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
        return;

    InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
    if ( !hash.contains( "title" ) || !hash.contains( "artist" ) )
        return;

    InfoStringHash src = map[ "sourceinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
    if ( !src.contains( "friendlyname" ) )
        return;

    QString messageText;
    // Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
    messageText = tr( "%1 sent you\n%2%4 %3.", "%1 is a nickname, %2 is a title, %3 is an artist, %4 is the preposition used to link track and artist ('by' in english)" )
            .arg( src["friendlyname"].toHtmlEscaped() )
            .arg( hash[ "title" ].toHtmlEscaped() )
            .arg( hash[ "artist" ].toHtmlEscaped() )
            .arg( QString( "\n<i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) );

    // Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text
    messageText = QString( "<i></i>%1" ).arg( messageText );

    Snore::Icon icon( RESPATH "images/inbox-512x512.png" );
    notifyUser( Tomahawk::InfoSystem::InfoInboxReceived, messageText, icon );
}
예제 #22
0
void
Connection::socketDisconnected()
{
    Q_D( Connection );

    qint64 bytesAvailable = 0;
    if ( !d->sock.isNull() )
    {
        bytesAvailable = d->sock->bytesAvailable();
    }
    tDebug( LOGVERBOSE ) << "SOCKET DISCONNECTED" << this->name() << id()
                         << "shutdown will happen after incoming queue empties."
                         << "bytesavail:" << bytesAvailable
                         << "bytesRecvd" << bytesReceived();

    d->peer_disconnected = true;
    emit socketClosed();

    if ( d->msgprocessor_in.length() == 0 && bytesAvailable == 0 )
    {
        handleIncomingQueueEmpty();
        actualShutdown();
    }
}
예제 #23
0
void
MetadataEditor::writeMetadata( bool closeDlg )
{
    if ( m_result )
    {
        QFileInfo fi( QUrl( m_result->url() ).toLocalFile() );

        bool changed = false;
        QByteArray fileName = QFile::encodeName( fi.canonicalFilePath() );
#ifdef Q_OS_WIN
        const wchar_t* encodedName = fi.canonicalFilePath().toStdWString().c_str();
#else
        const char* encodedName = fileName.constData();
#endif

        TagLib::FileRef f( encodedName );
        QSharedPointer<Tomahawk::Tag> tag( Tomahawk::Tag::fromFile( f ) );

        if ( title() != m_result->track()->track() )
        {
            tDebug() << Q_FUNC_INFO << "Track changed" << title() << m_result->track();

            tag->setTitle( title() );
            m_result->track()->setTrack( title() );

            changed = true;
        }

        Tomahawk::artist_ptr newArtist = Tomahawk::Artist::get( artist(), true );
        if ( newArtist != m_result->track()->artistPtr() )
        {
            tDebug() << Q_FUNC_INFO << "Artist changed" << artist() << m_result->track()->artist();

            tag->setArtist( artist() );
            m_result->track()->setArtist( artist() );

            changed = true;
        }

        Tomahawk::album_ptr newAlbum = Tomahawk::Album::get( newArtist, album(), true );
        if ( newAlbum != m_result->track()->albumPtr() )
        {
            tDebug() << Q_FUNC_INFO << "Album changed" << album() << newAlbum->id() << m_result->track()->album() << m_result->track()->albumPtr()->id() << newAlbum.data() << m_result->track()->albumPtr().data();
            if ( newAlbum->id() != m_result->track()->albumPtr()->id() )
            {
                tag->setAlbum( album() );
                m_result->track()->setAlbum( album() );

                changed = true;
            }
        }

        // FIXME: Ugly workaround for the min value of 0
        if ( albumPos() != 0 && albumPos() != (int)m_result->track()->albumpos() )
        {
            tag->setTrack( albumPos() );
            m_result->track()->setAlbumPos( albumPos() );

            tDebug() << Q_FUNC_INFO << "Albumpos changed";
            changed = true;
        }

        // FIXME: Ugly workaround for the min value of 1900
        if ( year() != 1900 && year() != m_result->track()->year() )
        {
            tag->setYear( year() );
            {
                QVariantMap attr = m_result->track()->attributes();
                attr[ "releaseyear" ] = year();
                m_result->track()->setAttributes( attr );
            }

            tDebug() << Q_FUNC_INFO << "Year changed";
            changed = true;
        }

        if ( changed )
        {
            f.save();

            m_editFiles.append( fileName );
            m_result->doneEditing();

            tDebug() << Q_FUNC_INFO << m_result->toString() << m_result->track()->toString();
        }
    }

    if ( closeDlg )
    {
        if ( m_editFiles.count() )
            ScanManager::instance()->runFileScan( m_editFiles, false );

        close();
    }
}
예제 #24
0
void
DatabaseWorker::doWork()
{
    /*
        Run the dbcmd. Only inside a transaction if the cmd does mutates.

        If the cmd is modifying local content (ie source->isLocal()) then
        log to the database oplog for replication to peers.

     */

#ifdef DEBUG_TIMING
    QTime timer;
    timer.start();
#endif

    QList< QSharedPointer<DatabaseCommand> > cmdGroup;
    QSharedPointer<DatabaseCommand> cmd;
    {
        QMutexLocker lock( &m_mut );
        cmd = m_commands.takeFirst();
    }

    if ( cmd->doesMutates() )
    {
        bool transok = m_dbimpl->database().transaction();
        Q_ASSERT( transok );
        Q_UNUSED( transok );
    }

    unsigned int completed = 0;
    try
    {
        bool finished = false;
        {
            while ( !finished )
            {
                completed++;
                cmd->_exec( m_dbimpl ); // runs actual SQL stuff

                if ( cmd->loggable() )
                {
                    // We only save our own ops to the oplog, since incoming ops from peers
                    // are applied immediately.
                    //
                    // Crazy idea: if peers had keypairs and could sign ops/msgs, in theory it
                    // would be safe to sync ops for friend A from friend B's cache, if he saved them,
                    // which would mean you could get updates even if a peer was offline.
                    if ( cmd->source()->isLocal() && !cmd->localOnly() )
                    {
                        // save to op-log
                        DatabaseCommandLoggable* command = (DatabaseCommandLoggable*)cmd.data();
                        logOp( command );
                    }
                    else
                    {
                        // Make a note of the last guid we applied for this source
                        // so we can always request just the newer ops in future.
                        //
                        if ( !cmd->singletonCmd() )
                        {
                            TomahawkSqlQuery query = m_dbimpl->newquery();
                            query.prepare( "UPDATE source SET lastop = ? WHERE id = ?" );
                            query.addBindValue( cmd->guid() );
                            query.addBindValue( cmd->source()->id() );

                            if ( !query.exec() )
                            {
                                throw "Failed to set lastop";
                            }
                        }
                    }
                }

                cmdGroup << cmd;
                if ( cmd->groupable() && !m_commands.isEmpty() )
                {
                    QMutexLocker lock( &m_mut );
                    if ( m_commands.first()->groupable() )
                    {
                        cmd = m_commands.takeFirst();
                    }
                    else
                    {
                        finished = true;
                    }
                }
                else
                    finished = true;
            }

            if ( cmd->doesMutates() )
            {
                qDebug() << "Committing" << cmd->commandname() << cmd->guid();
                if ( !m_dbimpl->database().commit() )
                {
                    tDebug() << "FAILED TO COMMIT TRANSACTION*";
                    throw "commit failed";
                }
            }

#ifdef DEBUG_TIMING
            uint duration = timer.elapsed();
            tDebug() << "DBCmd Duration:" << duration << "ms, now running postcommit for" << cmd->commandname();
#endif

            foreach ( QSharedPointer<DatabaseCommand> c, cmdGroup )
                c->postCommit();

#ifdef DEBUG_TIMING
            tDebug() << "Post commit finished in" << timer.elapsed() - duration << "ms for" << cmd->commandname();
#endif
        }
    }
    catch( const char * msg )
    {
        tLog() << endl
                 << "*ERROR* processing databasecommand:"
                 << cmd->commandname()
                 << msg
                 << m_dbimpl->database().lastError().databaseText()
                 << m_dbimpl->database().lastError().driverText()
                 << endl;

        if ( cmd->doesMutates() )
            m_dbimpl->database().rollback();

        Q_ASSERT( false );
    }
    catch(...)
    {
        qDebug() << "Uncaught exception processing dbcmd";
        if ( cmd->doesMutates() )
            m_dbimpl->database().rollback();

        Q_ASSERT( false );
        throw;
    }

    foreach ( QSharedPointer<DatabaseCommand> c, cmdGroup )
        c->emitFinished();

    QMutexLocker lock( &m_mut );
    m_outstanding -= completed;
    if ( m_outstanding > 0 )
        QTimer::singleShot( 0, this, SLOT( doWork() ) );
}
예제 #25
0
void
CredentialsManager::setCredentials( const CredentialsStorageKey& csKey, const QVariant& value, bool tryToWriteAsString )
{
    tDebug() << Q_FUNC_INFO;
    QMutexLocker locker( &m_mutex );

    QKeychain::Job* j;
    if ( value.isNull() ||
         ( value.type() == QVariant::Map && value.toMap().isEmpty() ) ||
         ( value.type() == QVariant::String && value.toString().isEmpty() ) )
    {
        if ( !m_credentials.contains( csKey ) ) //if we don't have any credentials for this key, we bail
            return;

        m_credentials.remove( csKey );

#ifdef Q_OS_MAC
        TomahawkSettings::instance()->beginGroup( QString( "accounts/%1" ).arg( csKey.key() ) );
        TomahawkSettings::instance()->remove( "credentials" );
        TomahawkSettings::instance()->endGroup();
#else
        QKeychain::DeletePasswordJob* dj = new QKeychain::DeletePasswordJob( csKey.service(), this );
        dj->setKey( csKey.key() );
        j = dj;
#endif
    }
    else
    {
        if ( value == m_credentials.value( csKey ) ) //if the credentials haven't actually changed, we bail
            return;

        m_credentials.insert( csKey, value );

#ifdef Q_OS_MAC
        TomahawkSettings::instance()->beginGroup( QString( "accounts/%1" ).arg( csKey.key() ) );
        TomahawkSettings::instance()->setValue( "credentials", value );
        TomahawkSettings::instance()->endGroup();
#else
        QKeychain::WritePasswordJob* wj = new QKeychain::WritePasswordJob( csKey.service(), this );
        wj->setKey( csKey.key() );

        Q_ASSERT( value.type() == QVariant::String || value.type() == QVariant::Map );

        if ( tryToWriteAsString && value.type() == QVariant::String )
        {
            wj->setTextData( value.toString() );
        }
        else if ( value.type() == QVariant::Map )
        {
            bool ok;
            QByteArray data = TomahawkUtils::toJson( value.toMap(), &ok );

            if ( ok )
            {
                tDebug() << "About to write credentials for key" << csKey.key();
            }
            else
            {
                tDebug() << "Cannot serialize credentials for writing" << csKey.key();
            }

            wj->setTextData( data );
        }

        j = wj;
#endif //Q_OS_MAC
    }

#ifndef Q_OS_MAC
    j->setAutoDelete( false );
#if defined( Q_OS_UNIX ) && !defined( Q_OS_MAC )
    j->setInsecureFallback( true );
#endif
    connect( j, SIGNAL( finished( QKeychain::Job* ) ),
             SLOT( keychainJobFinished( QKeychain::Job* ) ) );
    j->start();
    tDebug() << Q_FUNC_INFO << "launched" << j->metaObject()->className() << "for service" << j->service();
#endif
}
 UtilityCalculator* UCFirmRTBuilder::build(xmlDocPtr doc, xmlNodePtr cur) {
   tDebug() << "Building a UtilityCalculator";
   
   // No further information is needed to build the object
   return new UCFirmRT();
 }
예제 #27
0
void
AccountWidget::update( const QPersistentModelIndex& idx, int accountIdx )
{
    Tomahawk::Accounts::Account* account =
            idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole )
            .value< QList< Tomahawk::Accounts::Account* > >().at( accountIdx );

    if ( account )
    {
        const QPixmap& pixmap = account->icon();
        QSize pixmapSize( scaled( 32, 32 ) );
        m_imageLabel->setPixmap( pixmap.scaled( pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
        m_imageLabel->setFixedSize( pixmapSize );

        QFontMetrics fm = m_idLabel->fontMetrics();
        m_idLabel->setText( account->accountFriendlyName() );
        m_idLabel->setToolTip( "<b>" +
                               account->accountServiceName() +
                               "</b><br>" +
                               account->accountFriendlyName() );

        switch ( account->connectionState() )
        {
            case Tomahawk::Accounts::Account::Connected:
            {
                if ( account->enabled() )
                    m_statusToggle->setChecked( true );
                else
                    tDebug() << "AccountWidget warning:" << account->accountFriendlyName()
                             << "is Connected but Disabled!";
                m_spinner->fadeOut();
                m_statusToggle->setBackChecked( true );
                setInviteWidgetsEnabled( true );
                break;
            }

            case Tomahawk::Accounts::Account::Connecting:
            {
                if ( !account->enabled() )
                    tDebug() << "AccountWidget warning:" << account->accountFriendlyName()
                             << "is Connecting but Disabled!";
                m_spinner->fadeIn();
                m_statusToggle->setBackChecked( false );
                setInviteWidgetsEnabled( false );
                break;
            }

            case Tomahawk::Accounts::Account::Disconnected:
            {
                if ( !account->enabled() )
                    m_statusToggle->setChecked( false );
                else
                    tDebug() << "AccountWidget warning:" << account->accountFriendlyName()
                             << "is Disconnected but Enabled!";
                m_spinner->fadeOut();
                m_statusToggle->setBackChecked( false );
                setInviteWidgetsEnabled( false );
                break;
            }

            case Tomahawk::Accounts::Account::Disconnecting:
            {
                if ( account->enabled() )
                    tDebug() << "AccountWidget warning:" << account->accountFriendlyName()
                             << "is Disconnecting but Enabled!";
                m_spinner->fadeIn();
                m_statusToggle->setBackChecked( true );
                setInviteWidgetsEnabled( false );
            }
        }

        if ( !account->enabled() && account->connectionState() == Tomahawk::Accounts::Account::Disconnected )
        {
            m_spinner->fadeOut();
            m_statusToggle->setBackChecked( false );
            m_statusToggle->setChecked( false );
            setInviteWidgetsEnabled( false );
        }
        else if ( account->enabled() && account->connectionState() == Tomahawk::Accounts::Account::Connected )
        {
            m_spinner->fadeOut();
            m_statusToggle->setBackChecked( true );
            m_statusToggle->setChecked( true );
            setInviteWidgetsEnabled( true );
        }
    }
}
예제 #28
0
void
FdoNotifyPlugin::nowPlaying( const QVariant& input )
{
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
    if ( !input.canConvert< QVariantMap >() )
        return;

    QVariantMap map = input.toMap();

    if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
        return;

    InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
    if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) )
        return;

    QString messageText;
    // If the window manager supports notification styling then use it.
    if ( m_wmSupportsBodyMarkup )
    {
        // Remark: If using xml-based markup in notifications, the supplied strings need to be escaped.
        QString album;
        if ( !hash[ "album" ].isEmpty() )
            album = tr( "<br /><i>on</i> %1", "%1 is an album name" ).arg( Qt::escape( hash[ "album" ] ) );

        messageText = tr( "%1<br /><i>by</i> %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing" )
                        .arg( Qt::escape( hash[ "title" ] ) )
                        .arg( Qt::escape( hash[ "artist" ] ) )
                        .arg( album );
    }
    else
    {
        QString album;
        if ( !hash[ "album" ].isEmpty() )
            album = QString( " %1" ).arg( tr( "on \"%1\"", "%1 is an album name" ).arg( hash[ "album" ] ) );

        messageText = tr( "\"%1\" by %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing" )
                        .arg( hash[ "title" ] )
                        .arg( hash[ "artist" ] )
                        .arg( album );
    }

    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "sending message" << messageText;

    QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify" );
    QList<QVariant> arguments;
    arguments << QString( "Tomahawk" ); //app_name
    arguments << m_nowPlayingId; //notification_id
    arguments << QString(); //app_icon
    arguments << QString( "Tomahawk - Now Playing" ); //summary
    arguments << messageText; //body
    arguments << QStringList(); //actions
    QVariantMap dict;
    dict["desktop-entry"] = QString( "tomahawk" );

    // If there is a cover availble use it, else use Tomahawk logo as default.
    QImage image;
    if ( map.contains( "coveruri" ) && map[ "coveruri" ].canConvert< QString >() )
        image = QImage( map[ "coveruri" ].toString(), "PNG" );
    else
        image = QImage( RESPATH "icons/tomahawk-icon-512x512.png" );
    // Convert image to QVariant and scale to a consistent size.
    dict[ "image_data" ] = ImageConverter::variantForImage( image.scaledToHeight( getNotificationIconHeight() ) );

    arguments << dict; //hints
    arguments << qint32( -1 ); //expire_timeout
    message.setArguments( arguments );

    // Handle reply in a callback, so that this a non-blocking call
    QDBusConnection::sessionBus().callWithCallback( message, this, SLOT( dbusPlayingReplyReceived( QDBusMessage ) ) );
}
예제 #29
0
void
SipHandler::onPeerOffline( const QString& peerId )
{
//    qDebug() << Q_FUNC_INFO;
    tDebug() << "SIP offline:" << peerId;
}
예제 #30
0
void
Tomahawk::InfoSystem::XmppInfoPlugin::audioPaused()
{
    tDebug() << Q_FUNC_INFO << m_sipPlugin->m_client->jid().full();
}