emailservices/emailstore/message_store/server/src/MessageStoreSession.cpp
branchRCL_3
changeset 63 d189ee25cf9d
parent 24 b5fbb9b25d57
child 64 3533d4323edc
--- a/emailservices/emailstore/message_store/server/src/MessageStoreSession.cpp	Thu Aug 19 09:38:05 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/MessageStoreSession.cpp	Tue Aug 31 15:04:17 2010 +0300
@@ -21,8 +21,8 @@
 // INCLUDES
 // ========
 
-#include "msgstoretypes.h"
-#include "msgstorepropertykeys.h"
+#include "MsgStoreTypes.h"
+#include "MsgStorePropertyKeys.h"
 
 #include "MessageStoreSession.h"
 #include "MessageStoreServer.h"
@@ -112,10 +112,23 @@
     {
     __LOG_ENTER( "CreateL" )
     
-    iServer.AddSession( this );
+    iServer.AddSessionL( this );
 
     // This could leave if a session is created while the store is unavailable.
-    TRAP_IGNORE( iServer.MessageStoreL().ObserveL( this ) );
+    TRAPD( err, iServer.MessageStoreL().ObserveL( this ) );
+    
+    // We need to leave the Session active in the case of KErrInUse.  This is
+    // because if the observer is dropped during KErrInUse, they cannot
+    // re-establish connection, and they will not know when MS in no longer busy.
+    // As a result, they will retry for many seconds to connect, then permanently
+    // give up.  This is avoided by trapping KErrInUse.
+    // Thus, only dropSession and Leave for other errors
+    
+    if( err != KErrNone && err != KErrInUse )
+    {
+        iServer.DropSession( this );
+        User::Leave( err );
+    }
     
     __LOG_EXIT
     } // end CreateL
@@ -694,12 +707,16 @@
         	event.iOtherId     = KMsgStoreInvalidId;
         	event.iFlags       = KMsgStoreFlagsNotFound;
 
-    		iEventQueue.Append( event );		
+        	// return value can be ignored because queueing is very rare
+        	// case anyway and appending T-class into RArray should succeed
+    		TInt ignore = iEventQueue.Append( event );
 		    }
 		else
 		    {
     		__LOG_WRITE_INFO( "event queued" )
-    		iEventQueue.Append( aEvent );		
+            // return value can be ignored because queueing is very rare
+            // case anyway and appending T-class into RArray should succeed
+            TInt ignore = iEventQueue.Append( aEvent );
 		    } // end if		
 		}
 	else
@@ -1064,7 +1081,7 @@
 void CMessageStoreSession::DoMatchFoundL( TContainerId aMessageId, TContainerId aFolderId, const TDesC8& aPropertyBuf )
     {
     CSearchResult* result = CSearchResult::NewL( aMessageId, aFolderId, aPropertyBuf );
-    iMatchMessages.Append( result );
+    iMatchMessages.AppendL( result );
 
     SendMatchesToClient();
     } // end MatchFound
@@ -2185,7 +2202,7 @@
     TBool inMemorySort = aMessage.Int3();
 
     TContainerId sessionId = iServer.MessageStoreL().StartSortingL( sortCriteria, iPropertyNames, inMemorySort );
-    iSortSessionIds.Append( sessionId );
+    iSortSessionIds.AppendL( sessionId );
     
     TPckg<TContainerId> sessionIdPckg( sessionId );
     aMessage.WriteL( 0, sessionIdPckg );
@@ -2582,7 +2599,7 @@
         
         CMruAddress* mruAddress = CMruAddress::NewL(0, addressDes, dispNameDes );
         
-        iMruAddressArray.Append( mruAddress );
+        iMruAddressArray.AppendL( mruAddress );
         
         } // end while
     
@@ -2787,7 +2804,7 @@
     for( position = 0; position < aMessage.GetDesLengthL( aIndex ); position += idPckg.Length() )
         {
         aMessage.ReadL( aIndex, idPckg, position );      
-        aArray.Append( id );
+        aArray.AppendL( id );
         } // end for
     }