Qt 4.8
Public Slots | Signals | Public Functions | Private Slots | Private Functions | Static Private Functions | Properties | Static Private Attributes | List of all members
QWSSoundServerClient Class Reference
Inheritance diagram for QWSSoundServerClient:
QObject

Public Slots

void sendDeviceError (int, int, int)
 
void sendDeviceReady (int, int)
 
void sendSoundCompleted (int, int)
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void pause (int, int)
 
void play (int, int, const QString &)
 
void play (int, int, const QString &, int, int)
 
void playPriorityOnly (bool)
 
void playRaw (int, int, const QString &, int, int, int, int)
 
void resume (int, int)
 
void setMute (int, int, bool)
 
void setSilent (bool)
 
void setVolume (int, int, int, int)
 
void stop (int, int)
 
void stopAll (int)
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

 QWSSoundServerClient (QWS_SOCK_BASE *s, QObject *parent)
 
 ~QWSSoundServerClient ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Slots

void tryReadCommand ()
 

Private Functions

void sendClientMessage (QString msg)
 

Static Private Functions

static int nextId ()
 

Properties

int left
 
int mCurrentID
 
bool priExist
 
int right
 
QPointer< QWS_SOCK_BASEsocket
 

Static Private Attributes

static int lastId = 0
 

Additional Inherited Members

- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 116 of file qsoundqss_qws.cpp.

Constructors and Destructors

◆ QWSSoundServerClient()

QWSSoundServerClient::QWSSoundServerClient ( QWS_SOCK_BASE s,
QObject parent 
)

Definition at line 160 of file qsoundqss_qws.cpp.

160  :
161  QObject( parent )
162 {
163  socket = s;
164  priExist = false;
165  mCurrentID = nextId();
166  connect(socket,SIGNAL(readyRead()),
167  this,SLOT(tryReadCommand()));
168  connect(socket, SIGNAL(disconnected()), this, SLOT(deleteLater()));
169 }
#define SLOT(a)
Definition: qobjectdefs.h:226
QPointer< QWS_SOCK_BASE > socket
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145

◆ ~QWSSoundServerClient()

QWSSoundServerClient::~QWSSoundServerClient ( )

Definition at line 171 of file qsoundqss_qws.cpp.

172 {
173  if (priExist)
174  playPriorityOnly(false);
176  if (socket)
177  socket->deleteLater();
178 }
QPointer< QWS_SOCK_BASE > socket
#define emit
Definition: qobjectdefs.h:76
void playPriorityOnly(bool)

Functions

◆ nextId()

static int QWSSoundServerClient::nextId ( )
inlinestaticprivate

Definition at line 154 of file qsoundqss_qws.cpp.

Referenced by QWSSoundServerClient().

154 { return ++lastId; }

◆ pause

void QWSSoundServerClient::pause ( int  ,
int   
)
signal

Referenced by tryReadCommand().

◆ play [1/2]

void QWSSoundServerClient::play ( int  ,
int  ,
const QString  
)
signal

Referenced by tryReadCommand().

◆ play [2/2]

void QWSSoundServerClient::play ( int  ,
int  ,
const QString ,
int  ,
int   
)
signal

◆ playPriorityOnly

void QWSSoundServerClient::playPriorityOnly ( bool  )
signal

◆ playRaw

void QWSSoundServerClient::playRaw ( int  ,
int  ,
const QString ,
int  ,
int  ,
int  ,
int   
)
signal

Referenced by tryReadCommand().

◆ resume

void QWSSoundServerClient::resume ( int  ,
int   
)
signal

Referenced by tryReadCommand().

◆ sendClientMessage()

void QWSSoundServerClient::sendClientMessage ( QString  msg)
private

Definition at line 244 of file qsoundqss_qws.cpp.

Referenced by sendDeviceError(), sendDeviceReady(), and sendSoundCompleted().

