• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • arts
 

arts

  • arts
  • kde
kplayobjectcreator.cpp
1 /*
2
3 Copyright (C) 2002 Matthias Welwarsky <mwelwarsky@web.de>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19
20 */
21
22#include <tdeio/kmimetype.h>
23#include "artskde.h"
24#include "kplayobjectcreator.h"
25#include "kplayobjectcreator.moc"
26#include "kioinputstream_impl.h"
27
28#include <tqfile.h>
29
30#include <kdebug.h>
31
32KDE::PlayObjectCreator::PlayObjectCreator(Arts::SoundServerV2 server)
33{
34 m_server = server;
35}
36
37KDE::PlayObjectCreator::~PlayObjectCreator()
38{
39}
40
41bool KDE::PlayObjectCreator::create(const KURL& url, bool createBUS, const TQObject* receiver, const char* slot)
42{
43 // no need to go any further, and I hate deep indentation
44 if (m_server.isNull() || url.isEmpty() )
45 return false;
46
47 connect( this, TQ_SIGNAL( playObjectCreated( Arts::PlayObject ) ),
48 receiver, slot );
49
50 // check if the URL is a local file
51 if (!url.isLocalFile())
52 {
53 m_createBUS = createBUS;
54
55 // This is the RightWay(tm) according to stw
56 Arts::TDEIOInputStream_impl* instream_impl = new Arts::TDEIOInputStream_impl();
57 m_instream = Arts::TDEIOInputStream::_from_base(instream_impl);
58
59 // signal will be called once the ioslave knows the mime-type of the stream
60 connect(instream_impl, TQ_SIGNAL(mimeTypeFound(const TQString &)),
61 this, TQ_SLOT(slotMimeType(const TQString &)));
62
63 // GO!
64 m_instream.openURL(url.url().latin1());
65 m_instream.streamStart();
66
67 return true;
68 }
69 kdDebug( 400 ) << "stream is local file: " << url.url() << endl;
70
71 // usual stuff if we have a local file
72 KMimeType::Ptr mimetype = KMimeType::findByURL(url);
73 emit playObjectCreated (
74 m_server.createPlayObjectForURL(std::string(TQFile::encodeName(url.path())),
75 std::string(mimetype->name().latin1()),
76 createBUS)
77 );
78 return true;
79}
80
81void KDE::PlayObjectCreator::slotMimeType(const TQString& mimetype)
82{
83
84 kdDebug( 400 ) << "slotMimeType called: " << mimetype << endl;
85
86 TQString mimetype_copy = mimetype;
87
88 if ( mimetype_copy == "application/octet-stream" )
89 mimetype_copy = TQString("audio/x-mp3");
90
91 if (mimetype_copy == "application/x-zerosize")
92 emit playObjectCreated(Arts::PlayObject::null());
93
94 playObject = m_server.createPlayObjectForStream(
95 m_instream,
96 std::string( mimetype_copy.latin1() ),
97 m_createBUS );
98 if ( playObject.isNull() ) {
99 m_instream.streamEnd();
100 emit playObjectCreated( Arts::PlayObject::null() );
101 return;
102 }
103 emit playObjectCreated( playObject );
104}
KURL
KURL::path
TQString path() const
KURL::isEmpty
bool isEmpty() const
KURL::url
TQString url(int _trailing=0, int encoding_hint=0) const
KURL::isLocalFile
bool isLocalFile() const
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)

arts

Skip menu "arts"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

arts

Skip menu "arts"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for arts by doxygen 1.9.4
This website is maintained by Timothy Pearson.