mpx/commonframework/common/src/mpxmessagequeue.cpp
branchRCL_3
changeset 9 bee149131e4b
parent 0 a2952bb97e68
--- a/mpx/commonframework/common/src/mpxmessagequeue.cpp	Tue Feb 02 00:27:58 2010 +0200
+++ b/mpx/commonframework/common/src/mpxmessagequeue.cpp	Fri Feb 19 23:18:32 2010 +0200
@@ -302,4 +302,36 @@
                this, data, err, ret);
     }
 
+// ----------------------------------------------------------------------------
+// Adds a message into the top of the queue and sends the message if slot is available
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TInt CMPXMessageQueue::AddFirst(const CMPXMessage* aMessage, TInt aError)
+    {
+    // aMessage should not be NULL and aError is KErrNone
+    MPX_ASSERT(aMessage || aError);
+    MPX_FUNC_EX("CMPXMessageQueue::AddFirst()");
+    CMPXMessageItem* item(NULL);
+    TRAPD(err, item = CMPXMessageItem::NewL(aMessage, aError));
+    if (KErrNone==err)
+        {
+        iMsgs.AddFirst(*item);
+#ifdef _DEBUG
+        MPX_DEBUG3("CMPXMessageQueue::AddFirst 0x%08x, items %d", this, ++iCount);
+#endif
+        }//else failed to create message item.
+    else
+        {
+        MPX_DEBUG2("CMPXMessageQueue::AddFirst Failed to create message item %d", err);
+        }
+    if (KErrNone!=err && KErrNone==iFailure)
+        { // Set the failure code
+        iFailure = err;
+        }
+    if (!iMsgRequest.IsNull())
+        { // outstanding request
+        Send();
+        } // else client has not finished current message yet
+    return err;
+    }
 // End of file