00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include <flowsystem.h>
00022
#include <ksimpleconfig.h>
00023
#include <kprocess.h>
00024
#include <kstandarddirs.h>
00025
#include <qdir.h>
00026
#include <qfile.h>
00027
#include "kartsserver.h"
00028
00029
struct KArtsServer::Data
00030 {
00031 Arts::SoundServerV2 server;
00032 };
00033
00034 KArtsServer::KArtsServer(
QObject *parent,
const char *name)
00035 :
QObject(parent, name)
00036 , d(new Data)
00037 {
00038 d->server = Arts::SoundServerV2::null();
00039 }
00040
00041 KArtsServer::~KArtsServer(
void)
00042 {
00043 d->server = Arts::SoundServerV2::null();
00044
delete d;
00045 }
00046
00047 Arts::SoundServerV2
KArtsServer::server(
void)
00048 {
00049
bool error = d->server.error();
00050
if( d->server.isNull() || error )
00051 {
00052 d->server = Arts::Reference(
"global:Arts_SoundServerV2");
00053
if( error && !d->server.isNull() && !d->server.error() )
00054 emit
restartedServer();
00055 }
00056
00057
if(!d->server.isNull() && !d->server.error())
00058
return d->server;
00059
00060
00061
00062
KConfig config(
"kcmartsrc",
false ,
false );
00063
KProcess proc;
00064
00065 config.
setGroup(
"Arts");
00066
00067
bool rt = config.
readBoolEntry(
"StartRealtime",
false);
00068
bool x11Comm = config.
readBoolEntry(
"X11GlobalComm",
false);
00069
00070
00071
KSimpleConfig X11CommConfig(QDir::homeDirPath()+
"/.mcoprc");
00072
00073
if(x11Comm)
00074 X11CommConfig.
writeEntry(
"GlobalComm",
"Arts::X11GlobalComm");
00075
else
00076 X11CommConfig.
writeEntry(
"GlobalComm",
"Arts::TmpGlobalComm");
00077
00078 X11CommConfig.
sync();
00079
00080 proc << QFile::encodeName(KStandardDirs::findExe(QString::fromLatin1(
"kdeinit_wrapper")));
00081
00082
if(rt)
00083 proc << QFile::encodeName(KStandardDirs::findExe(QString::fromLatin1(
"artswrapper")));
00084
else
00085 proc << QFile::encodeName(KStandardDirs::findExe(QString::fromLatin1(
"artsd")));
00086
00087 proc << QStringList::split(
" ", config.
readEntry(
"Arguments",
"-F 10 -S 4096 -s 60 -m artsmessage -l 3 -f" ) );
00088
00089
if(proc.
start(KProcess::Block) && proc.
normalExit())
00090 {
00091
00092
00093
00094
00095
00096
int time = 0;
00097
do
00098 {
00099 sleep(1);
00100 d->server = Arts::Reference(
"global:Arts_SoundServerV2");
00101 }
while(++time < 5 && (d->server.isNull()));
00102
00103 emit
restartedServer();
00104 }
00105
00106
00107
return d->server;
00108 }
00109
00110
00111
#include "kartsserver.moc"