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

arts

  • arts
  • kde
kartsserver.cpp
1// Copyright (c) 2000-2001 Charles Samuels <charles@kde.org>
2// Neil Stevens <neil@qualityassistant.com>
3//
4// Permission is hereby granted, free of charge, to any person obtaining a copy
5// of this software and associated documentation files (the "Software"), to deal
6// in the Software without restriction, including without limitation the rights
7// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8// copies of the Software, and to permit persons to whom the Software is
9// furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN
18// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21#include <flowsystem.h>
22#include <ksimpleconfig.h>
23#include <tdeprocess.h>
24#include <tdestandarddirs.h>
25#include <tqdir.h>
26#include <tqfile.h>
27#include "kartsserver.h"
28
29struct KArtsServer::Data
30{
31 Arts::SoundServerV2 server;
32};
33
34KArtsServer::KArtsServer(TQObject *parent, const char *name)
35 : TQObject(parent, name)
36 , d(new Data)
37{
38 d->server = Arts::SoundServerV2::null();
39}
40
41KArtsServer::~KArtsServer(void)
42{
43 d->server = Arts::SoundServerV2::null();
44 delete d;
45}
46
47Arts::SoundServerV2 KArtsServer::server(void)
48{
49 bool error = d->server.error();
50 if( d->server.isNull() || error )
51 {
52 d->server = Arts::Reference("global:Arts_SoundServerV2");
53 if( error && !d->server.isNull() && !d->server.error() )
54 emit restartedServer();
55 }
56
57 if(!d->server.isNull() && !d->server.error())
58 return d->server;
59
60 // aRts seems not to be running, let's try to run it
61 // First, let's read the configuration as in kcmarts
62 TDEConfig config("kcmartsrc", false /*bReadOnly*/, false /*bUseKDEGlobals*/);
63 TDEProcess proc;
64
65 config.setGroup("Arts");
66
67 bool rt = config.readBoolEntry("StartRealtime", false);
68 bool x11Comm = config.readBoolEntry("X11GlobalComm", false);
69
70 // put the value of x11Comm into .mcoprc
71 KSimpleConfig X11CommConfig(TQDir::homeDirPath()+"/.mcoprc");
72
73 if(x11Comm)
74 X11CommConfig.writeEntry("GlobalComm", "Arts::X11GlobalComm");
75 else
76 X11CommConfig.writeEntry("GlobalComm", "Arts::TmpGlobalComm");
77
78 X11CommConfig.sync();
79
80 proc << TQFile::encodeName(TDEStandardDirs::findExe(TQString::fromLatin1("tdeinit_wrapper"))).data();
81
82 if(rt)
83 proc << TQFile::encodeName(TDEStandardDirs::findExe(TQString::fromLatin1("artswrapper"))).data();
84 else
85 proc << TQFile::encodeName(TDEStandardDirs::findExe(TQString::fromLatin1("artsd"))).data();
86
87 proc << TQStringList::split( " ", config.readEntry( "Arguments", "-F 10 -S 4096 -s 60 -m artsmessage -l 3 -f" ) );
88
89 if(proc.start(TDEProcess::Block) && proc.normalExit())
90 {
91 // We could have a race-condition here.
92 // The correct way to do it is to make artsd fork-and-exit
93 // after starting to listen to connections (and running artsd
94 // directly instead of using tdeinit), but this is better
95 // than nothing.
96 int time = 0;
97 do
98 {
99 sleep(1);
100 d->server = Arts::Reference("global:Arts_SoundServerV2");
101 } while(++time < 5 && (d->server.isNull()));
102
103 emit restartedServer();
104 }
105 // TODO else what?
106
107 return d->server;
108}
109#include "kartsserver.moc"
KArtsServer::restartedServer
void restartedServer(void)
This is emitted when the soundserver has been restarted (by this KArtsServer instance or outside).
KArtsServer::server
Arts::SoundServerV2 server(void)
Get a verified reference to the SoundServerV2, (re)starting artsd using the kcontrol-specified settin...
Definition: kartsserver.cpp:47
KArtsServer::KArtsServer
KArtsServer(TQObject *parent=0, const char *name=0)
Create a new KArtsServer.
Definition: kartsserver.cpp:34
KSimpleConfig
KSimpleConfig::sync
virtual void sync()
TDEConfigBase::readEntry
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
TDEConfigBase::readBoolEntry
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
TDEConfigBase::writeEntry
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
TDEConfigBase::setGroup
void setGroup(const TQString &group)
TDEConfig
TDEProcess
TDEProcess::start
virtual bool start(RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
TDEProcess::Block
Block
TDEProcess::normalExit
bool normalExit() const
TDEStandardDirs::findExe
static TQString findExe(const TQString &appname, const TQString &pathstr=TQString::null, bool ignoreExecBit=false)

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.