Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

PRInt32 tmQueue::DetachClient ( PRUint32  aClientID  ) 

Removes the client from the list of queue listeners. A reply is created and sent to the client to indicate the success of the removal.

The reply is sent for all cases, with the status field set to either -1 or NS_OK.

Returns:
NS_OK on success

-1 if client is not attached to this queue

TM_SUCCESS_DELETE_QUEUE if there are no more listeners, instructing the Transaction Mangaer to delete the queue.

Definition at line 120 of file tmQueue.cpp.

References tmTransaction::Init(), tmVector::RemoveAt(), tmTransactionManager::SendTransaction(), and tmVector::Size().

Referenced by tmTransactionManager::HandleTransaction().

                                        {

  PRUint32 size = mListeners.Size();
  PRUint32 id = 0;
  PRInt32 status = -1;

  for (PRUint32 index = 0; index < size; index++) {
    id = (PRUint32)NS_PTR_TO_INT32(mListeners[index]);
    if(id == aClientID) {
      mListeners.RemoveAt(index);
      status = NS_OK;
      break;
    }
  }

  tmTransaction trans;
  if (NS_SUCCEEDED(trans.Init(aClientID,
                               mID,
                               TM_DETACH_REPLY,
                               status,
                               nsnull,
                               0))) {
    // send the reply
    mTM->SendTransaction(aClientID, &trans);
  }

  // if we've removed all the listeners, remove the queue.
  if (mListeners.Size() == 0)
    return TM_SUCCESS_DELETE_QUEUE;
  return status;
}


Generated by  Doxygen 1.6.0   Back to index