wvuing/wvuiave/AppSrc/CCAConversationsView.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     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:  view class for conversation view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include	"chatngclient.hrh"
       
    21 #include	"CCAConversationsView.h"
       
    22 #include	"CCAConversationsContainer.h"
       
    23 #include    "CCAUISessionManager.h"
       
    24 #include	"CCAStatusPaneHandler.h"
       
    25 #include	"CCAAppUi.h"
       
    26 #include	"CAExternalInterface.h"
       
    27 #include	"CCAMessageEditor.h"
       
    28 #include	"ChatDebugPrint.h"
       
    29 #include    "ChatDefinitions.h"
       
    30 #include    "CAExternalInterface.h"
       
    31 #include    "IMNoteMapper.h"
       
    32 #include    "IMDialogUtils.h"
       
    33 #include	"ImpsCSPAllErrors.h"
       
    34 #include    "CCAMessageExtensionsHandler.h"
       
    35 #include    "CCAFadeControl.h"
       
    36 #include    "MCAIndicatorTerminator.h"
       
    37 #include    "MCAMessageExtension.h"
       
    38 #include    "IMUtils.h"
       
    39 #include    "CCAUiMessageUtils.h"
       
    40 #include    "CAUtils.h"
       
    41 #include    "CCAPCUtils.h"
       
    42 #include	"CCAApp.h"
       
    43 #include    "CCAContactSelectionDialog.h"
       
    44 #include	"CCAVariantFactory.h"
       
    45 
       
    46 #include    "MCAConversationMessage.h"
       
    47 #include    "MCAMessageCreator.h"
       
    48 #include    "MCASettingsPC.h"
       
    49 #include    "mcamessagecontainerinfo.h"
       
    50 #include    "IMPRivateCRKeys.h"
       
    51 #include    "IMVariant.hrh"
       
    52 
       
    53 #include	<eikbtgpc.h>
       
    54 #include	<eikgted.h> //For the CEikGlobalTextEditor
       
    55 #include	<eikmenup.h>
       
    56 #include	<eikmenub.h>
       
    57 #include	<aknpopup.h>
       
    58 #include	<aknnotewrappers.h>
       
    59 #include    <stringloader.h>
       
    60 #include    <aknenv.h>
       
    61 #include 	<aknlists.h>
       
    62 #include	<flogger.h>
       
    63 #include	<utf.h>
       
    64 #include 	<txtrich.h>
       
    65 #include	<aknquerydialog.h>
       
    66 #include	<chatNG.rsg>
       
    67 #include	<CAVariationNG.rsg>
       
    68 #include    <NewFileService.hrh> // TNewServiceFileType
       
    69 
       
    70 #include	<bldvariant.hrh>
       
    71 #include    <hlplch.h>
       
    72 #include    <FeatMgr.h>
       
    73 
       
    74 #include    <finditem.hrh>
       
    75 #include    <finditemmenu.h>
       
    76 
       
    77 #include    <commonuiinternalcrkeys.h>
       
    78 
       
    79 #include 	"MCAConversationPC.h"
       
    80 #include	"MCAProcessManager.h"
       
    81 #include	"MCAServerContactsArrayPC.h"
       
    82 #include    "CCAGroupUtils.h"
       
    83 #include    "MCALoginPC.h"
       
    84 #include    "CCaSyncChecker.h"
       
    85 #include 	"MCAMainViewArrayPC.h"
       
    86 // The Settings have been moved to Cenrep (also retained in the Resource file),
       
    87 // so the enums for keys and central repository header is added here
       
    88 #include 	"VariantKeys.h"
       
    89 const TInt KMaxTitleLength = 32;
       
    90 
       
    91 // ============================ MEMBER FUNCTIONS ===============================
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CCAConversationsView::CCAConversationsView()
       
    95 // C++ default constructor can NOT contain any code, that
       
    96 // might leave.
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 CCAConversationsView::CCAConversationsView()
       
   100         : iCleanSender( NULL, 0 ),
       
   101         iLastUnreadIndex( KErrNotFound ),
       
   102         iForeground( ETrue )
       
   103     {
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CCAConversationsView::ConstructL()
       
   108 // Symbian 2nd phase constructor can leave.
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CCAConversationsView::ConstructL( TInt aAvkonViewResourceId, TUid aViewId,
       
   112                                        CCAMessageExtensionsHandler& aMessageHandler )
       
   113     {
       
   114     BaseConstructL( aAvkonViewResourceId, aViewId );
       
   115 
       
   116     iMessageHandler = &aMessageHandler;
       
   117 
       
   118     iFindContextMenu = new( ELeave ) CEikMenuBar;
       
   119     iFindContextMenu->ConstructL( this, 0, R_CHATCLIENT_MENUBAR_FINDITEMUI );
       
   120 
       
   121     iAddAndReplyMenu = new( ELeave ) CEikMenuBar;
       
   122     iAddAndReplyMenu->ConstructL(
       
   123         this,
       
   124         0,
       
   125         R_CHATCLIENT_MENUBAR_ADDANDREPLY );
       
   126 
       
   127     iContactId = HBufC::NewL( KMaxChatGroupLenght );
       
   128     iListId = HBufC::NewL( KMaxChatGroupLenght );
       
   129     iFindMenu = CFindItemMenu::NewL( EChatClientFindMenuPlaceHolder );
       
   130     iFindMenu->AttachItemFinderMenuL( R_CHATCLIENT_IBOX_VIEW_MENU );
       
   131     // automatic finder on by default
       
   132     iFindMenu->HandleItemFinderCommandL( EFindItemCmdEnableAutoFind );
       
   133     iItemFinder = CItemFinder::NewL();
       
   134 
       
   135     iAppUI = static_cast <CCAAppUi*> ( CCoeEnv::Static()->AppUi() );
       
   136 
       
   137     iConversationPC = iAppUI->GetProcessManager().GetConversationInterface();
       
   138 
       
   139     iTitlePane = iAppUI->CAStatusPane();
       
   140     }
       
   141 
       
   142 // Destructor
       
   143 CCAConversationsView::~CCAConversationsView()
       
   144     {
       
   145 
       
   146 
       
   147 
       
   148     if ( iContainer && iAppUI )
       
   149         {
       
   150         iAppUI->RemoveFromViewStack( *this, iContainer );
       
   151         }
       
   152 
       
   153     delete iContainer;
       
   154 
       
   155     if ( iAddAndReplyMenu && iAppUI )
       
   156         {
       
   157         iAppUI->RemoveFromViewStack( *this, iAddAndReplyMenu );
       
   158         }
       
   159 
       
   160     if ( iFindContextMenu && iAppUI )
       
   161         {
       
   162         iAppUI->RemoveFromStack( iFindContextMenu );
       
   163         }
       
   164 
       
   165     delete iFindContextMenu;
       
   166     delete iAddAndReplyMenu;
       
   167     delete iContactId;
       
   168     if ( iListId )
       
   169         {
       
   170         delete iListId;
       
   171         }
       
   172     delete iTitle;
       
   173     delete iSender;
       
   174     delete iFindMenu;
       
   175     delete iItemFinder;
       
   176     delete iEditorContent;
       
   177     }
       
   178 
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CCAConversationsView::HandleCbaChangeL()
       
   182 // (other items were commented in a header).
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 void CCAConversationsView::HandleCbaChangeL( TInt aResourceId )
       
   186     {
       
   187     Cba()->SetCommandSetL( aResourceId );
       
   188     Cba()->DrawNow();
       
   189     }
       
   190 
       
   191 // ---------------------------------------------------------
       
   192 // CCAConversationsView::SetLastUnreadIndex()
       
   193 // Sets last unread message index
       
   194 // (other items were commented in a header).
       
   195 // ---------------------------------------------------------
       
   196 //
       
   197 void CCAConversationsView::SetLastUnreadIndex(
       
   198     const TInt aLastUnreadIndex /* = -1  */ )
       
   199     {
       
   200     iLastUnreadIndex = aLastUnreadIndex;
       
   201     }
       
   202 
       
   203 
       
   204 // ---------------------------------------------------------
       
   205 // CCAConversationsView::CloseConversationL()
       
   206 // (other items were commented in a header).
       
   207 // ---------------------------------------------------------
       
   208 //
       
   209 void CCAConversationsView::CloseConversationL()
       
   210     {
       
   211 
       
   212     MCAMainViewArrayPC* mainViewArrayPC = iAppUI->GetProcessManager().GetArrayInterface();
       
   213 
       
   214     if ( iTitlePane )
       
   215         {
       
   216         HBufC* identification = iTitlePane->GetTabItemIdentification( iTabId ).AllocLC();
       
   217 
       
   218 
       
   219         HBufC* prompt = StringLoader::LoadLC( R_CLOSE_CONVERSATION_PROMPT,
       
   220                                               *identification );
       
   221 
       
   222 
       
   223         CAknQueryDialog* dlg = new ( ELeave ) CAknQueryDialog(
       
   224             CAknQueryDialog::ENoTone );
       
   225 
       
   226         CleanupStack::PushL( dlg );
       
   227 
       
   228         dlg->SetPromptL( *prompt );
       
   229 
       
   230         CleanupStack::Pop( dlg );
       
   231 
       
   232         TInt ret( dlg->ExecuteLD( R_CLOSE_COVERSATION_QUERY ) );
       
   233 
       
   234         CleanupStack::PopAndDestroy( 2, identification ); // prompt, identification
       
   235 
       
   236 
       
   237         if ( ( ret == EAknSoftkeyOk ) || ( ret == EAknSoftkeyYes ) )
       
   238             {
       
   239             // hide button group to prevent back button using during close
       
   240             iCba = CEikButtonGroupContainer::Current();
       
   241             iCba->MakeVisible( EFalse );
       
   242             iCba->DrawNow();
       
   243 
       
   244             iConversationPC->DeleteChatL( KNullDesC,
       
   245                                           KNullDesC,
       
   246                                           *iContactId );
       
   247 
       
   248             //To remove the item from open chats array when conv is closed
       
   249             mainViewArrayPC->RemoveConversationItem( *iContactId );
       
   250 
       
   251             // Deregister conversation from switch back views
       
   252             iAppUI->DeRegisterSwitchBack( KUidConversationsView,
       
   253                                           *iContactId );
       
   254             if ( iTitlePane )
       
   255                 {
       
   256                 //iTitlePane->DeleteTab(iTabId);
       
   257                 iTitlePane->SynchroniseAndRemoveTabGroup();
       
   258                 }
       
   259 
       
   260             iAppUI->SwitchViewBackL( KUidFriendsListView );
       
   261             //iAppUI->SwitchViewL( KUidFriendsListView );
       
   262 
       
   263             // XXX before or after SwitchView
       
   264             iCba->MakeVisible( ETrue );
       
   265             iCba->DrawNow();
       
   266             }
       
   267         }
       
   268     }
       
   269 
       
   270 // ---------------------------------------------------------
       
   271 // CCAConversationsView::DynInitMenuPaneL
       
   272 // Called when menupane is about to be shown.
       
   273 // ---------------------------------------------------------
       
   274 //
       
   275 void CCAConversationsView::DynInitMenuPaneL(
       
   276     TInt aResourceId, CEikMenuPane* aMenuPane )
       
   277     {
       
   278     TInt Temp = aMenuPane->NumberOfItemsInPane();
       
   279     TBool showFwdToContact = iContainer->FwdContactVisible();
       
   280     TBool showFwdToGroup   = iContainer->FwdGroupVisible();
       
   281 
       
   282     if ( ! iAppUI->UISessionManager().IsSupported( CCAUISessionManager::EGroup ) )
       
   283         {
       
   284         // groups are not supported, hide forward to group
       
   285         showFwdToGroup = EFalse;
       
   286         }
       
   287 
       
   288     TBool showForwardMenu = showFwdToGroup || showFwdToContact;
       
   289 
       
   290     // if we're displaying general menu and help feature is not supported..
       
   291     switch ( aResourceId )
       
   292         {
       
   293 
       
   294             //added for edit text, writing language options
       
   295             /*  case R_CHATCLIENT_TEXTEDIT_MENU:
       
   296               	{
       
   297 
       
   298               	TBool editorFocus = iContainer->Editor().IsFocused();
       
   299 
       
   300               	aMenuPane->SetItemDimmed( EChatClientEditText, !editorFocus );
       
   301               	aMenuPane->SetItemDimmed( EAknCmdInputLanguage, !editorFocus );
       
   302               	break;
       
   303 
       
   304               	}*/
       
   305 
       
   306         case R_CHATCLIENT_GENERAL_MENU:
       
   307             {
       
   308             aMenuPane->SetItemDimmed( EChatClientCmdHelp,
       
   309                                       !FeatureManager::FeatureSupported( KFeatureIdHelp ) );
       
   310             break;
       
   311             }
       
   312         case R_CHATCLIENT_ADDANDREPLY_MENU:
       
   313             {
       
   314             aMenuPane->SetItemDimmed( EChatClientIboxReply, ETrue );
       
   315             if ( iConversationPC->FindAnyContact( *iContactId ) )
       
   316                 {
       
   317                 aMenuPane->SetItemDimmed( EChatClientSearchAddFriends, ETrue );
       
   318                 }
       
   319             break;
       
   320             }
       
   321         case R_CHATCLIENT_IBOX_VIEW_MENU:
       
   322             {
       
   323             TBool text( iContainer->Editor().TextLength() != 0 );
       
   324             TBool openable = EFalse;
       
   325             TBool savePossible( EFalse );
       
   326             TBool object = iContainer->IsObjectSelected( openable, savePossible );
       
   327 
       
   328             //	IM client UI customization, phase 2
       
   329             //  Based on Variation flag, Show Templates
       
   330             TBool showTemplates = IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_SHOW_TEMPLATES );
       
   331             // Convention does not allow comparison to NULL, using ugly if/else
       
   332             TBool contactInList;
       
   333 
       
   334             if ( iConversationPC->FindAnyContact( *iContactId ) )
       
   335                 {
       
   336                 contactInList = ETrue;
       
   337                 }
       
   338             else
       
   339                 {
       
   340                 contactInList = EFalse;
       
   341                 }
       
   342 
       
   343             // "send"
       
   344             aMenuPane->SetItemDimmed( EChatClientIboxViewSend, !text );
       
   345 
       
   346             // "insert smiley"
       
   347             if ( !iContainer->Editor().IsFocused() )
       
   348                 {
       
   349                 aMenuPane->SetItemDimmed(
       
   350                     EChatClientChatViewInsertSmiley, ETrue );
       
   351                 }
       
   352             else
       
   353                 {
       
   354                 aMenuPane->SetItemDimmed( EChatClientChatViewInsertSmiley,
       
   355                                           !iContainer->ExtensionFits( KChatSmileyLength ) );
       
   356                 }
       
   357 
       
   358             // "Templates"
       
   359             aMenuPane->SetItemDimmed( EChatClientIboxInsertTemplate, !showTemplates );
       
   360 
       
   361             // "open"
       
   362             aMenuPane->SetItemDimmed( EChatClientOpenObject, !openable );
       
   363 
       
   364             // "save"
       
   365             aMenuPane->SetItemDimmed( EChatClientSaveObject, !savePossible );
       
   366 
       
   367             // item finder menu
       
   368             aMenuPane->SetItemDimmed( EChatClientFindMenuPlaceHolder, ETrue );
       
   369             if ( iContainer->IsStopped() )
       
   370                 {
       
   371                 UpdateItemTypeL();
       
   372                 iFindMenu->AddItemFindMenuL( iItemFinder, aMenuPane,
       
   373                                              EChatClientFindMenuPlaceHolder,
       
   374                                              KNullDesC ); // we can ignore the sender here
       
   375                 }
       
   376 
       
   377             // "send image"
       
   378             if ( IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_SEND_IMAGE ) == 0 )
       
   379                 {
       
   380                 aMenuPane->SetItemDimmed( EChatClientSendImage, ETrue );
       
   381                 aMenuPane->SetItemDimmed( EChatClientSendImageCascade, ETrue );
       
   382                 }
       
   383             else
       
   384                 {
       
   385                 TBool cam( FeatureManager::FeatureSupported(
       
   386                                KFeatureIdCamera ) );
       
   387                 CHAT_DP( D_CHAT_LIT( " Camera %d" ), cam );
       
   388 
       
   389                 // if camera is supported, show cascade menu
       
   390                 // otherwise hide cascade menu
       
   391                 aMenuPane->SetItemDimmed( EChatClientSendImage, cam );
       
   392                 aMenuPane->SetItemDimmed( EChatClientSendImageCascade, !cam );
       
   393                 }
       
   394 
       
   395             // "forward" hiding logic case 3
       
   396             // Hide also when focus on object that is not openable
       
   397             if ( !showForwardMenu || ( object && !openable ) )
       
   398                 {
       
   399                 CHAT_DP_TXT( "CCAConversationsView::DynInitMenuPaneL \
       
   400 			              Hide the whole forward menu" );
       
   401                 aMenuPane->SetItemDimmed( EChatClientIboxForward, ETrue );
       
   402                 }
       
   403             else
       
   404                 {
       
   405                 CHAT_DP_TXT( "CCAConversationsView::DynInitMenuPaneL \
       
   406 			              Show the forward menu" );
       
   407                 aMenuPane->SetItemDimmed(
       
   408                     EChatClientIboxForward, !iContainer->IsStopped() );
       
   409                 }
       
   410 
       
   411             // "add to contacts"
       
   412             aMenuPane->SetItemDimmed( EChatClientSearchAddFriends,
       
   413                                       contactInList );
       
   414 
       
   415             // "save to conversations always show"
       
   416             aMenuPane->SetItemDimmed( EChatClientIboxRecord, EFalse );
       
   417 
       
   418             // "block", check if user block/unblock is supported
       
   419             if ( !iAppUI->UISessionManager().IsSupported( CCAUISessionManager::EBlock ) )
       
   420                 {
       
   421                 aMenuPane->SetItemDimmed( EChatClientIboxBlockOpt, ETrue );
       
   422                 }
       
   423             //As per new UI spec change own status is not avilable in conversation
       
   424             //view menu
       
   425             aMenuPane->SetItemDimmed( EChatClientMainViewCmdChangeStatus, ETrue );
       
   426 
       
   427             break;
       
   428             }
       
   429         case R_CHATCLIENT_IBOX_BLOCK_SUBMENU:
       
   430             {
       
   431             TBool blocked( iContainer->IsBlocked() );
       
   432             if ( blocked )
       
   433                 {
       
   434                 aMenuPane->SetItemDimmed( EChatClientIboxBlock, ETrue );
       
   435                 // show/hide "show blocked list" option
       
   436                 if ( !IMUtils::IntResourceValueL(
       
   437                          RSC_CHAT_VARIATION_SHOW_BLOCKED_LIST ) )
       
   438                     {
       
   439                     aMenuPane->SetItemDimmed( EChatClientIboxBlockShow, ETrue );
       
   440                     }
       
   441                 }
       
   442             break;
       
   443             }
       
   444         case R_CHATCLIENT_IBOX_FORWARD_SUBMENU:
       
   445             {
       
   446             aMenuPane->SetItemDimmed( EChatClientIboxForwardToGroup,
       
   447                                       ! showFwdToGroup );
       
   448             aMenuPane->SetItemDimmed( EChatClientIboxForwardToContact,
       
   449                                       ! showFwdToContact );
       
   450             break;
       
   451             }
       
   452 
       
   453         case R_CHATCLIENT_FINDITEMUI_MENU:
       
   454             {
       
   455             if ( iContainer->IsStopped() )
       
   456                 {
       
   457                 UpdateItemTypeL();
       
   458                 iFindMenu->AddItemFindMenuL( iItemFinder, aMenuPane,
       
   459                                              EFindItemContextMenuPlaceHolder,
       
   460                                              KNullDesC, // we can ignore the sender here
       
   461                                              EFalse, ETrue ); // context menu
       
   462                 }
       
   463             break;
       
   464             }
       
   465 
       
   466         default:
       
   467             {
       
   468             // update find menu
       
   469             iFindMenu->UpdateItemFinderMenuL( aResourceId, aMenuPane );
       
   470             break;
       
   471             }
       
   472         }
       
   473     }
       
   474 
       
   475 // ---------------------------------------------------------
       
   476 // CCAConversationsView::UpdateItemTypeL
       
   477 // (other items were commented in a header).
       
   478 // ---------------------------------------------------------
       
   479 //
       
   480 void CCAConversationsView::UpdateItemTypeL()
       
   481     {
       
   482     CItemFinder::CFindItemExt& item = iItemFinder->CurrentItemExt();
       
   483     switch ( iContainer->SelectedItemType() )
       
   484         {
       
   485         case CFindItemEngine::EFindItemSearchPhoneNumberBin:
       
   486             {
       
   487             item.iItemType = CItemFinder::EPhoneNumber;
       
   488             break;
       
   489             }
       
   490         case CFindItemEngine::EFindItemSearchMailAddressBin:
       
   491             {
       
   492             item.iItemType = CItemFinder::EEmailAddress;
       
   493             break;
       
   494             }
       
   495         case CFindItemEngine::EFindItemSearchURLBin:
       
   496             {
       
   497             item.iItemType = CItemFinder::EUrlAddress;
       
   498             break;
       
   499             }
       
   500         case CFindItemEngine::EFindItemSearchScheme:
       
   501             {
       
   502             item.iItemType = CItemFinder::EUriScheme;
       
   503             break;
       
   504             }
       
   505         case KErrNotFound:  // flowthrough
       
   506         default:
       
   507             {
       
   508             item.iItemType = CItemFinder::ENoneSelected;
       
   509             break;
       
   510             }
       
   511         }
       
   512     delete item.iItemDescriptor;
       
   513     item.iItemDescriptor = NULL;
       
   514     item.iItemDescriptor = iContainer->SelectedItemL();  // takes the ownership
       
   515 
       
   516     // this logic comes from CItemFinder::ResolveAndSetItemTypeL.
       
   517     // should be in ItemFinder engine, but for some reason it isn't,
       
   518     // so, next few lines are copypasted from AknItemFinder.cpp..
       
   519     if ( item.iItemType == CItemFinder::EUrlAddress )
       
   520         {
       
   521         // old url types need prefix in order to work w/ schemehandler
       
   522         const TDesC& pref = item.iItemDescriptor->Des().Left( 4 );
       
   523 
       
   524         //To avoid adding :http://" to rtsp links, we check it before it is done
       
   525         //and return.
       
   526         if ( pref.CompareF ( KIMRTSP().Left ( 4 ) ) == 0 )
       
   527             {
       
   528             return;
       
   529             }
       
   530 
       
   531         if ( pref.CompareF( KIMHTTPPREFIX().Left( 4 ) ) != 0 )
       
   532             {
       
   533             HBufC* tmp = item.iItemDescriptor->ReAlloc(
       
   534                              item.iItemDescriptor->Length() + KIMHTTPPREFIX().Length() );
       
   535             if ( tmp )
       
   536                 {
       
   537                 // realloc succeeded
       
   538                 item.iItemDescriptor = tmp;
       
   539                 item.iItemDescriptor->Des().Insert( 0, KIMHTTPPREFIX );
       
   540                 }
       
   541             }
       
   542         }
       
   543     if ( item.iItemType == CItemFinder::EUriScheme )
       
   544         {
       
   545         // some schemes (ie. "old ones") have special handling
       
   546         const TDesC& pref = item.iItemDescriptor->Des().Left( 4 );
       
   547         if ( pref.CompareF( KIMHTTPPREFIX().Left( 4 ) ) == 0
       
   548              || pref.CompareF( KIMRTSP ) == 0 )
       
   549             {
       
   550             item.iItemType = CItemFinder::EUrlAddress;
       
   551             }
       
   552         }
       
   553     }
       
   554 
       
   555 // ---------------------------------------------------------
       
   556 // CCAConversationsView::UpdateTitleL
       
   557 // (other items were commented in a header).
       
   558 // ---------------------------------------------------------
       
   559 //
       
   560 void CCAConversationsView::UpdateTitleL()
       
   561     {
       
   562     if ( iTitlePane )
       
   563         {
       
   564 
       
   565         HBufC* tempTitle = iTitlePane->GetTabItemIdentification( iTabId ).AllocL();
       
   566 
       
   567         delete iTitle;
       
   568         iTitle = tempTitle;
       
   569 
       
   570         iTitlePane->SetTitleL( *iTitle );
       
   571         }
       
   572     }
       
   573 
       
   574 // ---------------------------------------------------------
       
   575 // CCAConversationsView::StoreContent
       
   576 // (other items were commented in a header).
       
   577 // ---------------------------------------------------------
       
   578 //
       
   579 void CCAConversationsView::StoreContent( const HBufC* aContent )
       
   580     {
       
   581     // Delete previous stored content
       
   582     delete iEditorContent;
       
   583     iEditorContent = NULL;
       
   584     iEditorContent = aContent;
       
   585     }
       
   586 
       
   587 
       
   588 // ---------------------------------------------------------
       
   589 // CCAConversationsView::CheckBlockedL
       
   590 // (other items were commented in a header).
       
   591 // ---------------------------------------------------------
       
   592 //
       
   593 void CCAConversationsView::CheckBlockedL()
       
   594     {
       
   595     iContainer->CheckBlockedL();
       
   596     }
       
   597 
       
   598 // ---------------------------------------------------------
       
   599 // CCAConversationsView::HandleCommandL(TInt aCommand)
       
   600 // Handles commands
       
   601 // (other items were commented in a header).
       
   602 // ---------------------------------------------------------
       
   603 //
       
   604 void CCAConversationsView::HandleCommandL( TInt aCommand )
       
   605     {
       
   606     // This case is used to display the login query in offline mode.
       
   607     switch ( aCommand )
       
   608         {
       
   609         case EChatClientNewImage:
       
   610         case EChatClientFromPhotos:
       
   611         case EChatClientSendImage:
       
   612         case EChatClientIboxBlockEnter:
       
   613         case EChatClientIboxBlockShow:
       
   614         case EChatClientIboxBlock:
       
   615         case EChatClientIboxUnblock:
       
   616         case EChatClientIboxForwardToGroup:
       
   617         case EChatClientIboxForwardToContact:
       
   618         case EChatClientSearchAddFriends:
       
   619             {
       
   620             if ( !UISessionManager().LoginL( MCAUiLoginCmdCB::EQueryLogin ) )
       
   621                 {
       
   622                 return;
       
   623                 }
       
   624             break;
       
   625             }
       
   626         default:
       
   627             {
       
   628             break;
       
   629             }
       
   630 
       
   631         }
       
   632 
       
   633 #ifdef IMPS_CONTACT_FETCH_BACKGROUND
       
   634     switch ( aCommand )
       
   635         {
       
   636 
       
   637         case EChatClientIboxBlockEnter:
       
   638         case EChatClientIboxBlockShow:
       
   639         case EChatClientIboxBlock:
       
   640         case EChatClientIboxUnblock:
       
   641         case EChatClientIboxForwardToGroup:
       
   642         case EChatClientIboxForwardToContact:
       
   643         case EChatClientSearchAddFriends:
       
   644             {
       
   645             if ( !CCASyncChecker::CheckSyncStateL() )
       
   646                 {
       
   647                 return;
       
   648                 }
       
   649             break;
       
   650             }
       
   651         default:
       
   652             {
       
   653             break;
       
   654             }
       
   655 
       
   656         }
       
   657 #endif
       
   658 
       
   659     switch ( aCommand )
       
   660         {
       
   661         case EAknSoftkeyOpen:   // Flowthrough, MSK command
       
   662         case EChatClientOpenObject:
       
   663             {
       
   664             // Fix TELYG-7H2A6N
       
   665             if ( iObjectOpenedSaved )
       
   666                 {
       
   667                 return;
       
   668                 }
       
   669 
       
   670             MCAConversationMessage* msg = iContainer->SelectedMessage();
       
   671             if ( msg )
       
   672                 {
       
   673                 CCAUiMessageUtils* utils = CCAUiMessageUtils::NewLC();
       
   674                 // Set the indicator to true
       
   675                 iObjectOpenedSaved = ETrue;
       
   676                 TRAPD( err, utils->OpenObjectL( *msg ) );
       
   677                 // Set it back
       
   678                 iObjectOpenedSaved = EFalse;
       
   679 
       
   680                 CleanupStack::PopAndDestroy( utils );
       
   681                 User::LeaveIfError( err );
       
   682                 }
       
   683             break;
       
   684             }
       
   685         case EChatClientSaveObject:
       
   686             {
       
   687             // Fix TELYG-7H2A6N
       
   688             if ( iObjectOpenedSaved )
       
   689                 {
       
   690                 return;
       
   691                 }
       
   692 
       
   693             MCAConversationMessage* msg = iContainer->SelectedMessage();
       
   694             if ( msg )
       
   695                 {
       
   696                 CCAUiMessageUtils* utils = CCAUiMessageUtils::NewLC();
       
   697 
       
   698                 // Set the indicator to true
       
   699                 iObjectOpenedSaved = ETrue;
       
   700                 TRAPD( err, utils->SaveObjectL( *msg ) );
       
   701                 // Set it back
       
   702                 iObjectOpenedSaved = EFalse;
       
   703 
       
   704                 CleanupStack::PopAndDestroy( utils );
       
   705                 User::LeaveIfError( err );
       
   706                 }
       
   707             break;
       
   708             }
       
   709         case EChatClientNewImage:
       
   710             {
       
   711             // new file
       
   712             if ( iAppUI->UISessionManager().IsLoggedIn() )
       
   713                 {
       
   714                 iContainer->CheckReplyL();
       
   715 
       
   716                 CCAUiMessageUtils* utils = CCAUiMessageUtils::NewLC( this );
       
   717                 utils->SendNewFileL( ENewFileServiceImage,
       
   718                                      *iConversationPC );
       
   719                 CleanupStack::PopAndDestroy( utils );
       
   720 
       
   721                 }
       
   722             break;
       
   723             }
       
   724         case EChatClientFromPhotos: // flowthrough
       
   725         case EChatClientSendImage:
       
   726             {
       
   727             if ( iAppUI->UISessionManager().IsLoggedIn() )
       
   728                 {
       
   729                 iContainer->CheckReplyL();
       
   730                 CCAUiMessageUtils* utils = CCAUiMessageUtils::NewLC( this );
       
   731 
       
   732                 iCba = CEikButtonGroupContainer::Current();
       
   733 
       
   734                 if ( iCba )
       
   735                     {
       
   736                     iCba->MakeCommandVisible( EAknSoftkeyOptions, EFalse );
       
   737                     iCba->MakeCommandVisible( EAknSoftkeyBack, EFalse );
       
   738                 	iCba->MakeCommandVisible( EChatClientChatViewContinue, EFalse );
       
   739                     iCba->DrawNow();
       
   740                     }
       
   741 
       
   742                 utils->SendImageL( *iConversationPC );
       
   743                 iCba = CEikButtonGroupContainer::Current();
       
   744 
       
   745                 if ( iCba )
       
   746                     {
       
   747                     iCba->MakeCommandVisible( EAknSoftkeyOptions, ETrue );
       
   748                     iCba->MakeCommandVisible( EAknSoftkeyBack, ETrue );
       
   749                 	iCba->MakeCommandVisible( EChatClientChatViewContinue, ETrue );
       
   750                     iCba->DrawNow();
       
   751                     }
       
   752 
       
   753                 CleanupStack::PopAndDestroy( utils );
       
   754                 }
       
   755             break;
       
   756             }
       
   757 
       
   758         // flow through
       
   759         case EChatClientCmdBack:
       
   760         case EAknSoftkeyBack:
       
   761             {
       
   762             if ( iTitlePane )
       
   763                 {
       
   764                 iTitlePane->SynchroniseAndRemoveTabGroup();
       
   765                 }
       
   766             if ( TEnumsPC::ERegister == iAppUI->RetForwardTo() )
       
   767                 {
       
   768                 iAppUI->SetResetForwardTo( TEnumsPC::EToBeUnregistered );
       
   769 
       
   770                 iAppUI->SwitchViewL( KUidFriendsListView );
       
   771                 }
       
   772             else
       
   773                 {
       
   774                 if ( TEnumsPC::EAlreadyRegistered == iAppUI->RetForwardTo() )
       
   775                     {
       
   776                     // Deregister conversation from switch back views
       
   777                     iAppUI->UnRegisterPreviousview();
       
   778                     iAppUI->SetResetForwardTo( TEnumsPC::EUnregistered );
       
   779                     }
       
   780                 TCADnlConvInvGroupFocus dnlConvInvGroupFocus;
       
   781                 dnlConvInvGroupFocus.iInvConvGroupID.Copy( iContactId->Des().Left( KMaxWVIDLength ) );
       
   782                 dnlConvInvGroupFocus.iListID.Copy( iListId->Des().Left( KMaxWVIDLength ) );
       
   783                 dnlConvInvGroupFocus.iType = EConversationItem;
       
   784                 TCADnlConvInvGroupFocusBuf convInvGroupFocusBuf( dnlConvInvGroupFocus );
       
   785                 iAppUI->SwitchViewBackL( KUidFriendsListView, KConvInvGroupFocusId, convInvGroupFocusBuf );
       
   786                 }
       
   787             break;
       
   788             }
       
   789         // flow through
       
   790         case EAknSoftkeySend:   // MSK command
       
   791         case EChatClientIboxViewSend:
       
   792         case EChatClientChatViewCmdSend:
       
   793             {
       
   794             iContainer->SendMessageL();
       
   795             break;
       
   796             }
       
   797 
       
   798         case EChatClientChatViewContinue:
       
   799             {
       
   800             iContainer->StartScrollingL();
       
   801             iAppUI->SetFocusFlag( ETrue );
       
   802             break;
       
   803             }
       
   804         case EChatClientSearchAddFriends:
       
   805             {
       
   806             iContainer->AddToFriendsL();
       
   807             break;
       
   808             }
       
   809 
       
   810         case EChatClientChatViewInsertSmiley:
       
   811             {
       
   812             TBool dialogCancelled = EFalse;
       
   813             iMessageHandler->InsertExtensionL( iContainer->Editor(),
       
   814                                                EMessageExtensionSmiley,
       
   815                                                dialogCancelled );
       
   816 
       
   817             // Resize icons, use reading pane text line element as parent
       
   818             iContainer->ResizeIcons( iContainer->TextRect() );
       
   819 
       
   820             if ( !dialogCancelled )
       
   821                 {
       
   822                 iContainer->RefreshEditorL();
       
   823                 }
       
   824             break;
       
   825             }
       
   826         case EChatClientIboxInsertTemplate:
       
   827             {
       
   828             ShowTemplatesL();
       
   829             break;
       
   830             }
       
   831         case EChatClientIboxForwardToGroup:
       
   832             {
       
   833             ForwardToGroupL();
       
   834             break;
       
   835             }
       
   836         case EChatClientIboxForwardToContact:
       
   837             {
       
   838             ForwardToContactL();
       
   839             break;
       
   840             }
       
   841         case EChatClientIboxRecord:
       
   842             {
       
   843             iContainer->RecordChatL();
       
   844             break;
       
   845             }
       
   846         case EChatClientIboxBlockEnter:
       
   847             {
       
   848             if ( iAppUI->UISessionManager().IsLoggedIn() )
       
   849                 {
       
   850                 iContainer->BlockUserWVIdL();
       
   851                 }
       
   852             break;
       
   853             }
       
   854         case EChatClientIboxBlockShow:
       
   855             {
       
   856             if ( iAppUI->UISessionManager().IsLoggedIn() )
       
   857                 {
       
   858                 iContainer->DisplayBlockedListL();
       
   859                 }
       
   860             break;
       
   861             }
       
   862         case EChatClientIboxBlock:
       
   863             {
       
   864             if ( iAppUI->UISessionManager().IsLoggedIn() )
       
   865                 {
       
   866                 iContainer->BlockUserL();
       
   867                 }
       
   868             break;
       
   869             }
       
   870         case EChatClientIboxUnblock:
       
   871             {
       
   872             if ( iAppUI->UISessionManager().IsLoggedIn() )
       
   873                 {
       
   874                 iContainer->UnBlockL();
       
   875                 }
       
   876             break;
       
   877             }
       
   878         case EChatClientIboxClose:
       
   879             {
       
   880             CloseConversationL();
       
   881             break;
       
   882             }
       
   883 
       
   884         // Help key support EChatClientCmdHelp is assigned EAknCmdHelp in
       
   885         // chatngclient.hrh
       
   886         case EChatClientCmdHelp:
       
   887             {
       
   888             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   889                                                  iAppUI->AppHelpContextL() );
       
   890             break;
       
   891             }
       
   892 
       
   893         // flow through
       
   894         case EFindItemCmdEnableAutoFind:
       
   895         case EFindItemCmdDisableAutoFind:
       
   896             {
       
   897             iContainer->SetItemHighlightL(
       
   898                 aCommand == EFindItemCmdEnableAutoFind );
       
   899             iFindMenu->HandleItemFinderCommandL( aCommand );
       
   900             if ( MenuBar()->IsDisplayed() )
       
   901                 {
       
   902                 MenuBar()->StopDisplayingMenuBar();
       
   903                 }
       
   904             if ( iFindContextMenu->IsDisplayed() )
       
   905                 {
       
   906                 iFindContextMenu->StopDisplayingMenuBar();
       
   907                 }
       
   908             break;
       
   909             }
       
   910         case EChatClientCall:
       
   911             {
       
   912             UpdateItemTypeL();
       
   913             iFindMenu->HandleCallL( *iItemFinder->CurrentItemExt().iItemDescriptor );
       
   914             break;
       
   915             }
       
   916         case EAknCmdExit:           // fall-through, handled similarily
       
   917         case EEikCmdExit:           // fall-through, handled similarily
       
   918         case EAknSoftkeyExit:       // fall-through, handled similarily
       
   919         case EChatClientCmdExit:
       
   920             {
       
   921 
       
   922             if ( iFindMenu->CommandIsValidL( aCommand ) )
       
   923                 {
       
   924                 iFindMenu->HandleItemFinderCommandL( aCommand );
       
   925                 }
       
   926 
       
   927             iAppUI->HandleCommandL( aCommand );
       
   928             break;
       
   929             }
       
   930         default:
       
   931             {
       
   932             // check if it is find menu command
       
   933             if ( iFindMenu->CommandIsValidL( aCommand ) )
       
   934                 {
       
   935                 iFindMenu->HandleItemFinderCommandL( aCommand );
       
   936                 }
       
   937             else
       
   938                 {
       
   939                 //As per new UI spec change own status is not avilable in conversation
       
   940                 //view menu
       
   941                 iAppUI->HandleCommandL( aCommand );
       
   942                 }
       
   943             break;
       
   944             }
       
   945         }
       
   946     }
       
   947 
       
   948 // ---------------------------------------------------------
       
   949 // CCAConversationsView::ShowTemplatesL
       
   950 // (other items were commented in a header).
       
   951 // ---------------------------------------------------------
       
   952 //
       
   953 void CCAConversationsView::ShowTemplatesL()
       
   954     {
       
   955     CDesCArray* aResultArray = NULL;
       
   956     CEikonEnv* env = CEikonEnv::Static();
       
   957     aResultArray = env->ReadDesC16ArrayResourceL( R_CHATVIEW_TEMPLATES_LIST );
       
   958 
       
   959     // Create CEikTextListBox instance, list
       
   960     CEikTextListBox* nTemplateList = new( ELeave ) CAknSinglePopupMenuStyleListBox;
       
   961 
       
   962     // Push nProfileList pointer to CleanupStack.
       
   963     CleanupStack::PushL( nTemplateList );
       
   964 
       
   965     // Create CAknPopupList instance, popupList
       
   966     CAknPopupList* popupList = CAknPopupList::NewL( nTemplateList,
       
   967                                                     R_AVKON_SOFTKEYS_SELECT_CANCEL,
       
   968                                                     AknPopupLayouts::EMenuWindow );
       
   969     // Push popupList'pointer to CleanupStack.
       
   970     CleanupStack::PushL( popupList );
       
   971 
       
   972 
       
   973     // Initialize listbox.
       
   974     nTemplateList->ConstructL( popupList, CEikListBox::ELeftDownInViewRect );
       
   975     nTemplateList->CreateScrollBarFrameL( ETrue );
       
   976     nTemplateList->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   977         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   978 
       
   979     // Set title
       
   980     // Allocate TBuf with constant length.
       
   981     TBuf<KMaxTitleLength> title;
       
   982 
       
   983     // Reads a resource into a descriptor.
       
   984     env->ReadResourceL( title, R_QTN_CHAT_TEMPLATE_LIST_TITLE );
       
   985 
       
   986     popupList->SetTitleL( title );
       
   987     //popupList->SetTitleL( _L("Select Templates:") );
       
   988 
       
   989     // Set listitems.
       
   990     CTextListBoxModel* model = nTemplateList->Model();
       
   991     model->SetOwnershipType( ELbmOwnsItemArray );
       
   992     model->SetItemTextArray( aResultArray );
       
   993 
       
   994     // Show popup nProfileList and then show return value.
       
   995     TBool popupOk = popupList->ExecuteLD();
       
   996     CleanupStack::Pop();
       
   997 
       
   998     // Pop the popupList's pointer from CleanupStack
       
   999 
       
  1000     if ( popupOk )
       
  1001         {
       
  1002         TInt index = nTemplateList->CurrentItemIndex();
       
  1003         CCAMessageEditor& editor = iContainer->Editor();
       
  1004         TInt cursorPos( editor.CursorPos() );
       
  1005         editor.RichText()->InsertL( cursorPos, ( *aResultArray )[index] );
       
  1006         //editor.SetTextL( &((*aResultArray)[index]) );
       
  1007         editor.SetCursorPosL( editor.TextLength() + 1, EFalse );
       
  1008         iContainer->StartScrollingL();
       
  1009         }
       
  1010 
       
  1011     // Pop and Destroy the nProfileList pointer from CleanupStack
       
  1012     CleanupStack::PopAndDestroy( nTemplateList );
       
  1013     }
       
  1014 
       
  1015 // ---------------------------------------------------------
       
  1016 // CCAConversationsView::HandleForegroundEventL
       
  1017 // (other items were commented in a header).
       
  1018 // ---------------------------------------------------------
       
  1019 //
       
  1020 void CCAConversationsView::HandleForegroundEventL( TBool aForeground )
       
  1021     {
       
  1022     iForeground = aForeground;
       
  1023 
       
  1024     if ( iContainer )
       
  1025         {
       
  1026         //don't read messages if we're not in foreground
       
  1027         iContainer->FetchMessages( aForeground );
       
  1028         }
       
  1029     }
       
  1030 
       
  1031 
       
  1032 // ---------------------------------------------------------
       
  1033 // CCAConversationsView::HandleContactChange(...)
       
  1034 // ---------------------------------------------------------
       
  1035 //
       
  1036 void CCAConversationsView::HandleContactChange( const TDesC& /*aContact*/ )
       
  1037     {
       
  1038     // this contact was added/edited to contact store, update title
       
  1039     TRAPD( err, UpdateTitleL() );
       
  1040     if ( err != KErrNone )
       
  1041         {
       
  1042         CActiveScheduler::Current()->Error( err );
       
  1043         }
       
  1044     }
       
  1045 
       
  1046 
       
  1047 // ---------------------------------------------------------
       
  1048 // CCAConversationsView::DoActivateL(...)
       
  1049 // Handles view activation
       
  1050 // (other items were commented in a header).
       
  1051 // ---------------------------------------------------------
       
  1052 //
       
  1053 void CCAConversationsView::DoActivateL(
       
  1054     const TVwsViewId& aPrevViewId, TUid aCustomMessageId,
       
  1055     const TDesC8& aCustomMessage )
       
  1056     {
       
  1057     // Unregister the view that was registered from Forward option.
       
  1058     // didn't find any better place to put this.
       
  1059     if ( TEnumsPC::EToBeUnregistered == iAppUI->RetForwardTo() )
       
  1060         {
       
  1061         // Deregister conversation from switch back views
       
  1062         iAppUI->UnRegisterPreviousview();
       
  1063         iAppUI->SetResetForwardTo( TEnumsPC::EUnregistered );
       
  1064         }
       
  1065 
       
  1066     const MCAConversationMessage* forwardedMessage = NULL;
       
  1067     TBool storedEditorContent = EFalse;
       
  1068     TPtr groupId( iContactId->Des() );
       
  1069     TPtr listId( iListId->Des() );
       
  1070     TBool activateFromTabSwitch = EFalse;
       
  1071     if ( aCustomMessageId == KUidConvViewMsgId ||
       
  1072          aCustomMessageId == KUidExtViewActivationId )
       
  1073         {
       
  1074         TCADnlConvViewBuf viewBuf;
       
  1075         viewBuf.Copy( aCustomMessage );
       
  1076 
       
  1077         groupId.Copy( viewBuf().iWVID.Left( groupId.MaxLength() ) );
       
  1078         listId.Copy( viewBuf().iListID.Left( listId.MaxLength() ) );
       
  1079         activateFromTabSwitch = viewBuf().iSwitchTab;
       
  1080 
       
  1081         if ( activateFromTabSwitch )
       
  1082             {
       
  1083             iTabId = viewBuf().iTabId;
       
  1084             }
       
  1085 
       
  1086         if ( viewBuf().iIsForwarded )
       
  1087             {
       
  1088             CHAT_DP( D_CHAT_LIT( "--forwarding message %S" ), &viewBuf().iForwardedMessage->Text() );
       
  1089             forwardedMessage = viewBuf().iForwardedMessage;
       
  1090             }
       
  1091 
       
  1092         storedEditorContent = viewBuf().iSAPChanged;
       
  1093         }
       
  1094 
       
  1095     // When forwarding from contact to contact DoDeactivate is never called.
       
  1096     // We have to cleanup the necessary stuff ourself.
       
  1097     CCAConversationsContainer* oldContainer = NULL;
       
  1098     if ( iContainer && iAppUI )
       
  1099         {
       
  1100         // if we were in a middle of sending message, don't delete the container
       
  1101         if ( !iContainer->Sending() )
       
  1102             {
       
  1103             // Container
       
  1104             iAppUI->RemoveFromStack( iContainer );
       
  1105             oldContainer = iContainer;
       
  1106             CleanupStack::PushL( oldContainer );
       
  1107             iContainer = NULL;
       
  1108 
       
  1109             if ( iAddAndReplyMenu )
       
  1110                 {
       
  1111                 iAppUI->RemoveFromViewStack( *this, iAddAndReplyMenu );
       
  1112                 }
       
  1113 
       
  1114             if ( iFindContextMenu )
       
  1115                 {
       
  1116                 iAppUI->RemoveFromViewStack( *this, iFindContextMenu );
       
  1117                 }
       
  1118             }
       
  1119         }
       
  1120 
       
  1121 
       
  1122     iConversationPC->InitialiseResourcesL( *iContactId );
       
  1123 
       
  1124     // Register this as chat observer
       
  1125     iConversationPC->AddObserver( this );
       
  1126 
       
  1127     // Register switch back if conversation view is opened from
       
  1128     // search view
       
  1129     if ( iAppUI && aPrevViewId.iViewUid == KUidSearchView )
       
  1130         {
       
  1131 
       
  1132         TCADnlConvViewBuf viewBuf;
       
  1133         viewBuf.Copy( aCustomMessage );
       
  1134 
       
  1135         TCADnlConvInvGroupFocus dnlConvInvGroupFocus;
       
  1136         dnlConvInvGroupFocus.iInvConvGroupID.Copy( iContactId->Des().Left( KMaxWVIDLength ) );
       
  1137         dnlConvInvGroupFocus.iListID.Copy( iListId->Des().Left( KMaxWVIDLength ) );
       
  1138         dnlConvInvGroupFocus.iType = EConversationItem;
       
  1139         TCADnlConvInvGroupFocusBuf convInvGroupFocusBuf( dnlConvInvGroupFocus );
       
  1140 
       
  1141         iAppUI->RegisterSwitchBack(
       
  1142             KUidFriendsListView,
       
  1143             KConvInvGroupFocusId,
       
  1144             convInvGroupFocusBuf.AllocL(),
       
  1145             KNullUid );
       
  1146         }
       
  1147 
       
  1148 
       
  1149     // To prevent looping between this view and refresh view
       
  1150     if ( aPrevViewId.iViewUid != KUidRefreshView )
       
  1151         {
       
  1152         iPrevViewId = aPrevViewId;
       
  1153         }
       
  1154 
       
  1155 
       
  1156     if ( iContainer )
       
  1157         {
       
  1158         // container already exists, reset sending flag
       
  1159         iContainer->ResetSending();
       
  1160         }
       
  1161     else
       
  1162         {
       
  1163         iContainer = CCAConversationsContainer::NewL( ClientRect(),
       
  1164                                                       *static_cast<MCAViewSwitcher*>( iAppUI ),
       
  1165                                                       iConversationPC,
       
  1166                                                       *this, this, *iMessageHandler, *this, *this, Cba(),
       
  1167                                                       activateFromTabSwitch, iTabId );
       
  1168         }
       
  1169 
       
  1170 
       
  1171     // Restore find state
       
  1172     TInt findState = IMUtils::CRKeyL( KCRUidCommonUi, KCuiAutomaticHighlight );
       
  1173     CCAMessageEditor& editor = iContainer->Editor();
       
  1174 
       
  1175     iContainer->SetItemHighlightL( findState );
       
  1176 
       
  1177     // Handle forwarded message
       
  1178     if ( forwardedMessage )
       
  1179         {
       
  1180         CHAT_DP(
       
  1181             D_CHAT_LIT( "CCAConversationsView::DoActivateL, forwarding message" ) );
       
  1182 
       
  1183         MCASettingsPC* settingsPC = iAppUI->GetProcessManager().GetSettingsInterface();
       
  1184 
       
  1185         HBufC* ownId = settingsPC->GetSapSettingValuePCL(
       
  1186                            TEnumsPC::EOwnWVUserID );
       
  1187         CleanupStack::PushL( ownId );
       
  1188 
       
  1189         CCAUiMessageUtils* utils = CCAUiMessageUtils::NewLC();
       
  1190         TBool ret = utils->ForwardContentMessageL(
       
  1191                         *forwardedMessage,
       
  1192                         groupId, // recipient
       
  1193                         NULL,
       
  1194                         *iConversationPC,
       
  1195                         EFalse, // no whispering
       
  1196                         ownId->Des() );
       
  1197 
       
  1198         CleanupStack::PopAndDestroy( 2, ownId ); //utils, ownId
       
  1199 
       
  1200         // Message was not handled so we put it into the editor.
       
  1201         if ( !ret )
       
  1202             {
       
  1203             // Wether to put part or whole message
       
  1204             if ( forwardedMessage->ForwardPart() )
       
  1205                 {
       
  1206                 editor.SetTextL( forwardedMessage->ForwardPart() );
       
  1207                 }
       
  1208             else
       
  1209                 {
       
  1210                 editor.SetTextL( &forwardedMessage->Text() );
       
  1211                 }
       
  1212             editor.SetCursorPosL( editor.TextLength(), EFalse );
       
  1213 
       
  1214             iContainer->StartScrollingL();
       
  1215 
       
  1216             }
       
  1217         }
       
  1218 
       
  1219     // Handle stored editor content
       
  1220     if ( storedEditorContent )
       
  1221         {
       
  1222         editor.SetTextL( iEditorContent );
       
  1223         editor.SetCursorPosL( editor.TextLength(), EFalse );
       
  1224         iContainer->SendMessageL();
       
  1225         }
       
  1226 
       
  1227     if ( !editor.TextLength() )
       
  1228         {
       
  1229         TInt editorFlags = ( editor.AknEdwinFlags() | EAknEditorFlagNoEditIndicators );
       
  1230         editor.SetAknEditorFlags( editorFlags );
       
  1231         }
       
  1232 
       
  1233     iAppUI->AddToViewStackL( *this, iContainer );
       
  1234     iAppUI->AddToViewStackL( *this, iAddAndReplyMenu, 0,
       
  1235                              ECoeStackFlagRefusesFocus );
       
  1236     iAppUI->AddToStackL( *this, iFindContextMenu, ECoeStackPriorityDefault,
       
  1237                          ECoeStackFlagRefusesFocus );
       
  1238     if ( iTitlePane )
       
  1239         {
       
  1240 
       
  1241         if ( !activateFromTabSwitch )
       
  1242             {
       
  1243 
       
  1244             //hide navi pane decorators
       
  1245             iTitlePane->ClearNaviPaneL();
       
  1246 
       
  1247             //if activation is from contact list and not from switching between
       
  1248             //tabs then create tabs and show them
       
  1249             iTabId = iTitlePane->ShowTabGroupL( TEnumsPC::EConversationItem, iContactId->Des() );
       
  1250             }
       
  1251 
       
  1252         iTitlePane->AddObserver( this ) ;
       
  1253 
       
  1254         // Get temp id handler handle
       
  1255         // Get identification through temp identification handler
       
  1256         // code merge 14 nov, 2006
       
  1257         MCAMainViewArrayPC* mainViewArrayPC = iAppUI->GetProcessManager().GetArrayInterface();
       
  1258 
       
  1259         delete iTitle;
       
  1260         iTitle = NULL;
       
  1261         TRAPD( err, iTitle = iTitlePane->GetTabItemIdentification( iTabId ).AllocL() );
       
  1262         if ( err )
       
  1263             {
       
  1264             // Contact list was not synchronized yet, just strip the "wv:" etc.
       
  1265             iTitle = CCAPCUtils::DisplayId( *iContactId ).AllocL();
       
  1266             }
       
  1267 
       
  1268 
       
  1269         iTitlePane->SetTitleL( *iTitle );
       
  1270 
       
  1271 
       
  1272         }
       
  1273 #ifndef RD_30_DISABLE_TOUCH
       
  1274     // set the context menu for menubar (launched with middle softkey)
       
  1275     MenuBar()->SetContextMenuTitleResourceId( R_CHATCLIENT_MENUBAR_FINDITEMUI );
       
  1276 #endif
       
  1277 
       
  1278 
       
  1279 
       
  1280     if ( oldContainer )
       
  1281         {
       
  1282         // Everything should be ready and we can delete the old container
       
  1283         CleanupStack::PopAndDestroy(); // oldContainer
       
  1284         }
       
  1285 
       
  1286 
       
  1287 
       
  1288     }
       
  1289 
       
  1290 // ---------------------------------------------------------
       
  1291 // CCAConversationsView::HandleCommandL()
       
  1292 // Handles view deactivation
       
  1293 // ---------------------------------------------------------
       
  1294 //
       
  1295 void CCAConversationsView::DoDeactivate()
       
  1296     {
       
  1297     CHAT_DP_TXT( "DoDeactivate" );
       
  1298 
       
  1299     iConversationPC->RemoveObserver();
       
  1300     iConversationPC->ReleaseResources();
       
  1301 
       
  1302     if ( iTitlePane )
       
  1303         {
       
  1304         iTitlePane->RemoveObserver( this );
       
  1305         }
       
  1306     if ( iContainer )
       
  1307         {
       
  1308         iAppUI->RemoveFromViewStack( *this, iContainer );
       
  1309 
       
  1310         if ( !iContainer->Sending() )
       
  1311             {
       
  1312             // not in a middle of sending message
       
  1313             delete iContainer;
       
  1314             iContainer = NULL;
       
  1315             }
       
  1316         }
       
  1317 
       
  1318     if ( iAddAndReplyMenu )
       
  1319         {
       
  1320         iAppUI->RemoveFromViewStack( *this, iAddAndReplyMenu );
       
  1321         }
       
  1322 
       
  1323     if ( iFindContextMenu )
       
  1324         {
       
  1325         iAppUI->RemoveFromViewStack( *this, iFindContextMenu );
       
  1326         }
       
  1327 
       
  1328     iLastUnreadIndex = KErrNotFound;
       
  1329 
       
  1330     delete iTitle;
       
  1331     iTitle = NULL;
       
  1332     delete iSender;
       
  1333     iSender = NULL;
       
  1334     }
       
  1335 
       
  1336 // ---------------------------------------------------------
       
  1337 // CCAConversationsView::ShowRecipientsListL
       
  1338 // (other items were commented in a header).
       
  1339 // ---------------------------------------------------------
       
  1340 //
       
  1341 TInt CCAConversationsView::ShowRecipientsListL( TInt /*aResourceId*/ )
       
  1342     {
       
  1343     return KErrNotFound;
       
  1344     }
       
  1345 
       
  1346 // ---------------------------------------------------------
       
  1347 // CCAConversationsView::ShowPopUpMenuL()
       
  1348 // This method shows popup menu
       
  1349 // (other items were commented in a header).
       
  1350 // ---------------------------------------------------------
       
  1351 //
       
  1352 void CCAConversationsView::ShowPopUpMenuL( )
       
  1353     {
       
  1354     if ( iContainer->SelectedItemType() != KErrNotFound )
       
  1355         {
       
  1356 #ifndef RD_30_DISABLE_TOUCH
       
  1357         MenuBar()->StopDisplayingMenuBar();
       
  1358         MenuBar()->TryDisplayContextMenuBarL();
       
  1359 #else
       
  1360         iFindContextMenu->StopDisplayingMenuBar();
       
  1361         iFindContextMenu->TryDisplayMenuBarL();
       
  1362 #endif
       
  1363         }
       
  1364     }
       
  1365 
       
  1366 // ---------------------------------------------------------
       
  1367 // CCAConversationsView::HandleChatEvent
       
  1368 // (other items were commented in a header).
       
  1369 // ---------------------------------------------------------
       
  1370 void CCAConversationsView::HandleChatEvent( const TDesC& aWvid,
       
  1371                                             const TDesC& aContactId )
       
  1372     {
       
  1373 
       
  1374     TRAPD( err, DoHandleChatEventL( aWvid, aContactId ) );
       
  1375     if ( err != KErrNone )
       
  1376         {
       
  1377         CActiveScheduler::Current()->Error( err );
       
  1378         }
       
  1379 
       
  1380     }
       
  1381 
       
  1382 // ---------------------------------------------------------
       
  1383 // CCAConversationsView::DoHandleChatEventL
       
  1384 // (other items were commented in a header).
       
  1385 // ---------------------------------------------------------
       
  1386 //
       
  1387 void CCAConversationsView::DoHandleChatEventL( const TDesC& aWvid,
       
  1388                                                const TDesC& aContactId )
       
  1389     {
       
  1390     HBufC* tempSender = aWvid.AllocL();
       
  1391     delete iSender;
       
  1392     iSender = tempSender;
       
  1393 
       
  1394     // nickname or wv-less contact id
       
  1395     iCleanSender.Set( aContactId );
       
  1396 
       
  1397     }
       
  1398 
       
  1399 //added for multitab support
       
  1400 
       
  1401 
       
  1402 // ---------------------------------------------------------
       
  1403 // CCAConversationsView::SwitchTabL
       
  1404 // (other items were commented in a header).
       
  1405 // ---------------------------------------------------------
       
  1406 //
       
  1407 void CCAConversationsView::SwitchTabL( const TDesC& aWvId, const TInt aTabIndex )
       
  1408     {
       
  1409     //change the contact id based on tteh currenttab
       
  1410     TPtr groupId( iContactId->Des() );
       
  1411     TPtr listId( iListId->Des() );
       
  1412     if ( iListId )
       
  1413         {
       
  1414         listId = KNullDesC();
       
  1415         }
       
  1416     groupId.Copy( aWvId.Left( groupId.MaxLength() ) );
       
  1417 
       
  1418     iTabId = aTabIndex;
       
  1419 
       
  1420     UpdateTitleL();
       
  1421 
       
  1422     iConversationPC->SetActiveConversationL( aWvId );
       
  1423 
       
  1424     //remove the controls from view stack
       
  1425     if ( iContainer )
       
  1426         {
       
  1427         iAppUI->RemoveFromViewStack( *this, iContainer );
       
  1428         }
       
  1429 
       
  1430     if ( iAddAndReplyMenu )
       
  1431         {
       
  1432         iAppUI->RemoveFromViewStack( *this, iAddAndReplyMenu );
       
  1433         }
       
  1434 
       
  1435     if ( iFindContextMenu )
       
  1436         {
       
  1437         iAppUI->RemoveFromViewStack( *this, iFindContextMenu );
       
  1438         }
       
  1439 
       
  1440 
       
  1441     iContainer->SwitchViewL();
       
  1442 
       
  1443     //again add those controls to view stack
       
  1444     if ( iContainer )
       
  1445         {
       
  1446         iAppUI->AddToViewStackL( *this, iContainer );
       
  1447         }
       
  1448 
       
  1449     if ( iAddAndReplyMenu )
       
  1450         {
       
  1451         iAppUI->AddToViewStackL( *this, iAddAndReplyMenu, 0,
       
  1452                                  ECoeStackFlagRefusesFocus );
       
  1453         }
       
  1454 
       
  1455     if ( iFindContextMenu )
       
  1456         {
       
  1457         iAppUI->AddToStackL( *this, iFindContextMenu, ECoeStackPriorityDefault,
       
  1458                              ECoeStackFlagRefusesFocus );
       
  1459         }
       
  1460 
       
  1461     }
       
  1462 
       
  1463 
       
  1464 // ---------------------------------------------------------
       
  1465 
       
  1466 // ---------------------------------------------------------
       
  1467 // CCAConversationsView::HandleMessageError
       
  1468 // ---------------------------------------------------------
       
  1469 //
       
  1470 void CCAConversationsView::HandleMessageError( TInt aError,
       
  1471                                                const TDesC& aInfo,
       
  1472                                                TEnumsPC::TContentType aMsgContentType )
       
  1473     {
       
  1474     TRAPD( err, DoHandleMessageErrorL( aError, aInfo, aMsgContentType ) );
       
  1475     if ( err != KErrNone )
       
  1476         {
       
  1477         CActiveScheduler::Current()->Error( err );
       
  1478         }
       
  1479     }
       
  1480 
       
  1481 
       
  1482 // ---------------------------------------------------------
       
  1483 // CCAConversationsView::DoHandleMessageErrorL
       
  1484 // ---------------------------------------------------------
       
  1485 //
       
  1486 void CCAConversationsView::DoHandleMessageErrorL( TInt aError,
       
  1487                                                   const TDesC& aInfo,
       
  1488                                                   TEnumsPC::TContentType aMsgContentType )
       
  1489     {
       
  1490     if ( aError == KErrNoMemory ) // handled in AppUi::HandleMessageError
       
  1491         {
       
  1492         return;
       
  1493         }
       
  1494     if ( TEnumsPC::EContentPicture == aMsgContentType )
       
  1495         {
       
  1496         TInt res( aError == KErrOverflow ?
       
  1497                   R_QTN_CHAT_SCALING_IMAGE_TOO_BIG :
       
  1498                   R_QTN_CHAT_SCALING_ERROR );
       
  1499 
       
  1500         // sending of image failed
       
  1501         IMDialogUtils::DisplayInformationNoteL( res );
       
  1502         return;
       
  1503         }
       
  1504     if ( aError == ECSPUnknownUserId )
       
  1505         {
       
  1506         // This way error can be recognized in note mapper
       
  1507         aError += Imps_ERROR_BASE;
       
  1508         }
       
  1509 
       
  1510     IMNoteMapper::ShowNoteL( aError, aInfo );
       
  1511     }
       
  1512 
       
  1513 
       
  1514 // ---------------------------------------------------------
       
  1515 // CCAConversationsView::ForwardToContactL()
       
  1516 // (other items were commented in a header).
       
  1517 // ---------------------------------------------------------
       
  1518 //
       
  1519 void CCAConversationsView::ForwardToContactL()
       
  1520     {
       
  1521     MCAConversationMessage* message = iContainer->SelectedMessage();
       
  1522     if ( !message )
       
  1523         {
       
  1524         // nothing selected
       
  1525         return;
       
  1526         }
       
  1527 
       
  1528     //Set the focus flag as true 
       
  1529     iAppUI->SetFocusFlag(ETrue);
       
  1530 
       
  1531     CDesCArray* selectedContacts = new ( ELeave ) CDesCArrayFlat( KArrayGranularity );
       
  1532     CleanupStack::PushL( selectedContacts );
       
  1533 
       
  1534     CDesCArray* selectedIdentifications = new ( ELeave ) CDesCArrayFlat( KArrayGranularity );
       
  1535     CleanupStack::PushL( selectedIdentifications );
       
  1536 
       
  1537     MCASkinVariant* skinVar = static_cast<CCAApp*>( iAppUI->Application() )
       
  1538                               ->VariantFactory()->SkinVariantL();
       
  1539 
       
  1540     // show selection dialog
       
  1541 
       
  1542     MCAViewSwitcher& aViewSwitcher( *static_cast<MCAViewSwitcher*>( iAppUI ) );
       
  1543 
       
  1544     if ( !CCAContactSelectionDialog::ShowDialogL(
       
  1545              *selectedContacts,
       
  1546              *iAppUI->GetProcessManager().GetArrayInterface(),
       
  1547              *skinVar,
       
  1548              *iAppUI->GetProcessManager().GetSettingsInterface(),
       
  1549              iAppUI->MbmFullPath(),
       
  1550              TEnumsPC::ESingleSelect,
       
  1551              R_CONTACT_SELECTION_DIALOG,
       
  1552              *aViewSwitcher.CAStatusPane(),
       
  1553              selectedIdentifications  ) )
       
  1554         {
       
  1555         // no contacts
       
  1556         CleanupStack::PopAndDestroy( 2, selectedContacts ); // selectedContacts,selectedIdentifications
       
  1557         return;
       
  1558         }
       
  1559 
       
  1560     // allow tabs - suppose user would have received new messages
       
  1561     iTitlePane->RestoreNaviPane();
       
  1562 
       
  1563     // handle selected contact (if any)
       
  1564     if ( selectedContacts->MdcaCount() == 1 )
       
  1565         {
       
  1566 
       
  1567         TPtrC wvid( selectedContacts->MdcaPoint( 0 ) );
       
  1568 
       
  1569         MCAMainViewArrayPC* mainViewArrayPC = iAppUI->GetProcessManager().GetArrayInterface();
       
  1570 
       
  1571         //Add the conversation item to open chats array before switching the view
       
  1572         mainViewArrayPC->InsertConversationItemL( wvid,
       
  1573                                                   selectedIdentifications->MdcaPoint( 0 ) );
       
  1574 
       
  1575         // Check if there is highlighted item
       
  1576         HBufC* item = iContainer->SelectedItemL();
       
  1577         CleanupStack::PushL( item );
       
  1578 
       
  1579         if ( item->Length() > 0 )
       
  1580             {
       
  1581             // Set forwarded message
       
  1582             message->SetForwardPartL( item );
       
  1583             }
       
  1584         else
       
  1585             {
       
  1586             // Clear previous forward part
       
  1587             message->SetForwardPartL( NULL );
       
  1588             }
       
  1589 
       
  1590         CleanupStack::PopAndDestroy( item );
       
  1591 
       
  1592         iAppUI->SetForwardMessageL( message );
       
  1593 
       
  1594         const MCAConversationMessage* fwdMessage = iAppUI->ForwardMessage();
       
  1595 
       
  1596         if ( !fwdMessage )
       
  1597             {
       
  1598             CleanupStack::PopAndDestroy(); // selectedContacts.Close()
       
  1599             return;
       
  1600             }
       
  1601 
       
  1602         if ( TEnumsPC::EUnregistered == iAppUI->RetForwardTo()  )
       
  1603             {
       
  1604             iAppUI->SetResetForwardTo( TEnumsPC::ERegister );
       
  1605             iAppUI->GroupUtils()->PrepareToSwitchBackL( iContactId->Des(),
       
  1606                                                         KUidConversationsView,
       
  1607                                                         KUidConversationsView );
       
  1608             }
       
  1609         else if ( TEnumsPC::ERegister == iAppUI->RetForwardTo() )
       
  1610             {
       
  1611             iAppUI->SetResetForwardTo( TEnumsPC::EAlreadyRegistered );
       
  1612             }
       
  1613 
       
  1614         if ( !iConversationPC->IsActiveConversation( wvid ) && iTitlePane )
       
  1615             {
       
  1616 
       
  1617             iTabId = iTitlePane->ShowTabGroupL( TEnumsPC::EConversationItem, wvid );
       
  1618 
       
  1619             SwitchTabL( wvid, iTabId );
       
  1620 
       
  1621             }
       
  1622         //Check whether we have fwded the message to any other contact
       
  1623         //if so add a tab and switch the tab to focus on the forwarded contact
       
  1624         MCASettingsPC* settingsPC = iAppUI->GetProcessManager().GetSettingsInterface();
       
  1625 
       
  1626         HBufC* ownId = settingsPC->GetSapSettingValuePCL(
       
  1627                            TEnumsPC::EOwnWVUserID );
       
  1628         CleanupStack::PushL( ownId );
       
  1629 
       
  1630         CCAUiMessageUtils* utils = CCAUiMessageUtils::NewLC();
       
  1631         TBool ret = utils->ForwardContentMessageL(
       
  1632                         *fwdMessage,
       
  1633                         wvid, // recipient
       
  1634                         NULL,
       
  1635                         *iConversationPC,
       
  1636                         EFalse, // no whispering
       
  1637                         ownId->Des() );
       
  1638 
       
  1639         CleanupStack::PopAndDestroy( 2, ownId ); //utils, ownId
       
  1640 
       
  1641         CCAMessageEditor& editor = iContainer->Editor();
       
  1642 
       
  1643         // Message was not handled so we put it into the editor.
       
  1644         if ( !ret )
       
  1645             {
       
  1646             // Wether to put part or whole message
       
  1647             if ( fwdMessage->ForwardPart() )
       
  1648                 {
       
  1649                 editor.SetTextL( fwdMessage->ForwardPart() );
       
  1650                 }
       
  1651             else
       
  1652                 {
       
  1653                 editor.SetTextL( &fwdMessage->Text() );
       
  1654                 }
       
  1655             editor.SetCursorPosL( editor.TextLength(), EFalse );
       
  1656 
       
  1657             iContainer->StartScrollingL();
       
  1658 
       
  1659             }
       
  1660 
       
  1661         }
       
  1662 
       
  1663     CleanupStack::PopAndDestroy( 2, selectedContacts ); // selectedContacts,selectedIdentifications
       
  1664     }
       
  1665 
       
  1666 
       
  1667 
       
  1668 // ---------------------------------------------------------
       
  1669 // CCAConversationsView::ForwardToGroupL()
       
  1670 // (other items were commented in a header).
       
  1671 // ---------------------------------------------------------
       
  1672 //
       
  1673 void CCAConversationsView::ForwardToGroupL()
       
  1674     {
       
  1675     MCAConversationMessage* message = iContainer->SelectedMessage();
       
  1676     if ( !message )
       
  1677         {
       
  1678         // nothing selected
       
  1679         return;
       
  1680         }
       
  1681 
       
  1682     MCAServerContactsArrayPC* pairsArray ( iConversationPC->PopulateGroupDetailsLC() );
       
  1683 
       
  1684     HBufC* emptyText = iEikonEnv->AllocReadResourceLC(
       
  1685                            R_CHAT_IBOX_FRIENDS_OFFLINE );
       
  1686     HBufC* title = iEikonEnv->AllocReadResourceLC(
       
  1687                        R_PRIVATE_CHAT_FORWARD_TITLE_GROUP );
       
  1688 
       
  1689     TInt selectedIndex( 0 );
       
  1690     TInt retVal( IMDialogUtils::DisplayListQueryDialogL( &selectedIndex,
       
  1691                                                          pairsArray,
       
  1692                                                          R_PRIVATE_CHAT_LIST_SELECT_RECIP_DLG,
       
  1693                                                          *title,
       
  1694                                                          *emptyText, ETrue ) );
       
  1695 
       
  1696     CleanupStack::PopAndDestroy( 2, emptyText ); // title, emptyText
       
  1697 
       
  1698     if ( retVal == EAknSoftkeyOk || retVal == EAknSoftkeyDone
       
  1699          || retVal == EAknSoftkeySelect )
       
  1700         {
       
  1701         // Check if there is highlighted item
       
  1702         HBufC* item = iContainer->SelectedItemL();
       
  1703         CleanupStack::PushL( item );
       
  1704 
       
  1705         if ( TEnumsPC::EUnregistered == iAppUI->RetForwardTo()  )
       
  1706             {
       
  1707             iAppUI->SetResetForwardTo( TEnumsPC::ERegister );
       
  1708             iAppUI->GroupUtils()->PrepareToSwitchBackL( iContactId->Des(),
       
  1709                                                         KUidConversationsView,
       
  1710                                                         KUidChatView );
       
  1711             }
       
  1712         else if ( TEnumsPC::ERegister == iAppUI->RetForwardTo() )
       
  1713             {
       
  1714             iAppUI->SetResetForwardTo( TEnumsPC::EAlreadyRegistered );
       
  1715             }
       
  1716         if ( item->Length() > 0 )
       
  1717             {
       
  1718             // Set forwarded message
       
  1719             message->SetForwardPartL( item );
       
  1720             }
       
  1721         else
       
  1722             {
       
  1723             // Clear previous forward part
       
  1724             message->SetForwardPartL( NULL );
       
  1725             }
       
  1726 
       
  1727         CleanupStack::PopAndDestroy( item );
       
  1728 
       
  1729 
       
  1730         TInt err( iAppUI->GroupUtils()->JoinGroupL( ETrue,
       
  1731                                                     pairsArray->WVIdL( selectedIndex )->iWVID,
       
  1732                                                     KNullDesC, message ) );
       
  1733 
       
  1734         if ( err )
       
  1735             {
       
  1736             CActiveScheduler::Current()->Error( err );
       
  1737             }
       
  1738         }
       
  1739     //always dont use CleanupStack::PopAndDestroy(pairsArray)
       
  1740     //because there might be a object slicing happening
       
  1741     //when the pairsArray is transferred from the creator
       
  1742     //to the caller. Hence one will end up deleting the wrong ptr.
       
  1743     //Hence it is better to use CleanupStack::PopAndDestroy(), as
       
  1744     //we dont know wat the creator has pushed onto the CleanupStack
       
  1745     CleanupStack::PopAndDestroy();
       
  1746     }
       
  1747 
       
  1748 
       
  1749 //  End of File