245 {
246 #ifndef QT_NO_TEXTCODEC
247  QByteArray u = msg.toUtf8();
248 #else
249  QByteArray u = msg.toLatin1();
250 #endif
251  socket->write(u.data(), u.length());
252  socket->flush();
253 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
quint16 u
QPointer< QWS_SOCK_BASE > socket
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
int length() const
Same as size().
Definition: qbytearray.h:356

◆ sendDeviceError

void QWSSoundServerClient::sendDeviceError ( int  gid,
int  sid,
int  err 
)
slot

Definition at line 269 of file qsoundqss_qws.cpp.

270 {
271  if (gid == mCurrentID)
272  sendClientMessage(QLatin1String("DEVICEERROR ")
273  + QString::number(sid) + QLatin1Char(' ')
274  + QString::number(err) + QLatin1Char('\n'));
275 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void sendClientMessage(QString msg)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ sendDeviceReady

void QWSSoundServerClient::sendDeviceReady ( int  gid,
int  sid 
)
slot

Definition at line 262 of file qsoundqss_qws.cpp.

263 {
264  if (gid == mCurrentID)
265  sendClientMessage(QLatin1String("DEVICEREADY ")
266  + QString::number(sid) + QLatin1Char('\n'));
267 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void sendClientMessage(QString msg)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ sendSoundCompleted

void QWSSoundServerClient::sendSoundCompleted ( int  gid,
int  sid 
)
slot

Definition at line 255 of file qsoundqss_qws.cpp.

256 {
257  if (gid == mCurrentID)
258  sendClientMessage(QLatin1String("SOUNDCOMPLETED ")
259  + QString::number(sid) + QLatin1Char('\n'));
260 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void sendClientMessage(QString msg)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ setMute

void QWSSoundServerClient::setMute ( int  ,
int  ,
bool   
)
signal

Referenced by tryReadCommand().

◆ setSilent

void QWSSoundServerClient::setSilent ( bool  )
signal

Referenced by tryReadCommand().

◆ setVolume

void QWSSoundServerClient::setVolume ( int  ,
int  ,
int  ,
int   
)
signal

Referenced by tryReadCommand().

◆ stop

void QWSSoundServerClient::stop ( int  ,
int   
)
signal

Referenced by tryReadCommand().

◆ stopAll

void QWSSoundServerClient::stopAll ( int  )
signal

Referenced by ~QWSSoundServerClient().

◆ tryReadCommand

void QWSSoundServerClient::tryReadCommand ( )
privateslot

Definition at line 199 of file qsoundqss_qws.cpp.

Referenced by QWSSoundServerClient().

200 {
201  while ( socket->canReadLine() ) {
202  QString l = QString::fromAscii(socket->readLine());
203  l.truncate(l.length()-1); // chomp
204  QString functionName = getStringTok(l);
205  int soundid = getNumTok(l);
206  if (functionName == QLatin1String("PLAY")) {
207  emit play(mCurrentID, soundid, l);
208  } else if (functionName == QLatin1String("PLAYEXTEND")) {
209  int volume = getNumTok(l);
210  int flags = getNumTok(l);
211  emit play(mCurrentID, soundid, l, volume, flags);
212  } else if (functionName == QLatin1String("PLAYRAW")) {
213  int chs = getNumTok(l);
214  int freq = getNumTok(l);
215  int bitspersample = getNumTok(l);
216  int flags = getNumTok(l);
217  emit playRaw(mCurrentID, soundid, l, freq, chs, bitspersample, flags);
218  } else if (functionName == QLatin1String("PAUSE")) {
219  emit pause(mCurrentID, soundid);
220  } else if (functionName == QLatin1String("STOP")) {
221  emit stop(mCurrentID, soundid);
222  } else if (functionName == QLatin1String("RESUME")) {
223  emit resume(mCurrentID, soundid);
224  } else if (functionName == QLatin1String("SETVOLUME")) {
225  int left = getNumTok(l);
226  int right = getNumTok(l);
227  emit setVolume(mCurrentID, soundid, left, right);
228  } else if (functionName == QLatin1String("MUTE")) {
229  emit setMute(mCurrentID, soundid, true);
230  } else if (functionName == QLatin1String("UNMUTE")) {
231  emit setMute(mCurrentID, soundid, false);
232  } else if (functionName == QLatin1String("PRIORITYONLY")) {
233  bool sPri = soundid != 0;
234  if (sPri != priExist) {
235  priExist = sPri;
236  emit playPriorityOnly(sPri);
237  }
238  } else if(functionName == QLatin1String("SILENT")) {
239  emit setSilent( soundid != 0 );
240  }
241  }
242 }
static QString getStringTok(QString &in)
void playRaw(int, int, const QString &, int, int, int, int)
void pause(int, int)
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QPointer< QWS_SOCK_BASE > socket
void setMute(int, int, bool)
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
#define emit
Definition: qobjectdefs.h:76
static int getNumTok(QString &in)
void playPriorityOnly(bool)
void stop(int, int)
void play(int, int, const QString &)
void setVolume(int, int, int, int)
QFactoryLoader * l
void resume(int, int)

Properties

◆ lastId

int QWSSoundServerClient::lastId = 0
staticprivate

Definition at line 153 of file qsoundqss_qws.cpp.

◆ left

int QWSSoundServerClient::left
private

Definition at line 151 of file qsoundqss_qws.cpp.

Referenced by tryReadCommand().

◆ mCurrentID

int QWSSoundServerClient::mCurrentID
private

◆ priExist

bool QWSSoundServerClient::priExist
private

Definition at line 152 of file qsoundqss_qws.cpp.

Referenced by QWSSoundServerClient(), tryReadCommand(), and ~QWSSoundServerClient().

◆ right

int QWSSoundServerClient::right
private

Definition at line 151 of file qsoundqss_qws.cpp.

Referenced by tryReadCommand().

◆ socket

QPointer<QWS_SOCK_BASE> QWSSoundServerClient::socket
private

The documentation for this class was generated from the following file: