emailservices/emailstore/message_store/server/src/MessageStoreSession.cpp
changeset 51 d845db10c0d4
parent 0 8466d47a6819
child 62 a8c646b56683
equal deleted inserted replaced
49:00c7ae862740 51:d845db10c0d4
   110 // ==========================================================================
   110 // ==========================================================================
   111 void CMessageStoreSession::CreateL()
   111 void CMessageStoreSession::CreateL()
   112     {
   112     {
   113     __LOG_ENTER( "CreateL" )
   113     __LOG_ENTER( "CreateL" )
   114     
   114     
   115     iServer.AddSession( this );
   115     iServer.AddSessionL( this );
   116 
   116 
   117     // This could leave if a session is created while the store is unavailable.
   117     // This could leave if a session is created while the store is unavailable.
   118     TRAP_IGNORE( iServer.MessageStoreL().ObserveL( this ) );
   118     TRAPD( err, iServer.MessageStoreL().ObserveL( this ) );
       
   119     
       
   120     if( err != KErrNone )
       
   121     {
       
   122         iServer.DropSession( this );
       
   123         User::Leave( err );
       
   124     }
   119     
   125     
   120     __LOG_EXIT
   126     __LOG_EXIT
   121     } // end CreateL
   127     } // end CreateL
   122 
   128 
   123 // ==========================================================================
   129 // ==========================================================================
   692         	event.iId          = KMsgStoreInvalidId;
   698         	event.iId          = KMsgStoreInvalidId;
   693         	event.iParentId    = KMsgStoreInvalidId;
   699         	event.iParentId    = KMsgStoreInvalidId;
   694         	event.iOtherId     = KMsgStoreInvalidId;
   700         	event.iOtherId     = KMsgStoreInvalidId;
   695         	event.iFlags       = KMsgStoreFlagsNotFound;
   701         	event.iFlags       = KMsgStoreFlagsNotFound;
   696 
   702 
   697     		iEventQueue.Append( event );		
   703         	// return value can be ignored because queueing is very rare
       
   704         	// case anyway and appending T-class into RArray should succeed
       
   705     		TInt ignore = iEventQueue.Append( event );
   698 		    }
   706 		    }
   699 		else
   707 		else
   700 		    {
   708 		    {
   701     		__LOG_WRITE_INFO( "event queued" )
   709     		__LOG_WRITE_INFO( "event queued" )
   702     		iEventQueue.Append( aEvent );		
   710             // return value can be ignored because queueing is very rare
       
   711             // case anyway and appending T-class into RArray should succeed
       
   712             TInt ignore = iEventQueue.Append( aEvent );
   703 		    } // end if		
   713 		    } // end if		
   704 		}
   714 		}
   705 	else
   715 	else
   706 		{
   716 		{
   707 		__LOG_WRITE_INFO( "Sending event now" )
   717 		__LOG_WRITE_INFO( "Sending event now" )
  1062 // FUNCTION: DoMatchFoundL
  1072 // FUNCTION: DoMatchFoundL
  1063 // ==========================================================================
  1073 // ==========================================================================
  1064 void CMessageStoreSession::DoMatchFoundL( TContainerId aMessageId, TContainerId aFolderId, const TDesC8& aPropertyBuf )
  1074 void CMessageStoreSession::DoMatchFoundL( TContainerId aMessageId, TContainerId aFolderId, const TDesC8& aPropertyBuf )
  1065     {
  1075     {
  1066     CSearchResult* result = CSearchResult::NewL( aMessageId, aFolderId, aPropertyBuf );
  1076     CSearchResult* result = CSearchResult::NewL( aMessageId, aFolderId, aPropertyBuf );
  1067     iMatchMessages.Append( result );
  1077     iMatchMessages.AppendL( result );
  1068 
  1078 
  1069     SendMatchesToClient();
  1079     SendMatchesToClient();
  1070     } // end MatchFound
  1080     } // end MatchFound
  1071 
  1081 
  1072 // ==========================================================================
  1082 // ==========================================================================
  2183     
  2193     
  2184     //parameter 3
  2194     //parameter 3
  2185     TBool inMemorySort = aMessage.Int3();
  2195     TBool inMemorySort = aMessage.Int3();
  2186 
  2196 
  2187     TContainerId sessionId = iServer.MessageStoreL().StartSortingL( sortCriteria, iPropertyNames, inMemorySort );
  2197     TContainerId sessionId = iServer.MessageStoreL().StartSortingL( sortCriteria, iPropertyNames, inMemorySort );
  2188     iSortSessionIds.Append( sessionId );
  2198     iSortSessionIds.AppendL( sessionId );
  2189     
  2199     
  2190     TPckg<TContainerId> sessionIdPckg( sessionId );
  2200     TPckg<TContainerId> sessionIdPckg( sessionId );
  2191     aMessage.WriteL( 0, sessionIdPckg );
  2201     aMessage.WriteL( 0, sessionIdPckg );
  2192     
  2202     
  2193     aMessage.Complete( KErrNone );
  2203     aMessage.Complete( KErrNone );
  2580         
  2590         
  2581         position += length16;
  2591         position += length16;
  2582         
  2592         
  2583         CMruAddress* mruAddress = CMruAddress::NewL(0, addressDes, dispNameDes );
  2593         CMruAddress* mruAddress = CMruAddress::NewL(0, addressDes, dispNameDes );
  2584         
  2594         
  2585         iMruAddressArray.Append( mruAddress );
  2595         iMruAddressArray.AppendL( mruAddress );
  2586         
  2596         
  2587         } // end while
  2597         } // end while
  2588     
  2598     
  2589     iServer.MessageStoreL().SetMruAddressListL( mailboxId, iMruAddressArray );
  2599     iServer.MessageStoreL().SetMruAddressListL( mailboxId, iMruAddressArray );
  2590     
  2600     
  2722     while( position < aMessage.GetDesLengthL( aIndex ) )
  2732     while( position < aMessage.GetDesLengthL( aIndex ) )
  2723         {
  2733         {
  2724         aMessage.ReadL( aIndex, length16Pckg, position );        
  2734         aMessage.ReadL( aIndex, length16Pckg, position );        
  2725         position += length16Pckg.Length();
  2735         position += length16Pckg.Length();
  2726         
  2736         
  2727         HBufC8* buf8 = HBufC8::NewL( length16 );            
  2737         HBufC8* buf8 = HBufC8::NewLC( length16 );            
  2728         aArray.Append( buf8 );
       
  2729         TPtr8 buf8Ptr( buf8->Des() );
  2738         TPtr8 buf8Ptr( buf8->Des() );
  2730         aMessage.ReadL( aIndex, buf8Ptr, position );
  2739         aMessage.ReadL( aIndex, buf8Ptr, position );
  2731         buf8->Des().SetLength( length16 ); 
  2740         buf8->Des().SetLength( length16 ); 
       
  2741         aArray.AppendL( buf8 );
       
  2742         CleanupStack::Pop(buf8);
  2732         position += length16;
  2743         position += length16;
  2733         } // end while
  2744         } // end while
  2734     }
  2745     }
  2735 
  2746 
  2736 // ==========================================================================
  2747 // ==========================================================================
  2753         aMessage.ReadL( aIndex, length16Pckg, position );        
  2764         aMessage.ReadL( aIndex, length16Pckg, position );        
  2754         position += length16Pckg.Length();
  2765         position += length16Pckg.Length();
  2755         
  2766         
  2756         if ( readBuf.MaxLength() < length16 )
  2767         if ( readBuf.MaxLength() < length16 )
  2757             {
  2768             {
  2758             readBuf.ReAlloc( length16 );
  2769             readBuf.ReAllocL( length16 );
  2759             }
  2770             }
  2760         aMessage.ReadL( aIndex, readBuf, position );
  2771         aMessage.ReadL( aIndex, readBuf, position );
  2761         
  2772         
  2762         //now read convert the 8 bit descriptor to 16 descriptor
  2773         //now read convert the 8 bit descriptor to 16 descriptor
  2763         const TUint16* valuePtr = reinterpret_cast<const TUint16*>( readBuf.Ptr() );
  2774         const TUint16* valuePtr = reinterpret_cast<const TUint16*>( readBuf.Ptr() );
  2764         TPtrC valueDes( valuePtr, length16 / 2 );  
  2775         TPtrC valueDes( valuePtr, length16 / 2 );  
  2765         
  2776         
  2766         aArray.Append( valueDes.AllocL() );
  2777         HBufC *p = valueDes.AllocLC();
       
  2778         aArray.AppendL( p );
       
  2779         CleanupStack::Pop( p );
  2767         
  2780         
  2768         position += length16;
  2781         position += length16;
  2769         } // end while
  2782         } // end while
  2770     
  2783     
  2771     CleanupStack::PopAndDestroy( &readBuf );
  2784     CleanupStack::PopAndDestroy( &readBuf );
  2782 
  2795 
  2783     aArray.Reset();
  2796     aArray.Reset();
  2784     for( position = 0; position < aMessage.GetDesLengthL( aIndex ); position += idPckg.Length() )
  2797     for( position = 0; position < aMessage.GetDesLengthL( aIndex ); position += idPckg.Length() )
  2785         {
  2798         {
  2786         aMessage.ReadL( aIndex, idPckg, position );      
  2799         aMessage.ReadL( aIndex, idPckg, position );      
  2787         aArray.Append( id );
  2800         aArray.AppendL( id );
  2788         } // end for
  2801         } // end for
  2789     }
  2802     }
  2790 
  2803 
  2791 /**
  2804 /**
  2792  * 
  2805  *