wvuing/wvuiave/AppSrc/CCAChatView.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     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 chat group view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include	"CCAChatView.h"
       
    21 #include	"CCAChatViewContainer.h"
       
    22 #include	"chatngclient.hrh"
       
    23 #include	"CCAStatusPaneHandler.h"
       
    24 #include	"CCAAppUi.h"
       
    25 #include	"CAExternalInterface.h"
       
    26 #include	"CCAMessageEditor.h"
       
    27 #include    "CCAUISessionManager.h"
       
    28 #include	"CAArrayUtils.h"
       
    29 #include	"ChatDebugPrint.h"
       
    30 #include    "IMDialogUtils.h"
       
    31 #include    "ChatDefinitions.h"
       
    32 #include    "CAExternalInterface.h"
       
    33 #include    "IMNoteMapper.h"
       
    34 #include    "ImpsCSPAllErrors.h"
       
    35 #include    "CCAMessageExtensionsHandler.h"
       
    36 #include    "MCAMessageExtension.h"
       
    37 #include	"CCAFadeControl.h"
       
    38 #include    "CCAUiMessageUtils.h"
       
    39 #include    "cautils.h"
       
    40 #include    "IMUtils.h"
       
    41 #include	"MCAConversationMessage.h"
       
    42 #include    "IMPrivateCRKeys.h"
       
    43 #include    "IMVariant.hrh"
       
    44 #include    "mcagrouppc.h"
       
    45 #include    "MCAProcessManager.h"
       
    46 #include    "MCAMainViewArrayPC.h"
       
    47 #include    "CCAPCUtils.h"
       
    48 #include	"CCAGroupUtils.h"
       
    49 #include	"MCAOpenChatsPC.h"
       
    50 #include	"CCAProcessManagerFactory.h"
       
    51 #include	"MCAGroupUtilsPC.h"
       
    52 
       
    53 #include	<eikbtgpc.h>
       
    54 #include    <stringloader.h>
       
    55 #include	<eikgted.h> //For the CEikGlobalTextEditor
       
    56 #include	<eikmenup.h>
       
    57 #include	<eikmenub.h>
       
    58 #include	<aknpopup.h>
       
    59 #include	<aknnotewrappers.h>
       
    60 #include    <aknenv.h>
       
    61 #include	<flogger.h>
       
    62 #include	<utf.h>
       
    63 #include	<aknquerydialog.h>
       
    64 #include	<ChatNG.rsg>
       
    65 #include	<bldvariant.hrh>
       
    66 #include    <FeatMgr.h>
       
    67 #include    <hlplch.h>
       
    68 #include    <finditem.hrh>
       
    69 #include    <finditemmenu.h>
       
    70 #include    <commonuiinternalcrkeys.h>
       
    71 
       
    72 // The Settings have been moved to Cenrep (also retained in the Resource file),
       
    73 // so the enums for keys and central repository header is added here
       
    74 #include 	"VariantKeys.h"
       
    75 
       
    76 
       
    77 
       
    78 // ================= MEMBER FUNCTIONS =======================
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------
       
    82 // CCAChatView::CCAChatView()
       
    83 // C++ default constructor can NOT contain any code, that
       
    84 // might leave.
       
    85 // ---------------------------------------------------------
       
    86 //
       
    87 CCAChatView::CCAChatView()
       
    88         : iMenuPane ( NULL )
       
    89     {
       
    90     }
       
    91 // ---------------------------------------------------------
       
    92 // CCAChatView::ConstructL( TInt aAvkonViewResourceId, TUid aViewId )
       
    93 // Symbian OS two-phased constructor
       
    94 // ---------------------------------------------------------
       
    95 //
       
    96 void CCAChatView::ConstructL( TInt aAvkonViewResourceId, TUid aViewId,
       
    97                               CCAMessageExtensionsHandler& aMessageHandler )
       
    98     {
       
    99     BaseConstructL( aAvkonViewResourceId, aViewId );
       
   100 
       
   101     iMessageHandler = &aMessageHandler;
       
   102 
       
   103     // Construct array for recipient list
       
   104     iRecipients = new( ELeave ) CDesCArrayFlat( KArrayGranularity );
       
   105     iJoinedMembers = new( ELeave )CDesCArrayFlat( KArrayGranularity );
       
   106 
       
   107     iFindContextMenu = new( ELeave ) CEikMenuBar;
       
   108     iFindContextMenu->ConstructL( this, 0, R_CHATCLIENT_MENUBAR_FINDITEMUI );
       
   109 
       
   110     iAddAndReplyMenu = new( ELeave ) CEikMenuBar;
       
   111     iAddAndReplyMenu->ConstructL(
       
   112         this,
       
   113         0,
       
   114         R_CHATCLIENT_MENUBAR_ADDANDREPLY );
       
   115 
       
   116 
       
   117     iGroupId = HBufC::NewL( KMaxWVIDLength );
       
   118     iRecipient = HBufC::NewL( KMaxWVIDLength );
       
   119 
       
   120 
       
   121     iGroupUtils = CAAppUi()->GroupUtils();
       
   122 
       
   123     iGroupPC = CAAppUi()->GetProcessManager().GetGroupInterface();
       
   124 
       
   125     iFindMenu = CFindItemMenu::NewL( EChatClientFindMenuPlaceHolder );
       
   126     iFindMenu->AttachItemFinderMenuL( R_CHATCLIENT_IBOX_VIEW_MENU );
       
   127     iFindMenu->AttachItemFinderMenuL( R_CHATCLIENT_MENUBAR_FINDITEMUI );
       
   128 
       
   129     // automatic finder on by default
       
   130     iFindMenu->HandleItemFinderCommandL( EFindItemCmdEnableAutoFind );
       
   131     iItemFinder = CItemFinder::NewL();
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------
       
   135 // CCAChatView::~CCAChatView()
       
   136 // Destructor
       
   137 // ---------------------------------------------------------
       
   138 //
       
   139 CCAChatView::~CCAChatView()
       
   140     {
       
   141     //In manual login,on exit from options menu
       
   142     //DoDeactivate is not getting called,so free resources here
       
   143     if ( iGroupPC )
       
   144         {
       
   145         iGroupPC->UnRegisterGroupObserver( );
       
   146         iGroupPC->ReleaseResources();
       
   147         }
       
   148 
       
   149     if ( iAsyncCallBack )
       
   150         {
       
   151         if ( iAsyncCallBack->IsActive() )
       
   152             {
       
   153             iAsyncCallBack->Cancel();
       
   154             }
       
   155         delete iAsyncCallBack;
       
   156         }
       
   157 
       
   158     if ( iAddAndReplyMenu )
       
   159         {
       
   160         AppUi()->RemoveFromStack( iAddAndReplyMenu );
       
   161         }
       
   162 
       
   163     delete iAddAndReplyMenu;
       
   164 
       
   165     if ( iFindContextMenu )
       
   166         {
       
   167         AppUi()->RemoveFromStack( iFindContextMenu );
       
   168         delete iFindContextMenu;
       
   169         }
       
   170 
       
   171     delete iRecipients;
       
   172 
       
   173     if ( iContainer )
       
   174         {
       
   175         AppUi()->RemoveFromStack( iContainer );
       
   176         }
       
   177     delete iContainer;
       
   178     delete iGroupId;
       
   179     delete iRecipient;
       
   180     delete iSender;
       
   181     delete iJoinedMembers;
       
   182     delete iFindMenu;
       
   183     delete iItemFinder;
       
   184 
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------
       
   188 // CCAChatView::HandleCommandL(TInt aCommand)
       
   189 // Handles commands
       
   190 // ---------------------------------------------------------
       
   191 //
       
   192 void CCAChatView::HandleCommandL( TInt aCommand )
       
   193     {
       
   194     CCAAppUi* appUi = static_cast<CCAAppUi*>( iEikonEnv->AppUi() );
       
   195     switch ( aCommand )
       
   196         {
       
   197         case EAknSoftkeyOpen: // flowthrough
       
   198         case EChatClientOpenObject:
       
   199             {
       
   200             if ( iObjectOpenedSaved )
       
   201                 {
       
   202                 return;
       
   203                 }
       
   204 
       
   205             MCAConversationMessage* msg = iContainer->SelectedMessage();
       
   206             if ( msg )
       
   207                 {
       
   208                 CCAUiMessageUtils* utils = CCAUiMessageUtils::NewLC();
       
   209 
       
   210                 // Set the indicator to true
       
   211                 iObjectOpenedSaved = ETrue;
       
   212                 TRAPD( err, utils->OpenObjectL( *msg ) );
       
   213                 // Set it back
       
   214                 iObjectOpenedSaved = EFalse;
       
   215 
       
   216                 CleanupStack::PopAndDestroy( utils );
       
   217                 User::LeaveIfError( err );
       
   218                 }
       
   219             break;
       
   220             }
       
   221         case EChatClientSaveObject:
       
   222             {
       
   223             if ( iObjectOpenedSaved )
       
   224                 {
       
   225                 return;
       
   226                 }
       
   227 
       
   228             MCAConversationMessage* msg = iContainer->SelectedMessage();
       
   229             if ( msg )
       
   230                 {
       
   231                 CCAUiMessageUtils* utils = CCAUiMessageUtils::NewLC();
       
   232 
       
   233                 // Set the indicator to true
       
   234                 iObjectOpenedSaved = ETrue;
       
   235                 TRAPD( err, utils->SaveObjectL( *msg ) );
       
   236                 // Set it back
       
   237                 iObjectOpenedSaved = EFalse;
       
   238 
       
   239                 CleanupStack::PopAndDestroy( utils );
       
   240                 User::LeaveIfError( err );
       
   241                 }
       
   242             break;
       
   243             }
       
   244 
       
   245         case EChatClientNewImage:
       
   246             {
       
   247             // new file
       
   248             iContainer->SendObjectL( ETrue, ENewFileServiceImage );
       
   249             break;
       
   250             }
       
   251         case EChatClientFromPhotos: // flowthrough
       
   252         case EChatClientSendImage:
       
   253             {
       
   254             iCba = CEikButtonGroupContainer::Current();
       
   255 
       
   256             if ( iCba )
       
   257                 {
       
   258                 iCba->MakeCommandVisible( EAknSoftkeyOptions, EFalse );
       
   259                 iCba->MakeCommandVisible( EAknSoftkeyBack, EFalse );
       
   260             	iCba->MakeCommandVisible( EChatClientChatViewContinue, EFalse );
       
   261                 iCba->DrawNow();
       
   262                 }
       
   263 
       
   264             iContainer->SendObjectL( EFalse );
       
   265 
       
   266             if ( iCba )
       
   267                 {
       
   268                 iCba->MakeCommandVisible( EAknSoftkeyOptions, ETrue );
       
   269                 iCba->MakeCommandVisible( EAknSoftkeyBack, ETrue );
       
   270                 iCba->MakeCommandVisible( EChatClientChatViewContinue, ETrue );
       
   271                 iCba->DrawNow();
       
   272                 }
       
   273 
       
   274             break;
       
   275             }
       
   276 
       
   277         //ChatClientCmdBack and EAknSoftKeyBack have same function
       
   278         case EChatClientCmdBack:
       
   279         case EAknSoftkeyBack:
       
   280             {
       
   281             CAAppUi()->CAStatusPane()->SynchroniseAndRemoveTabGroup();
       
   282             if ( TEnumsPC::ERegister == appUi->RetForwardTo() )
       
   283                 {
       
   284                 appUi->SetResetForwardTo( TEnumsPC::EToBeUnregistered );
       
   285 
       
   286                 appUi->SwitchViewL( KUidFriendsListView );
       
   287                 }
       
   288             else
       
   289                 {
       
   290                 if ( TEnumsPC::EAlreadyRegistered == appUi->RetForwardTo() )
       
   291                     {
       
   292                     appUi->UnRegisterPreviousview();
       
   293                     appUi->SetResetForwardTo( TEnumsPC::EUnregistered );
       
   294                     }
       
   295                 TCADnlConvInvGroupFocus dnlConvInvGroupFocus;
       
   296                 dnlConvInvGroupFocus.iInvConvGroupID.Copy( iGroupId->Des().Left( KMaxWVIDLength ) );
       
   297                 dnlConvInvGroupFocus.iListID.Copy( KNullDesC() );
       
   298                 dnlConvInvGroupFocus.iType = EGroupItem;
       
   299                 TCADnlConvInvGroupFocusBuf convInvGroupFocusBuf( dnlConvInvGroupFocus );
       
   300                 CAAppUi()->SwitchViewBackL( KUidFriendsListView, KConvInvGroupFocusId, convInvGroupFocusBuf );
       
   301                 }
       
   302             break;
       
   303             }
       
   304         // Flow through
       
   305         case EAknSoftkeySend:   // MSK command
       
   306         case EChatClientIboxViewSend:
       
   307         case EChatClientChatViewCmdSend:
       
   308             {
       
   309             iContainer->SendMessageL();
       
   310             break;
       
   311             }
       
   312 
       
   313         case EChatClientInviteFriend:
       
   314             {
       
   315             // launch the invite without query
       
   316             DoLaunchInviteL( EFalse );
       
   317             break;
       
   318             }
       
   319 
       
   320         case EChatClientChatViewInsertSmiley:
       
   321             {
       
   322             TBool dialogCancelled = EFalse;
       
   323             iMessageHandler->InsertExtensionL( iContainer->Editor(),
       
   324                                                EMessageExtensionSmiley,
       
   325                                                dialogCancelled );
       
   326 
       
   327             // Resize icons, use reading pane text line element as parent
       
   328             iContainer->ResizeIcons( iContainer->TextRect() );
       
   329 
       
   330             if ( !dialogCancelled )
       
   331                 {
       
   332                 iContainer->RefreshEditorL();
       
   333                 }
       
   334 
       
   335             break;
       
   336             }
       
   337 
       
   338         case EChatClientChatViewContinue:
       
   339             {
       
   340             iContainer->StartScrollingL();
       
   341             break;
       
   342             }
       
   343 
       
   344         case EChatClientChatViewCmdWhisper:
       
   345             {
       
   346             ShowRecipientsListL( R_CHATVIEW_RECIPIENT_QUERY );
       
   347             break;
       
   348             }
       
   349         // flow through
       
   350         case EChatClientIboxReply:
       
   351         case EChatClientChatViewCmdReply:
       
   352             {
       
   353             if ( iAddAndReplyMenu->IsDisplayed() )
       
   354                 {
       
   355                 iAddAndReplyMenu->StopDisplayingMenuBar();
       
   356                 }
       
   357             iContainer->ReplyL();
       
   358             break;
       
   359             }
       
   360 
       
   361         case EChatClientIboxForwardToGroup:
       
   362             {
       
   363             iContainer->ForwardToGroupL();
       
   364             break;
       
   365             }
       
   366         case EChatClientIboxForwardToContact:
       
   367             {
       
   368             iContainer->ForwardToContactL();
       
   369             break;
       
   370             }
       
   371 
       
   372         case EChatClientChatViewLogOn:
       
   373             {
       
   374             iContainer->SaveChatL();
       
   375             break;
       
   376             }
       
   377 
       
   378 
       
   379 
       
   380         case EChatClientChatViewCmdLeave:
       
   381             {
       
   382             iContainer->LeaveGroupL();
       
   383             //switch view is called in handleleft also
       
   384             //calling switch view twice would not create any problem
       
   385             //switch view is called here because just after creating the group if
       
   386             //we leave from the group view , we would not get callback in handleleft
       
   387             CAAppUi()->SwitchViewL( KUidFriendsListView );
       
   388 
       
   389             break;
       
   390             }
       
   391         case EChatClientChatViewCmdParticip:
       
   392             {
       
   393             iGroupUtils->DisplayJoinedMembersL( *iGroupId );
       
   394             break;
       
   395             }
       
   396         case EChatClientChatViewCmdGroupInfo:
       
   397             {
       
   398             iContainer->DisplayChatInfoL();
       
   399             break;
       
   400             }
       
   401         case EChatClientChatViewEdit:
       
   402             {
       
   403             iContainer->EditChatGroupPropertiesL();
       
   404             break;
       
   405             }
       
   406         case EChatClientChatViewFavor:
       
   407             {
       
   408             iGroupUtils->SaveAsFavouriteL( *iGroupId );
       
   409             break;
       
   410             }
       
   411 
       
   412         // Help key support EChatClientCmdHelp is assigned EAknCmdHelp in
       
   413         // chatngclient.hrh
       
   414         case EChatClientCmdHelp:
       
   415             {
       
   416             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   417                                                  AppUi()->AppHelpContextL() );
       
   418             break;
       
   419             }
       
   420 
       
   421         // flow through
       
   422         case EFindItemCmdEnableAutoFind:
       
   423         case EFindItemCmdDisableAutoFind:
       
   424             {
       
   425             iContainer->SetItemHighlight(
       
   426                 aCommand == EFindItemCmdEnableAutoFind );
       
   427             iFindMenu->HandleItemFinderCommandL( aCommand );
       
   428             if ( MenuBar()->IsDisplayed() )
       
   429                 {
       
   430                 MenuBar()->StopDisplayingMenuBar();
       
   431                 }
       
   432             if ( iFindContextMenu->IsDisplayed() )
       
   433                 {
       
   434                 iFindContextMenu->StopDisplayingMenuBar();
       
   435                 }
       
   436             break;
       
   437             }
       
   438         case EChatClientCall:
       
   439             {
       
   440             UpdateItemTypeL();
       
   441             iFindMenu->HandleCallL( *iItemFinder->CurrentItemExt().iItemDescriptor );
       
   442             break;
       
   443             }
       
   444         case EAknCmdExit:           // fall-through, handled similarily
       
   445         case EEikCmdExit:           // fall-through, handled similarily
       
   446         case EAknSoftkeyExit:       // fall-through, handled similarily
       
   447         case EChatClientCmdExit:
       
   448             {
       
   449             CAAppUi()->CAStatusPane()->RemoveObserver( this ) ;
       
   450             AppUi()->HandleCommandL( aCommand );
       
   451             break;
       
   452             }
       
   453         default:
       
   454             {
       
   455             // check if it is find menu command
       
   456             if ( iFindMenu->CommandIsValidL( aCommand ) )
       
   457                 {
       
   458                 iFindMenu->HandleItemFinderCommandL( aCommand );
       
   459                 }
       
   460             else
       
   461                 {
       
   462                 AppUi()->HandleCommandL( aCommand );
       
   463                 }
       
   464             break;
       
   465             }
       
   466         }
       
   467     }
       
   468 
       
   469 
       
   470 // ---------------------------------------------------------
       
   471 // CCAChatView::HandleForegroundEventL
       
   472 // (other items were commented in a header).
       
   473 // ---------------------------------------------------------
       
   474 //
       
   475 void CCAChatView::HandleForegroundEventL( TBool aForeground )
       
   476     {
       
   477     if ( iContainer )
       
   478         {
       
   479         //don't read messages if we're not in foreground
       
   480         iContainer->FetchMessages( aForeground );
       
   481         }
       
   482     CCAView::HandleForegroundEventL( aForeground );
       
   483     }
       
   484 
       
   485 // ---------------------------------------------------------
       
   486 // CCAChatView::DoActivateL(...)
       
   487 // Handles view activation
       
   488 // ---------------------------------------------------------
       
   489 //
       
   490 void CCAChatView::DoActivateL(
       
   491     const TVwsViewId& aPrevViewId, TUid aCustomMessageId,
       
   492     const TDesC8& aCustomMessage )
       
   493     {
       
   494     CHAT_DP_TXT( "CCAChatView::DoActivateL" );
       
   495     TBool launchInvite( EFalse );
       
   496 
       
   497     // Unregister the view that was registered from Forward option.
       
   498     // didn't find any better place to put this.
       
   499     if ( TEnumsPC::EToBeUnregistered == CAAppUi()->RetForwardTo() )
       
   500         {
       
   501         // Deregister conversation from switch back views
       
   502         CAAppUi()->UnRegisterPreviousview();
       
   503         CAAppUi()->SetResetForwardTo( TEnumsPC::EUnregistered );
       
   504         }
       
   505     const MCAConversationMessage* forwardedMessage = NULL;
       
   506 
       
   507     TBool activateFromTabSwitch ( EFalse );
       
   508 
       
   509     if ( aCustomMessageId == KUidChatViewMsgId )
       
   510         {
       
   511         TCADnlChatViewBuf viewBuf;
       
   512         viewBuf.Copy( aCustomMessage );
       
   513 
       
   514         activateFromTabSwitch = viewBuf().iSwitchTab;
       
   515 
       
   516         if ( activateFromTabSwitch )
       
   517             {
       
   518             iTabId = viewBuf().iTabId;
       
   519             }
       
   520 
       
   521         HBufC* group = viewBuf().iGroupId.AllocL();
       
   522         delete iGroupId;
       
   523         iGroupId = group;
       
   524         if ( viewBuf().iGroupName.Length() > 0 )
       
   525             {
       
   526             CAAppUi()->CAStatusPane()->SetTitleL( viewBuf().iGroupName );
       
   527             }
       
   528         else
       
   529             {
       
   530             CAAppUi()->CAStatusPane()->
       
   531             SetTitleL( CCAPCUtils::DisplayId( *iGroupId ) );
       
   532             }
       
   533         if ( viewBuf().iIsForwarded )
       
   534             {
       
   535             forwardedMessage = viewBuf().iForwardedMessage;
       
   536             }
       
   537 
       
   538         launchInvite = viewBuf().iInviteQuery;
       
   539         }
       
   540 
       
   541 
       
   542     // Register this as chat observer
       
   543 
       
   544     iGroupPC->RegisterGroupObserver( this );
       
   545 
       
   546     // set the context menu for menubar (launched with middle softkey)
       
   547 #ifndef RD_30_DISABLE_TOUCH
       
   548     MenuBar()->SetContextMenuTitleResourceId(
       
   549         R_CHATCLIENT_MENUBAR_FINDITEMUI );
       
   550 #endif // RD_30_DISABLE_TOUCH
       
   551 
       
   552     // To prevent looping between this view and search view
       
   553     if ( aPrevViewId.iViewUid == KUidSearchView )
       
   554         {
       
   555         // If this view is activated from search view register
       
   556         // chat list view as view for back option
       
   557         TCADnlChatViewBuf viewBuf;
       
   558         viewBuf.Copy( aCustomMessage );
       
   559 
       
   560         TCADnlConvInvGroupFocus dnlConvInvGroupFocus;
       
   561         dnlConvInvGroupFocus.iInvConvGroupID.Copy( viewBuf().iGroupId );
       
   562         dnlConvInvGroupFocus.iListID.Copy( KNullDesC() );
       
   563         dnlConvInvGroupFocus.iType = EGroupItem;
       
   564         TCADnlConvInvGroupFocusBuf convInvGroupFocusBuf( dnlConvInvGroupFocus );
       
   565 
       
   566         static_cast<CCAAppUi*>( AppUi() )->RegisterSwitchBack(
       
   567             KUidFriendsListView, KConvInvGroupFocusId, convInvGroupFocusBuf.AllocL(), KNullUid );
       
   568 
       
   569         CAAppUi()->GetProcessManager().GetArrayInterface()->PopulateGroupsListL();
       
   570         }
       
   571 
       
   572     // To prevent looping between this view and refresh view
       
   573     if ( aPrevViewId.iViewUid != KUidRefreshView )
       
   574         {
       
   575         iPrevViewId = aPrevViewId;
       
   576         }
       
   577 
       
   578     //can be done while construction after TCADnlChatViewBuf is refactored
       
   579     iGroupPC->InitialiseResourcesL( *iGroupId );
       
   580 
       
   581     MCAViewSwitcher* viewSwitcher = static_cast<MCAViewSwitcher*>( CAAppUi() );
       
   582 
       
   583     // When forwarding from group to group DoDeactivate is never called.
       
   584     // We have to cleanup the necessary stuff ourself.
       
   585     CCAChatViewContainer* oldContainer = NULL;
       
   586     if ( iContainer )
       
   587         {
       
   588         AppUi()->RemoveFromStack( iContainer );
       
   589         oldContainer = iContainer;
       
   590         iContainer = NULL;
       
   591 
       
   592         if ( iAddAndReplyMenu )
       
   593             {
       
   594             AppUi()->RemoveFromStack( iAddAndReplyMenu );
       
   595             }
       
   596 
       
   597         if ( iFindContextMenu )
       
   598             {
       
   599             AppUi()->RemoveFromStack( iFindContextMenu );
       
   600             }
       
   601 
       
   602         CleanupStack::PushL( oldContainer );
       
   603         }
       
   604 
       
   605     iContainer = CCAChatViewContainer::NewL( ClientRect(), *viewSwitcher,
       
   606                                              iGroupPC,
       
   607                                              *this, this, *iMessageHandler,
       
   608                                              Cba(), activateFromTabSwitch, iTabId , this );
       
   609     // Get group properties (waiting operation)
       
   610 
       
   611 
       
   612     static_cast<MCAGroupEventObserverPC*>
       
   613     ( iContainer )->HandleGroupPropertiesChanged();
       
   614 
       
   615     // Restore find state
       
   616     TInt findState = IMUtils::CRKeyL( KCRUidCommonUi, KCuiAutomaticHighlight );
       
   617     iContainer->SetItemHighlight( findState );
       
   618 
       
   619     CCAMessageEditor& editor = iContainer->Editor();
       
   620 
       
   621     // Handle forwarded message
       
   622     if ( forwardedMessage )
       
   623         {
       
   624         CHAT_DP(
       
   625             D_CHAT_LIT( "CCAChatView::DoActivateL, forwarding message" ) );
       
   626 
       
   627 
       
   628         CCAUiMessageUtils* utils = CCAUiMessageUtils::NewLC();
       
   629         CDesCArray* members = new( ELeave )CDesCArrayFlat( 1 );
       
   630         CleanupStack::PushL( members );
       
   631 
       
   632 
       
   633 
       
   634         TBool isGroupFound = iGroupUtils->FindGroup( iGroupPC->ActiveGroupId() );
       
   635 
       
   636         if ( isGroupFound )
       
   637             {
       
   638             iGroupUtils->GetParticipantsL( *members, iGroupPC->ActiveGroupId() );
       
   639             }
       
   640         // Remove user from targets
       
   641         TInt index;
       
   642         if ( members->Find( iGroupPC->ScreenName(), index ) == KErrNone )
       
   643             {
       
   644             members->Delete( index );
       
   645             members->Compress();
       
   646             }
       
   647         members->Sort( ECmpCollated );
       
   648 
       
   649 
       
   650 
       
   651         TBool ret = utils->ForwardContentMessageL(
       
   652                         *forwardedMessage,
       
   653                         *iGroupId, // recipient
       
   654                         members,
       
   655                         *iGroupPC,
       
   656                         iContainer->IsWhisperAllowedL(), // no whispering
       
   657                         iGroupPC->ScreenName() );
       
   658 
       
   659         //Note: code scanner warning is ignored
       
   660         CleanupStack::PopAndDestroy( 2 ); //utils, members
       
   661 
       
   662         // Message was not handled so we put it into the editor.
       
   663         if ( !ret )
       
   664             {
       
   665             // Wether to put part or whole message
       
   666             if ( forwardedMessage->ForwardPart() )
       
   667                 {
       
   668                 editor.SetTextL( forwardedMessage->ForwardPart() );
       
   669                 }
       
   670             else
       
   671                 {
       
   672                 editor.SetTextL( &forwardedMessage->Text() );
       
   673                 }
       
   674             editor.SetCursorPosL( editor.TextLength(), EFalse );
       
   675 
       
   676             iContainer->StartScrollingL();
       
   677 
       
   678             }
       
   679         }
       
   680 
       
   681     if ( !editor.TextLength() )
       
   682         {
       
   683         TInt editorFlags = ( editor.AknEdwinFlags() | EAknEditorFlagNoEditIndicators );
       
   684         editor.SetAknEditorFlags( editorFlags );
       
   685         }
       
   686 
       
   687     AppUi()->AddToStackL( *this, iContainer );
       
   688     AppUi()->AddToStackL( *this, iAddAndReplyMenu, ECoeStackPriorityDefault,
       
   689                           ECoeStackFlagRefusesFocus );
       
   690     AppUi()->AddToStackL( *this, iFindContextMenu, ECoeStackPriorityDefault,
       
   691                           ECoeStackFlagRefusesFocus );
       
   692 
       
   693     if ( launchInvite )
       
   694         {
       
   695         delete iAsyncCallBack;
       
   696         iAsyncCallBack = NULL;
       
   697 
       
   698         iAsyncCallBack = new( ELeave )CAsyncCallBack(
       
   699             TCallBack( LaunchInvite, this ), CActive::EPriorityIdle );
       
   700 
       
   701         // hide CBA
       
   702         iCba = CEikButtonGroupContainer::Current();
       
   703         iCba->MakeVisible( EFalse );
       
   704         iCba->DrawNow();
       
   705 
       
   706         iAsyncCallBack->CallBack();
       
   707         }
       
   708 
       
   709     if ( !activateFromTabSwitch )
       
   710         {
       
   711         //Hides navi-pane decorators.
       
   712         CAAppUi()->CAStatusPane()->ClearNaviPaneL();
       
   713 
       
   714         //if activation is from contact list and not from switching between
       
   715         //tabs then create tabs and show them
       
   716         iTabId = CAAppUi()->CAStatusPane()->ShowTabGroupL( TEnumsPC::EGroupItem, *iGroupId );
       
   717         }
       
   718     CAAppUi()->CAStatusPane()->AddObserver( this ) ;
       
   719 
       
   720     if ( oldContainer )
       
   721         {
       
   722         // Everything should be ready and we can delete the old container
       
   723         CleanupStack::PopAndDestroy(); // oldContainer
       
   724         }
       
   725     CHAT_DP_TXT( "CCAChatView::DoActivateL done" );
       
   726     }
       
   727 
       
   728 // ---------------------------------------------------------
       
   729 // CCAChatView::ShowRecipientsListL()
       
   730 // This method launches recipient list
       
   731 // (other items were commented in a header).
       
   732 // ---------------------------------------------------------
       
   733 //
       
   734 TInt CCAChatView::ShowRecipientsListL( TInt aResourceId )
       
   735     {
       
   736     CArrayFixFlat<TInt>* indexArray =
       
   737         new ( ELeave ) CArrayFixFlat<TInt>( KArrayGranularity );
       
   738     CleanupStack::PushL( indexArray );
       
   739 
       
   740     CDesCArrayFlat* items = new ( ELeave ) CDesCArrayFlat( KArrayGranularity );
       
   741     CleanupStack::PushL( items );
       
   742 
       
   743     HBufC* text = HBufC::NewLC( KWVNameMaxLength + KIconTabulator().Size() );
       
   744     TPtr textPtr( text->Des() );
       
   745 
       
   746 
       
   747     TBool isGroupFound = iGroupUtils->FindGroup( *iGroupId );
       
   748     if ( isGroupFound )
       
   749         {
       
   750         iJoinedMembers->Reset();
       
   751         iGroupUtils->GetParticipantsL( *iJoinedMembers, *iGroupId );
       
   752         }
       
   753 
       
   754 
       
   755     iJoinedMembers->Sort( ECmpCollated );
       
   756 
       
   757     TInt count( iJoinedMembers->Count() );
       
   758     for ( TInt i( 0 ); i < count; ++i )
       
   759         {
       
   760         textPtr.Copy( KIconTabulator );
       
   761         textPtr.Append( ( *iJoinedMembers )[i] );
       
   762         items->AppendL( *text );
       
   763         }
       
   764     CleanupStack::PopAndDestroy( text );
       
   765 
       
   766     TInt result( 0 );
       
   767     CArrayFixFlat<TInt>* selectedArray =
       
   768         CAArrayUtils::SetSelectionsLC( *iRecipients, *iJoinedMembers );
       
   769     result = IMDialogUtils::DisplayListQueryDialogL( indexArray,
       
   770                                                      items,
       
   771                                                      aResourceId,
       
   772                                                      selectedArray );
       
   773     CleanupStack::PopAndDestroy( 2, items ); //selectedArray, items
       
   774 
       
   775     if ( result )
       
   776         {
       
   777         // use indexArray here
       
   778         TInt selectionCount( indexArray->Count() );
       
   779         iRecipients->Reset();
       
   780         iContainer->Recipients().Reset();
       
   781         HBufC* userIdBuf = HBufC::NewLC( KMaxWVIDLength );
       
   782         TPtr userIdPtr( userIdBuf->Des() );
       
   783         TBool groupMsg( EFalse );
       
   784         if ( selectionCount > 0 )
       
   785             {
       
   786             for ( TInt i( 0 ); i < selectionCount; i++ )
       
   787                 {
       
   788                 //Cache user id to descriptor
       
   789                 userIdPtr.Copy( ( *iJoinedMembers )[ indexArray->At( i ) ] );
       
   790                 iContainer->Recipients().AppendL( *userIdBuf );
       
   791                 iRecipients->AppendL( *userIdBuf );
       
   792                 }
       
   793             if ( selectionCount > 1 )
       
   794                 {
       
   795                 groupMsg = ETrue;
       
   796                 }
       
   797             iContainer->InitPrivateMessageL(
       
   798                 iContainer->Recipients().MdcaPoint( 0 ), groupMsg );
       
   799             }
       
   800         else
       
   801             {
       
   802             result =  0;
       
   803             }
       
   804         CleanupStack::PopAndDestroy( userIdBuf );
       
   805         }
       
   806 
       
   807     CleanupStack::PopAndDestroy( indexArray );
       
   808 
       
   809     return result;
       
   810     }
       
   811 
       
   812 // ---------------------------------------------------------
       
   813 // CCAChatView::ShowPopUpMenuL()
       
   814 // This method shows popup menu
       
   815 // (other items were commented in a header).
       
   816 // ---------------------------------------------------------
       
   817 //
       
   818 void CCAChatView::ShowPopUpMenuL( )
       
   819     {
       
   820     if ( iContainer->SelectedItemType() != KErrNotFound )
       
   821         {
       
   822 #ifndef RD_30_DISABLE_TOUCH
       
   823         // S60 COMMON
       
   824         MenuBar()->StopDisplayingMenuBar();
       
   825         MenuBar()->TryDisplayContextMenuBarL();
       
   826 #else
       
   827         // S60 3.0
       
   828         iFindContextMenu->StopDisplayingMenuBar();
       
   829         iFindContextMenu->TryDisplayMenuBarL();
       
   830 #endif //RD_30_DISABLE_TOUCH
       
   831         }
       
   832     }
       
   833 
       
   834 // ---------------------------------------------------------
       
   835 // CCAChatView::DoDeactivate()
       
   836 // Handles view deactivation
       
   837 // ---------------------------------------------------------
       
   838 //
       
   839 void CCAChatView::DoDeactivate()
       
   840     {
       
   841     CHAT_DP_TXT( "DoDeactivate" );
       
   842     if ( !CAAppUi()->IsUnderDestruction() )
       
   843         {
       
   844 
       
   845         CCAStatusPaneHandler* statuspaneHandler = CAAppUi()->CAStatusPane();
       
   846         if ( statuspaneHandler )
       
   847             {
       
   848             statuspaneHandler->RemoveObserver( this ) ;
       
   849             }
       
   850         }
       
   851     if ( iGroupPC )
       
   852         {
       
   853         iGroupPC->UnRegisterGroupObserver( );
       
   854         iGroupPC->ReleaseResources();
       
   855         }
       
   856 
       
   857 
       
   858 
       
   859     if ( iContainer )
       
   860         {
       
   861         AppUi()->RemoveFromStack( iContainer );
       
   862         }
       
   863 
       
   864     if ( iAddAndReplyMenu )
       
   865         {
       
   866         AppUi()->RemoveFromStack( iAddAndReplyMenu );
       
   867         }
       
   868 
       
   869     if ( iFindContextMenu )
       
   870         {
       
   871         AppUi()->RemoveFromStack( iFindContextMenu );
       
   872         }
       
   873 
       
   874     delete iContainer;
       
   875     iContainer = NULL;
       
   876     }
       
   877 
       
   878 // ---------------------------------------------------------
       
   879 // CCAChatView::DynInitMenuPaneL
       
   880 // Called when menupane is about to be shown.
       
   881 // ---------------------------------------------------------
       
   882 //
       
   883 void CCAChatView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   884     {
       
   885     CHAT_DP_FUNC_ENTER( "DynInitMenuPaneL" );
       
   886 
       
   887     TBool showFwdToContact = iContainer->FwdContactVisible();
       
   888     TBool showFwdToGroup   = iContainer->FwdGroupVisible();
       
   889     TBool showForwardMenu = showFwdToGroup || showFwdToContact;
       
   890 
       
   891     iMenuPane = aMenuPane;
       
   892     switch ( aResourceId )
       
   893         {
       
   894         case R_CHATCLIENT_GENERAL_MENU:
       
   895             {
       
   896             if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   897                 {
       
   898                 // dims the help menu item
       
   899                 aMenuPane->SetItemDimmed( EChatClientCmdHelp, ETrue );
       
   900                 }
       
   901             break;
       
   902             }
       
   903 
       
   904         case R_CHATCLIENT_ADDANDREPLY_MENU:
       
   905             {
       
   906             aMenuPane->SetItemDimmed( EChatClientSearchAddFriends, ETrue );
       
   907             if ( iContainer->Editor().IsFocused()
       
   908                  || !iContainer->IsWhisperAllowedL()
       
   909                  || iContainer->ApplicationUserSentThis()
       
   910                  || !iContainer->Received() )
       
   911                 {
       
   912                 // editor is focused, whispering is not allowed,
       
   913                 // this is our own message or this is not received from server
       
   914                 aMenuPane->SetItemDimmed( EChatClientIboxReply, ETrue );
       
   915                 }
       
   916             break;
       
   917             }
       
   918 
       
   919         case R_CHATCLIENT_CHAT_VIEW_MENU:
       
   920             {
       
   921             TBool text( iContainer->Editor().TextLength() != 0 );
       
   922             TBool openable = EFalse;
       
   923             TBool savable = EFalse;
       
   924             TBool object = iContainer->IsObjectSelected( openable, savable );
       
   925 
       
   926             TBool isInviteAllowed( iContainer->IsInvitationAllowed() );
       
   927             TBool isUserAdmin( iContainer->IsUserAdmin() );
       
   928             TBool isGroupOpen( iContainer->IsGroupOpen() );
       
   929 
       
   930             // "send"
       
   931             aMenuPane->SetItemDimmed( EChatClientChatViewCmdSend, !text );
       
   932 
       
   933             // "insert smiley"
       
   934             if ( iContainer->Editor().IsFocused() )
       
   935                 {
       
   936                 aMenuPane->SetItemDimmed( EChatClientChatViewInsertSmiley,
       
   937                                           !iContainer->ExtensionFits( KChatSmileyLength ) );
       
   938                 }
       
   939             else
       
   940                 {
       
   941                 aMenuPane->SetItemDimmed( EChatClientChatViewInsertSmiley,
       
   942                                           ETrue );
       
   943                 }
       
   944 
       
   945             // "open"
       
   946             aMenuPane->SetItemDimmed( EChatClientOpenObject, !openable );
       
   947 
       
   948             // "save"
       
   949             aMenuPane->SetItemDimmed( EChatClientSaveObject, !savable );
       
   950 
       
   951 
       
   952             // item finder menu
       
   953             aMenuPane->SetItemDimmed( EChatClientFindMenuPlaceHolder, ETrue );
       
   954 
       
   955             if ( iContainer->IsStopped() )
       
   956                 {
       
   957                 UpdateItemTypeL();
       
   958 
       
   959                 iFindMenu->AddItemFindMenuL( iItemFinder, aMenuPane,
       
   960                                              EChatClientFindMenuPlaceHolder,
       
   961                                              KNullDesC ); // We can ignore sender here
       
   962                 }
       
   963 
       
   964             // "send image"
       
   965             if ( IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_SEND_IMAGE ) == 0 )
       
   966                 {
       
   967                 aMenuPane->SetItemDimmed( EChatClientSendImage, ETrue );
       
   968                 aMenuPane->SetItemDimmed( EChatClientSendImageCascade, ETrue );
       
   969                 }
       
   970             else
       
   971                 {
       
   972                 TBool cam( FeatureManager::FeatureSupported(
       
   973                                KFeatureIdCamera ) );
       
   974                 CHAT_DP( D_CHAT_LIT( " Camera %d" ), cam );
       
   975 
       
   976                 // if camera is supported, show cascade menu
       
   977                 // otherwise hide cascade menu
       
   978                 aMenuPane->SetItemDimmed( EChatClientSendImage, cam );
       
   979                 aMenuPane->SetItemDimmed( EChatClientSendImageCascade, !cam );
       
   980                 }
       
   981 
       
   982             // forward hiding logic case 3
       
   983             // Hide also when focus on object that is not openable
       
   984             if ( !showForwardMenu || ( object && !openable ) )
       
   985                 {
       
   986                 CHAT_DP_TXT(
       
   987                     "CCAChatView::DynInitMenuPaneL Hide the whole forward menu" );
       
   988                 aMenuPane->SetItemDimmed(
       
   989                     EChatClientChatViewCmdForward, ETrue );
       
   990                 }
       
   991             else
       
   992                 {
       
   993                 CHAT_DP_TXT(
       
   994                     "CCAChatView::DynInitMenuPaneL Hide the whole forward menu" );
       
   995                 aMenuPane->SetItemDimmed( EChatClientChatViewCmdForward,
       
   996                                           !iContainer->IsStopped() );
       
   997                 }
       
   998 
       
   999             TBool inviteSupported( UISessionManager().IsSupported(
       
  1000                                        CCAUISessionManager::EInvite ) );
       
  1001 
       
  1002             if ( !inviteSupported )
       
  1003                 {
       
  1004                 aMenuPane->SetItemDimmed( EChatClientInviteFriend,
       
  1005                                           ETrue );
       
  1006                 }
       
  1007             else if ( isInviteAllowed )
       
  1008                 {
       
  1009                 if ( !isUserAdmin )
       
  1010                     {
       
  1011                     aMenuPane->SetItemDimmed( EChatClientInviteFriend,
       
  1012                                               ( !isGroupOpen )  );
       
  1013                     }
       
  1014                 }
       
  1015             else
       
  1016                 {
       
  1017                 aMenuPane->SetItemDimmed( EChatClientInviteFriend,
       
  1018                                           ETrue );
       
  1019                 }
       
  1020 
       
  1021             aMenuPane->SetItemDimmed( EChatClientChatViewCmdWhisper,
       
  1022                                       ( iContainer->IsStopped() || !iContainer->IsWhisperAllowedL() ) );
       
  1023 
       
  1024             if ( iContainer->Editor().IsFocused()
       
  1025                  || !iContainer->IsWhisperAllowedL()
       
  1026                  || iContainer->ApplicationUserSentThis()
       
  1027                  || !iContainer->Received() )
       
  1028                 {
       
  1029                 // editor is focused, whispering is not allowed,
       
  1030                 // this is our own message or this is not received from server
       
  1031                 aMenuPane->SetItemDimmed( EChatClientChatViewCmdReply, ETrue );
       
  1032                 }
       
  1033 
       
  1034 
       
  1035 
       
  1036             break;
       
  1037             }
       
  1038 
       
  1039         case R_CHATCLIENT_CHATVIEW_SUB_MENU:
       
  1040             {
       
  1041 
       
  1042 
       
  1043             aMenuPane->SetItemDimmed( EChatClientChatViewFavor,
       
  1044                                       iGroupUtils->IsFavouriteChatGroup( *iGroupId ) );
       
  1045             aMenuPane->SetItemDimmed( EChatClientChatViewRmv,
       
  1046                                       ETrue );
       
  1047 
       
  1048             // branding things: edit group properties
       
  1049             if ( ! IMUtils::IntResourceValueL(
       
  1050                      RSC_CHAT_VARIATION_ALLOW_EDIT_GROUP_PROPERTIES ) )
       
  1051                 {
       
  1052                 // branded as inactive
       
  1053                 aMenuPane->SetItemDimmed( EChatClientChatViewEdit, ETrue );
       
  1054                 }
       
  1055             else
       
  1056                 {
       
  1057                 // not branded
       
  1058                 aMenuPane->SetItemDimmed( EChatClientChatViewEdit,
       
  1059                                           !iContainer->IsUserAdmin() );
       
  1060                 }
       
  1061             break;
       
  1062             }
       
  1063 
       
  1064         case R_CHATCLIENT_IBOX_FORWARD_SUBMENU:
       
  1065             {
       
  1066             // forward-menu funkiness
       
  1067             aMenuPane->SetItemDimmed( EChatClientIboxForwardToGroup,
       
  1068                                       ! showFwdToGroup );
       
  1069             aMenuPane->SetItemDimmed( EChatClientIboxForwardToContact,
       
  1070                                       ! showFwdToContact );
       
  1071             break;
       
  1072             }
       
  1073 
       
  1074         case R_CHATCLIENT_FINDITEMUI_MENU:
       
  1075             {
       
  1076             if ( iContainer->IsStopped() )
       
  1077                 {
       
  1078                 UpdateItemTypeL();
       
  1079                 iFindMenu->AddItemFindMenuL( iItemFinder, aMenuPane,
       
  1080                                              EFindItemContextMenuPlaceHolder,
       
  1081                                              KNullDesC, // we can ignore the sender here
       
  1082                                              EFalse, ETrue ); // context menu
       
  1083                 }
       
  1084             break;
       
  1085             }
       
  1086 
       
  1087         default:
       
  1088             {
       
  1089             // update find menu
       
  1090             iFindMenu->UpdateItemFinderMenuL( aResourceId, aMenuPane );
       
  1091             break;
       
  1092             }
       
  1093         }
       
  1094     }
       
  1095 
       
  1096 // ---------------------------------------------------------
       
  1097 // CCAChatView::UpdateItemTypeL
       
  1098 // ---------------------------------------------------------
       
  1099 //
       
  1100 void CCAChatView::UpdateItemTypeL()
       
  1101     {
       
  1102     CItemFinder::CFindItemExt& item = iItemFinder->CurrentItemExt();
       
  1103     switch ( iContainer->SelectedItemType() )
       
  1104         {
       
  1105         case CFindItemEngine::EFindItemSearchPhoneNumberBin:
       
  1106             {
       
  1107             item.iItemType = CItemFinder::EPhoneNumber;
       
  1108             break;
       
  1109             }
       
  1110         case CFindItemEngine::EFindItemSearchMailAddressBin:
       
  1111             {
       
  1112             item.iItemType = CItemFinder::EEmailAddress;
       
  1113             break;
       
  1114             }
       
  1115         case CFindItemEngine::EFindItemSearchURLBin:
       
  1116             {
       
  1117             item.iItemType = CItemFinder::EUrlAddress;
       
  1118             break;
       
  1119             }
       
  1120         case CFindItemEngine::EFindItemSearchScheme:
       
  1121             {
       
  1122             item.iItemType = CItemFinder::EUriScheme;
       
  1123             break;
       
  1124             }
       
  1125         case KErrNotFound:  // flowthrough
       
  1126         default:
       
  1127             {
       
  1128             item.iItemType = CItemFinder::ENoneSelected;
       
  1129             break;
       
  1130             }
       
  1131         }
       
  1132     delete item.iItemDescriptor;
       
  1133     item.iItemDescriptor = NULL;
       
  1134     item.iItemDescriptor = iContainer->SelectedItemL(); // takes the ownership
       
  1135 
       
  1136     // this logic comes from CItemFinder::ResolveAndSetItemTypeL.
       
  1137     // should be in ItemFinder engine, but for some reason it isn't,
       
  1138     // so, next few lines are copypasted from AknItemFinder.cpp..
       
  1139     if ( item.iItemType == CItemFinder::EUrlAddress )
       
  1140         {
       
  1141         // old url types need prefix in order to work w/ schemehandler
       
  1142         const TDesC& pref = item.iItemDescriptor->Des().Left( KHttpLength );
       
  1143         if ( pref.CompareF( KIMHTTPPREFIX().Left( KHttpLength ) ) != 0 )
       
  1144             {
       
  1145             HBufC* tmp = item.iItemDescriptor->ReAlloc(
       
  1146                              item.iItemDescriptor->Length() + KIMHTTPPREFIX().Length() );
       
  1147             if ( tmp )
       
  1148                 {
       
  1149                 // realloc succeeded
       
  1150                 item.iItemDescriptor = tmp;
       
  1151                 item.iItemDescriptor->Des().Insert( 0, KIMHTTPPREFIX );
       
  1152                 }
       
  1153             }
       
  1154         }
       
  1155     if ( item.iItemType == CItemFinder::EUriScheme )
       
  1156         {
       
  1157         // some schemes (ie. "old ones") have special handling
       
  1158         const TDesC& pref = item.iItemDescriptor->Des().Left( KHttpLength );
       
  1159         if ( pref.CompareF( KIMHTTPPREFIX().Left( KHttpLength ) ) == 0
       
  1160              || pref.CompareF( KIMRTSP ) == 0 )
       
  1161             {
       
  1162             item.iItemType = CItemFinder::EUrlAddress;
       
  1163             }
       
  1164         }
       
  1165     }
       
  1166 
       
  1167 
       
  1168 // ---------------------------------------------------------
       
  1169 // CCAChatView::LaunchInvite
       
  1170 // ---------------------------------------------------------
       
  1171 //
       
  1172 TInt CCAChatView::LaunchInvite( TAny *aInstance )
       
  1173     {
       
  1174     // launch the invite with query
       
  1175     TRAPD(
       
  1176         err, static_cast<CCAChatView*>( aInstance )->DoLaunchInviteL( ETrue ) );
       
  1177 
       
  1178     if ( err != KErrNone )
       
  1179         {
       
  1180         CActiveScheduler::Current()->Error( err );
       
  1181         }
       
  1182 
       
  1183     return EFalse;
       
  1184     }
       
  1185 
       
  1186 // ---------------------------------------------------------
       
  1187 // CCAChatView::DoLaunchInviteL
       
  1188 // ---------------------------------------------------------
       
  1189 //
       
  1190 void CCAChatView::DoLaunchInviteL( TBool aShowQuery )
       
  1191     {
       
  1192     if ( iCba )
       
  1193         {
       
  1194         iCba->MakeVisible( ETrue );
       
  1195         iCba->DrawNow();
       
  1196         }
       
  1197 
       
  1198     if ( aShowQuery )
       
  1199         {
       
  1200         TInt retVal( IMDialogUtils::DisplayYesNoConfirmationDialogL(
       
  1201                          R_QTN_CHAT_INVITE_FRIENDS_NOW ) );
       
  1202         if ( retVal != EAknSoftkeyOk && retVal != EAknSoftkeyYes )
       
  1203             {
       
  1204             // user declined the query
       
  1205             return;
       
  1206             }
       
  1207         }
       
  1208 
       
  1209     if ( UISessionManager().IsSupported( CCAUISessionManager::EInvite ) )
       
  1210         {
       
  1211         iContainer->InviteFriendsToGroupL();
       
  1212         }
       
  1213     else
       
  1214         {
       
  1215         // We don't need the returned keycode.
       
  1216         IMDialogUtils::DisplayNoteDialogL( R_CHAT_ERROR_NOT_SUP_FUNCTIONS );
       
  1217         }
       
  1218     }
       
  1219 
       
  1220 
       
  1221 // ---------------------------------------------------------
       
  1222 // CCAChatView::HandleChatEvent
       
  1223 // (other items were commented in a header).
       
  1224 // ---------------------------------------------------------
       
  1225 //
       
  1226 void CCAChatView::HandleChatEvent( const TDesC& aWvid ,
       
  1227                                    const TDesC& aContactId  )
       
  1228     {
       
  1229 
       
  1230     TRAPD( err, DoHandleChatEventL( aWvid, aContactId ) );
       
  1231     if ( err != KErrNone )
       
  1232         {
       
  1233         CActiveScheduler::Current()->Error( err );
       
  1234         }
       
  1235 
       
  1236     }
       
  1237 
       
  1238 
       
  1239 // ---------------------------------------------------------
       
  1240 // CCAChatView::DoHandleChatEventL
       
  1241 // (other items were commented in a header).
       
  1242 // ---------------------------------------------------------
       
  1243 //
       
  1244 void CCAChatView::DoHandleChatEventL( const TDesC& aWvid ,
       
  1245                                       const TDesC& aContactId  )
       
  1246     {
       
  1247     HBufC* tempSender = aWvid.AllocL();
       
  1248     delete iSender;
       
  1249     iSender = tempSender;
       
  1250 
       
  1251     // nickname or wv-less contact id
       
  1252 
       
  1253 
       
  1254     iCleanSender.Set( aContactId );
       
  1255 
       
  1256     }
       
  1257 
       
  1258 // ---------------------------------------------------------
       
  1259 // CCAChatView::SwitchTabL
       
  1260 // (other items were commented in a header).
       
  1261 // ---------------------------------------------------------
       
  1262 //
       
  1263 void CCAChatView::SwitchTabL( const TDesC& aWvId, const TInt aTabIndex )
       
  1264     {
       
  1265     //change the contact id based on tteh currenttab
       
  1266     HBufC* group = aWvId.AllocL();
       
  1267     delete iGroupId;
       
  1268     iGroupId = group;
       
  1269 
       
  1270     iTabId = aTabIndex;
       
  1271 
       
  1272     CAAppUi()->CAStatusPane()->SetTitleL( CAAppUi()->CAStatusPane()->GetTabItemIdentification( iTabId ) );
       
  1273 
       
  1274 
       
  1275     iGroupPC->SetActiveGroupChatL( aWvId );
       
  1276 
       
  1277     //remove the controls from view stack
       
  1278     if ( iContainer )
       
  1279         {
       
  1280         CAAppUi()->RemoveFromViewStack( *this, iContainer );
       
  1281         }
       
  1282 
       
  1283     if ( iAddAndReplyMenu )
       
  1284         {
       
  1285         CAAppUi()->RemoveFromViewStack( *this, iAddAndReplyMenu );
       
  1286         }
       
  1287 
       
  1288     if ( iFindContextMenu )
       
  1289         {
       
  1290         CAAppUi()->RemoveFromViewStack( *this, iFindContextMenu );
       
  1291         }
       
  1292 
       
  1293 
       
  1294     iContainer->SwitchTabL();
       
  1295 
       
  1296     //again add those controls to view stack
       
  1297     if ( iContainer )
       
  1298         {
       
  1299         CAAppUi()->AddToViewStackL( *this, iContainer );
       
  1300         }
       
  1301 
       
  1302     if ( iAddAndReplyMenu )
       
  1303         {
       
  1304         CAAppUi()->AddToViewStackL( *this, iAddAndReplyMenu, ECoeStackPriorityDefault,
       
  1305                                     ECoeStackFlagRefusesFocus );
       
  1306         }
       
  1307 
       
  1308     if ( iFindContextMenu )
       
  1309         {
       
  1310         CAAppUi()->AddToStackL( *this, iFindContextMenu, ECoeStackPriorityDefault,
       
  1311                                 ECoeStackFlagRefusesFocus );
       
  1312         }
       
  1313 
       
  1314     }
       
  1315 
       
  1316 
       
  1317 // ---------------------------------------------------------
       
  1318 // CCAChatView::HandleMessageError
       
  1319 // ---------------------------------------------------------
       
  1320 //
       
  1321 void CCAChatView::HandleMessageError( TInt aError,
       
  1322                                       const TDesC& aNick )
       
  1323     {
       
  1324     TRAPD( err, DoHandleMessageErrorL( aError, aNick ) );
       
  1325     if ( err != KErrNone )
       
  1326         {
       
  1327         CActiveScheduler::Current()->Error( err );
       
  1328         }
       
  1329     }
       
  1330 
       
  1331 // ---------------------------------------------------------
       
  1332 // CCAChatView::DoHandleMessageErrorL
       
  1333 // ---------------------------------------------------------
       
  1334 //
       
  1335 void CCAChatView::DoHandleMessageErrorL( TInt aError,
       
  1336                                          const TDesC& aNick )
       
  1337     {
       
  1338     if ( aError == KErrNoMemory ) // handled in AppUi::HandleMessageError
       
  1339         {
       
  1340         return;
       
  1341         }
       
  1342     else if ( aError == TEnumsPC::EContentPicture )
       
  1343         {
       
  1344         TInt res( aError == KErrOverflow ?
       
  1345                   R_QTN_CHAT_SCALING_IMAGE_TOO_BIG :
       
  1346                   R_QTN_CHAT_SCALING_ERROR );
       
  1347 
       
  1348         // sending of image failed
       
  1349         IMDialogUtils::DisplayInformationNoteL( res );
       
  1350         return;
       
  1351         }
       
  1352 
       
  1353     CHAT_DP(
       
  1354         D_CHAT_LIT( "CCAChatViewContainer::DoHandleMessageErrorL %d %S" ),
       
  1355         aError,
       
  1356         &aNick );
       
  1357 
       
  1358     IMNoteMapper::ShowNoteL( aError, aNick );
       
  1359 
       
  1360 
       
  1361     }
       
  1362 
       
  1363 // ---------------------------------------------------------
       
  1364 // CCAChatView::GetIfMenuPopup()
       
  1365 // ---------------------------------------------------------
       
  1366 //
       
  1367 TBool CCAChatView::GetIfMenuPopup()
       
  1368     {
       
  1369     TBool reValue = EFalse;
       
  1370     if ( !iMenuPane )
       
  1371         {
       
  1372         reValue = EFalse;
       
  1373         }
       
  1374     else
       
  1375         {
       
  1376         reValue = iMenuPane->IsFocused();
       
  1377         }
       
  1378     return reValue;
       
  1379     }
       
  1380 // End of File