~ubuntu-branches/ubuntu/karmic/amarok/karmic

« back to all changes in this revision

Viewing changes to src/dialogs/ScriptManager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2009-09-03 23:49:07 UTC
  • mfrom: (1.77.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090903234907-rk4lt6hnxwckvuon
Tags: 2:2.1.80-0ubuntu1
New upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2004-2007 by Mark Kretschmann <kretschmann@kde.org>     *
3
 
 *                 2005-2007 by Seb Ruiz <ruiz@kde.org>                    *
4
 
 *                      2006 by Alexandre Oliveira <aleprj@gmail.com>      *
5
 
 *                      2006 by Martin Ellis <martin.ellis@kdemail.net>    *
6
 
 *                      2007 by Leonardo Franchi <lfranchi@gmail.com>      *
7
 
 *                      2008 by Peter ZHOU <peterzhoulei@gmail.com>        *
8
 
 *                                                                         *
9
 
 *   This program is free software; you can redistribute it and/or modify  *
10
 
 *   it under the terms of the GNU General Public License as published by  *
11
 
 *   the Free Software Foundation; either version 2 of the License, or     *
12
 
 *   (at your option) any later version.                                   *
13
 
 *                                                                         *
14
 
 *   This program is distributed in the hope that it will be useful,       *
15
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
16
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
17
 
 *   GNU General Public License for more details.                          *
18
 
 *                                                                         *
19
 
 *   You should have received a copy of the GNU General Public License     *
20
 
 *   along with this program; if not, write to the                         *
21
 
 *   Free Software Foundation, Inc.,                                       *
22
 
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
23
 
 ***************************************************************************/
 
1
/****************************************************************************************
 
2
 * Copyright (c) 2004-2007 Mark Kretschmann <kretschmann@kde.org>                       *
 
3
 * Copyright (c) 2005-2007 Seb Ruiz <ruiz@kde.org>                                      *
 
4
 * Copyright (c) 2006 Alexandre Pereira de Oliveira <aleprj@gmail.com>                  *
 
5
 * Copyright (c) 2006 Martin Ellis <martin.ellis@kdemail.net>                           *
 
6
 * Copyright (c) 2007 Leo Franchi <lfranchi@gmail.com>                                  *
 
7
 * Copyright (c) 2008 Peter ZHOU <peterzhoulei@gmail.com>                               *
 
8
 *                                                                                      *
 
9
 * This program is free software; you can redistribute it and/or modify it under        *
 
10
 * the terms of the GNU General Public License as published by the Free Software        *
 
11
 * Foundation; either version 2 of the License, or (at your option) any later           *
 
12
 * version.                                                                             *
 
13
 *                                                                                      *
 
14
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
 
15
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
 
16
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.              *
 
17
 *                                                                                      *
 
18
 * You should have received a copy of the GNU General Public License along with         *
 
19
 * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
 
20
 ****************************************************************************************/
24
21
 
25
22
#define DEBUG_PREFIX "ScriptManager"
26
23
 
72
69
#include <sys/stat.h>
73
70
#include <sys/types.h>
74
71
 
75
 
namespace Amarok
76
 
{
77
 
    QString
78
 
    proxyForUrl(const QString& url)
79
 
    {
80
 
        KUrl kurl( url );
81
 
 
82
 
        QString proxy;
83
 
 
84
 
        if ( KProtocolManager::proxyForUrl( kurl ) !=
85
 
                QString::fromLatin1( "DIRECT" ) ) {
86
 
            KProtocolManager::slaveProtocol ( kurl, proxy );
87
 
        }
88
 
 
89
 
        return proxy;
90
 
    }
91
 
 
92
 
    QString
93
 
    proxyForProtocol(const QString& protocol)
94
 
    {
95
 
        return KProtocolManager::proxyFor( protocol );
96
 
    }
97
 
}
98
 
 
99
72
////////////////////////////////////////////////////////////////////////////////
100
73
// class ScriptManager
101
74
////////////////////////////////////////////////////////////////////////////////
430
403
    m_scripts[name].evaluating = true;
431
404
    if( m_scripts[name].info.category() == "Lyrics" )
432
405
        m_lyricsScript = name;
433
 
   
 
406
 
434
407
    m_scripts[name].log += time.currentTime().toString() + " Script Started!" + '\n';
435
408
    m_scripts[name].engine->setProcessEventsInterval( 100 );
436
409
    m_scripts[name].engine->evaluate( scriptFile.readAll() );
460
433
    else
461
434
        slotStopScript( name );
462
435
 
463
 
 
464
 
 
465
 
 
466
436
    return true;
467
437
}
468
438
 
634
604
    scriptObject = scriptEngine->newQObject( objectPtr );
635
605
    m_global.setProperty( "Script", scriptObject );
636
606
    m_scripts[name].wrapperList.append( objectPtr );
637
 
    
 
607
 
638
608
    objectPtr = new InfoScript( m_scripts[name].url );
639
609
    QScriptValue infoContext = scriptEngine->newQObject( objectPtr );
640
610
    m_global.setProperty( "Info", infoContext );
657
627
    scriptObject = scriptEngine->newQObject( objectPtr );
658
628
    m_global.setProperty( "Lyrics", scriptObject );
659
629
    m_scripts[name].wrapperList.append( objectPtr );
660
 
    
 
630
 
661
631
    objectPtr = new AmarokScript::AmarokServicePluginManagerScript( scriptEngine );
662
632
    scriptObject = scriptEngine->newQObject( objectPtr );
663
633
    m_global.setProperty( "ServicePluginManager", scriptObject );