[Feature] Improve uri handling.
[Khopper.git] / plugins / xiph / xiphplugin.cpp
blobabdcb65377cfe1f768b2b7cc37aa5f2802ceb0b2
1 /**
2 * @file xiphplugin.cpp
3 * @author Wei-Cheng Pan
5 * Copyright (C) 2008 Wei-Cheng Pan <legnaleurc@gmail.com>
7 * This file is part of Khopper.
9 * Khopper 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 3 of the License, or
12 * (at your option) any later version.
14 * Khopper 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.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "xiphplugin.hpp"
23 #include "flac/flacpanel.hpp"
24 #include "flac/flacreader.hpp"
25 #include "ogg/oggpanel.hpp"
27 #include "khopper/text.hpp"
28 #include "khopper/application.hpp"
30 #include <QtCore/QtPlugin>
32 Q_EXPORT_PLUGIN2( KHOPPER_PLUGIN_ID, khopper::plugin::XiphPlugin )
34 namespace {
36 unsigned int verifier( const QUrl & uri ) {
37 // FIXME
38 QFileInfo info( uri.toLocalFile() );
39 if( info.suffix().toLower() == "flac" ) {
40 return 200;
42 return 0;
45 khopper::codec::ReaderSP creator( const QUrl & uri ) {
46 return khopper::codec::ReaderSP( new khopper::codec::FlacReader( uri ) );
51 using namespace khopper::plugin;
52 using khopper::widget::FlacPanel;
53 using khopper::widget::OggPanel;
54 using khopper::plugin::registerReader;
55 using khopper::plugin::unregisterReader;
57 XiphPlugin::XiphPlugin():
58 AbstractPlugin(),
59 flacPanel_( new FlacPanel ),
60 oggPanel_( new OggPanel ) {
61 this->setID( KHOPPER_STRINGIZE(KHOPPER_PLUGIN_ID) );
62 this->setVersion( KHOPPER_STRINGIZE(KHOPPER_VERSION) );
65 XiphPlugin::~XiphPlugin() {
66 delete this->flacPanel_;
67 delete this->oggPanel_;
70 void XiphPlugin::doInstall() {
71 KHOPPER_APPLICATION->addPanel( this->flacPanel_ );
72 KHOPPER_APPLICATION->addPanel( this->oggPanel_ );
73 registerReader( this->getID(), verifier, creator );
76 void XiphPlugin::doUninstall() {
77 KHOPPER_APPLICATION->removePanel( this->flacPanel_ );
78 KHOPPER_APPLICATION->removePanel( this->oggPanel_ );
79 unregisterReader( this->getID() );