email/mail/ViewerSrc/cmsgmailviewerreplytomatcher.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Mail viewer reply to address matcher.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cmsgmailviewerreplytomatcher.h"
       
    20 #include "cmsgmailviewercontactmatcher.h"
       
    21 #include "MsgMailViewerAppUi.h"
       
    22 
       
    23 #include <e32std.h>
       
    24 #include <MsgAddressControl.h>
       
    25 #include <SenduiMtmUids.h>
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // CMsgMailViewerReplyToMatcher
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CMsgMailViewerReplyToMatcher::CMsgMailViewerReplyToMatcher(
       
    32 		CMsgMailViewerAppUi& aAppUi, CMsgMailViewerContactMatcher& aMatcher)
       
    33     :iContactMacther(aMatcher), 
       
    34     iAppUi(aAppUi)
       
    35     {
       
    36     
       
    37     }
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // NewL
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 CMsgMailViewerReplyToMatcher* CMsgMailViewerReplyToMatcher::NewL(
       
    44 		CMsgMailViewerAppUi& aAppUi, CMsgMailViewerContactMatcher& aMatcher)
       
    45     {
       
    46     CMsgMailViewerReplyToMatcher* self =
       
    47         new( ELeave ) CMsgMailViewerReplyToMatcher(aAppUi, aMatcher);
       
    48     
       
    49     return self;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // ~CMsgMailViewerReplyToMatcher
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CMsgMailViewerReplyToMatcher::~CMsgMailViewerReplyToMatcher()
       
    57     {
       
    58     delete iData;
       
    59     delete iName;
       
    60     } 
       
    61 
       
    62 
       
    63 //----------------------------------------------------------------------------
       
    64 //  AddressMatchCallbackL()
       
    65 //----------------------------------------------------------------------------
       
    66 TInt CMsgMailViewerReplyToMatcher::AddressMatchCallbackL(TAny* aAny)	// CSI: 40 # We must return 
       
    67 																		// the integer value although this 
       
    68 																		// is a leaving method.
       
    69 	{
       
    70 	static_cast<CMsgMailViewerReplyToMatcher*>(aAny)->NotifyMatchingReadyL();	
       
    71 	return 0; // one-time TCallBack call
       
    72 	}
       
    73 	
       
    74 //----------------------------------------------------------------------------
       
    75 //  NotifyMatchingReadyL()
       
    76 //----------------------------------------------------------------------------
       
    77 void CMsgMailViewerReplyToMatcher::NotifyMatchingReadyL()
       
    78     {
       
    79     //Get data which user has selected from contact matcher.
       
    80     iData = iContactMacther.GetDataL();
       
    81     
       
    82     if( iData )
       
    83         {
       
    84         //Get name for contact.
       
    85         iName = iContactMacther.GetNameL();
       
    86         iAppUi.DoReplyViaL(iSendingMtmUid, iData, iName);
       
    87         }
       
    88     else
       
    89         {
       
    90         iAppUi.DoReplyViaL(iSendingMtmUid, NULL, NULL);
       
    91         }
       
    92     }
       
    93     
       
    94         
       
    95 //----------------------------------------------------------------------------
       
    96 //  CheckMatchesL()
       
    97 //----------------------------------------------------------------------------
       
    98 void CMsgMailViewerReplyToMatcher::CheckMatchesL(TUid aMtmUid, CMsgRecipientArray* aRecs)
       
    99     {
       
   100     iSendingMtmUid = aMtmUid;
       
   101     
       
   102     if ( aRecs )
       
   103         {
       
   104         TInt count( aRecs->Count() );
       
   105         
       
   106         if(count > 0)
       
   107             {
       
   108             //We can only have one from-adderess
       
   109             iContactMacther.FindContactL(*aRecs->At(0)->Address(), 
       
   110             		CMsgMailViewerContactMatcher::EMsgToContact, 
       
   111             		TCallBack(AddressMatchCallbackL, this));    
       
   112             }
       
   113         else
       
   114             {
       
   115             User::Leave(KErrNotFound);
       
   116             }
       
   117         }
       
   118     }