wvuing/wvuiave/AppSrc/ccainvitationcontainer.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:  Private chat list view's container class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CCAInvitationContainer.h"
       
    21 #include    "ccainvitationview.h"
       
    22 #include    "caexternalinterface.h"
       
    23 #include	"IMDialogUtils.h"
       
    24 
       
    25 #include    "MCAViewSwitcher.h"
       
    26 
       
    27 #include    "CCAStatusPaneHandler.h"
       
    28 #include    "ChatDebugPrint.h"
       
    29 #include    "CCABlockingUI.h"
       
    30 #include    "chatngclient.hrh"
       
    31 #include	"CCAAppUi.h"
       
    32 #include    "MCASkinVariant.h"
       
    33 #include    "CCAVariantFactory.h"
       
    34 #include    "CCAApp.h"
       
    35 #include    "CCAGroupUtils.h"
       
    36 #include    "IMUtils.h"
       
    37 #include    "CAUtils.h"
       
    38 #include    "ChatDebugAssert.h"
       
    39 
       
    40 #include	"MCAUiLoginCmdCB.h"
       
    41 #include 	"MCABlockingPC.h"
       
    42 #include    "MCAProcessManager.h"
       
    43 #include    "MCAMainviewArrayPC.h"
       
    44 #include    "MCAInvitationPC.h"
       
    45 #include    "MCASettingsPC.h"
       
    46 #include    "TEnumsPC.h"
       
    47 #include    "CCATextViewControl.h"
       
    48 #include	"CATouchUtils.h"
       
    49 #include	"MCARecipientObserver.h"
       
    50 #include 	"CCAProcessManagerFactory.h"
       
    51 
       
    52 #include    "ImpsCSPAllErrors.h"
       
    53 
       
    54 #include    <chatNG.mbg>
       
    55 #include    <barsread.h>
       
    56 #include	<impserrors.h>
       
    57 #include    <chatNG.rsg>
       
    58 #include    <aknlists.h>
       
    59 #include    <eikclbd.h>
       
    60 #include    <aknnotedialog.h>
       
    61 #include    <aknsfld.h>
       
    62 #include	<stringloader.h>
       
    63 #include    <aknquerydialog.h>
       
    64 #include    <AknIconUtils.h>
       
    65 #include    <akniconarray.h>
       
    66 #include    <txtrich.h>
       
    67 #include    <aknenv.h>
       
    68 #include    <aknsettingcache.h>
       
    69 #include    <aknutils.h>
       
    70 #include    <AknsUtils.h>
       
    71 #include    <AppLayout.cdl.h>
       
    72 #include    <AknsBasicBackgroundControlContext.h>
       
    73 #include    <hlplch.h>
       
    74 #include	<csxhelp/imng.hlp.hrh>
       
    75 // The Settings have been moved to Cenrep (also retained in the Resource file),
       
    76 // so the enums for keys and central repository header is added here
       
    77 #include 	"VariantKeys.h"
       
    78 
       
    79 
       
    80 // constants
       
    81 const TInt KTextMargin = 100;  // normal text margin in twips
       
    82 const TInt KBoldMargin = 200;  // bold text margin in twips
       
    83 const TInt KSpaceBefore = 10;  // space before each paragraph (twips)
       
    84 const TInt KPixelsBetweenLines = 5; // pixels between text lines
       
    85 
       
    86 // ============================ MEMBER FUNCTIONS ===============================
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CCAInvitationContainer::NewL()
       
    90 // Two-phased constructor.
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 CCAInvitationContainer* CCAInvitationContainer::NewL(
       
    94     const TRect& aRect,
       
    95     TInt aInvitationIndex,
       
    96     TPtr aRejectReason,
       
    97     MCAViewSwitcher& aViewSwitcher,
       
    98     CCAView& aView,
       
    99     TInt& aTabId,
       
   100     TBool aContextFlag,
       
   101     MCARecipientObserver& aMenuObserver )
       
   102     {
       
   103     CCAInvitationContainer* self =
       
   104         new ( ELeave ) CCAInvitationContainer( aViewSwitcher,
       
   105                                                aInvitationIndex,
       
   106                                                aRejectReason,
       
   107                                                aView,
       
   108                                                aTabId,
       
   109                                                aContextFlag,
       
   110                                                aMenuObserver );
       
   111     CleanupStack::PushL( self );
       
   112     self->ConstructL( aRect );
       
   113     CleanupStack::Pop( self );
       
   114     return self;
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CCAInvitationContainer::CCAInvitationContainer()
       
   119 // C++ default constructor can NOT contain any code, that
       
   120 // might leave.
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 CCAInvitationContainer::CCAInvitationContainer( MCAViewSwitcher& aViewSwitcher,
       
   124                                                 TInt aInvitationIndex,
       
   125                                                 TPtr aRejectReason,
       
   126                                                 CCAView& aView,
       
   127                                                 TInt& aTabId,
       
   128                                                 TBool aContextFlag,
       
   129                                                 MCARecipientObserver& aMenuObserver )
       
   130         : iViewSwitcher( aViewSwitcher ),
       
   131         iView( aView ),
       
   132         iInvitationIndex( aInvitationIndex ),
       
   133         iRejectReason( aRejectReason ),
       
   134         iTabId( aTabId ),
       
   135         iContextFlag( aContextFlag ),
       
   136         iMenuObserver( aMenuObserver ),
       
   137         iLongTapUsed( EFalse )
       
   138     {
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CCAInvitationContainer::ConstructL()
       
   143 // Symbian 2nd phase constructor can leave.
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 void CCAInvitationContainer::ConstructL( const TRect& aRect )
       
   147     {
       
   148     CreateWindowL();
       
   149     iAppUi = static_cast<CCAAppUi*>( CEikonEnv::Static()->AppUi() );
       
   150     iAppUi->AddLayoutChangeObserver( this );
       
   151     iInvitationPC = iAppUi->GetProcessManager().GetInvitationsInterface();
       
   152     iBgContext = CAknsBasicBackgroundControlContext::NewL(
       
   153                      KAknsIIDQsnBgAreaMainMessage, Rect(), ETrue );
       
   154 
       
   155     // Granularity of 2 because we have listbox and findbox
       
   156     iControlArray = new ( ELeave ) CArrayPtrSeg<CCoeControl>( 2 );
       
   157 
       
   158     // Construct CAknLongTapDetector object
       
   159     LongTapDetectorL();
       
   160 
       
   161     // construct rich text object and basic formatting
       
   162     iParaFormatLayer = CParaFormatLayer::NewL();
       
   163     iCharFormatLayer = CCharFormatLayer::NewL();
       
   164     SetRect( aRect );
       
   165 
       
   166     MCABlockingPC* blockingPC = iAppUi->GetProcessManager().GetBlockingInterface();
       
   167 
       
   168 
       
   169     iBlockingUI = CCABlockingUI::NewL( blockingPC );
       
   170 
       
   171     iCba = CEikButtonGroupContainer::Current();
       
   172     UpdateCbaL();
       
   173 
       
   174     ActivateL();
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CCAInvitationContainer::~CCAInvitationContainer()
       
   179 // Symbian 2nd phase constructor can leave.
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 
       
   183 CCAInvitationContainer::~CCAInvitationContainer()
       
   184     {
       
   185     if ( iAppUi && !iAppUi->IsUnderDestruction() )
       
   186         {
       
   187         iAppUi->RemoveLayoutChangeObserver( this );
       
   188         }
       
   189 
       
   190     if ( iControlArray )
       
   191         {
       
   192         iControlArray->ResetAndDestroy();
       
   193         }
       
   194 
       
   195 
       
   196     delete iControlArray;
       
   197     delete iBlockingUI;
       
   198     if ( iParaFormatLayer )
       
   199         {
       
   200         delete iParaFormatLayer;
       
   201         iParaFormatLayer = NULL;
       
   202         }
       
   203     if ( iCharFormatLayer )
       
   204         {
       
   205         delete iCharFormatLayer;
       
   206         iCharFormatLayer = NULL;
       
   207         }
       
   208 
       
   209     if ( iRichText )
       
   210         {
       
   211         delete iRichText;
       
   212         iRichText = NULL;
       
   213         }
       
   214     delete iBgContext;
       
   215 
       
   216     delete iIdentification;
       
   217 
       
   218     delete iDateTime;
       
   219 
       
   220     delete iLongTapDetector;
       
   221     }
       
   222 
       
   223 // ---------------------------------------------------------
       
   224 // CCAInvitationContainer::DisplayBlockedListL()
       
   225 // Displays list of blocked persons
       
   226 // (other items were commented in a header).
       
   227 // ---------------------------------------------------------
       
   228 //
       
   229 void CCAInvitationContainer::DisplayBlockedListL() const
       
   230     {
       
   231     iBlockingUI->DisplayBlockedListL();
       
   232     }
       
   233 
       
   234 // ---------------------------------------------------------
       
   235 // CCAInvitationContainer::DisplayUnblockListQueryL()
       
   236 // Displays unblock list query
       
   237 // (other items were commented in a header).
       
   238 // ---------------------------------------------------------
       
   239 //
       
   240 void CCAInvitationContainer::DisplayUnblockListQueryL() const
       
   241     {
       
   242     iBlockingUI->DisplayUnblockListQueryL();
       
   243     }
       
   244 
       
   245 
       
   246 // ---------------------------------------------------------
       
   247 // CCAInvitationContainer::DisplayBlockTextQueryL()
       
   248 // Displays query that takes input for wvid
       
   249 // (other items were commented in a header)
       
   250 // ---------------------------------------------------------
       
   251 void CCAInvitationContainer::DisplayBlockTextQueryL() const
       
   252     {
       
   253     iBlockingUI->DisplayBlockTextQueryL();
       
   254     }
       
   255 
       
   256 // ---------------------------------------------------------
       
   257 // CCAInvitationContainer::JoinToGroupL()
       
   258 // (other items were commented in a header).
       
   259 // ---------------------------------------------------------
       
   260 //
       
   261 void CCAInvitationContainer::JoinToGroupL( TInt aInviteIndex )
       
   262     {
       
   263     CHAT_DP_TXT( "invitation accepted" );
       
   264 
       
   265     // we must store the groupid because it's not valid after replying
       
   266     HBufC* groupId = iInvitationPC->GroupName( aInviteIndex ).AllocLC();
       
   267 
       
   268     HBufC* screenName =
       
   269         static_cast<CCAAppUi*>( iCoeEnv->AppUi() )->ScreenNamePtr();
       
   270     // join the group
       
   271     TInt err = iAppUi->GroupUtils()->JoinGroupL( EFalse, *groupId, screenName->Des() );
       
   272     if ( err == EOperationCancelled)
       
   273     	{
       
   274         CleanupStack::PopAndDestroy( groupId );
       
   275     	return; 
       
   276     	}
       
   277     if ( ( err == ECSPInvalidParameter ) || ( err == ECSPGroupDoesNotExist ) )
       
   278         {
       
   279         // If for some reason Group doesnt exist/Invalid, since we have called
       
   280         // ReplyInvitationL, the current invitation becomes invalid.
       
   281         // So even we cannot switch to the group view, as the group is invalid/doesnt exist
       
   282         // So better goback to the main view.
       
   283         if ( iAppUi->CAStatusPane() )
       
   284             {
       
   285             iAppUi->CAStatusPane()->SynchroniseAndRemoveTabGroup();
       
   286             }
       
   287         iAppUi->SwitchViewBackL( KUidFriendsListView );
       
   288         }
       
   289 
       
   290     // send invitation reply
       
   291     HBufC* ownWVIDbuf = iAppUi->GetProcessManager().GetSettingsInterface( )->
       
   292                         GetSapSettingValuePCL( TEnumsPC::EOwnWVUserID, NULL );
       
   293     CleanupStack::PushL( ownWVIDbuf );
       
   294     iInvitationPC->ReplyInvitationL( aInviteIndex , ETrue, KNullDesC,
       
   295                                      *ownWVIDbuf );
       
   296     CleanupStack::PopAndDestroy( ownWVIDbuf );
       
   297 
       
   298     CleanupStack::PopAndDestroy( groupId );
       
   299     }
       
   300 
       
   301 // ---------------------------------------------------------
       
   302 // CCAInvitationContainer::LayoutChangedL()
       
   303 // (other items were commented in a header).
       
   304 // ---------------------------------------------------------
       
   305 //
       
   306 void CCAInvitationContainer::LayoutChangedL( TInt aType )
       
   307     {
       
   308 
       
   309     TRect mainPaneRect;
       
   310     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
   311     SetRect( mainPaneRect );
       
   312     CCoeControl::HandleResourceChange( aType );
       
   313     }
       
   314 
       
   315 // ---------------------------------------------------------
       
   316 //  CCAInvitationContainer::SizeChanged()
       
   317 // (other items were commented in a header).
       
   318 // ---------------------------------------------------------
       
   319 //
       
   320 void CCAInvitationContainer::SizeChanged()
       
   321     {
       
   322     // Update the font to correct size
       
   323     if ( iParaFormatLayer && iCharFormatLayer )
       
   324         {
       
   325         // Correct font
       
   326         const CFont* font = GetLayoutFont();
       
   327 
       
   328         // format richtext
       
   329         TInt lineSpacing( font->HeightInPixels() + KPixelsBetweenLines );
       
   330         CParaFormat paraFormat;
       
   331         TParaFormatMask paraFormatMask;
       
   332         paraFormat.iLineSpacingControl =
       
   333             CParaFormat::ELineSpacingExactlyInPixels;
       
   334         paraFormatMask.SetAttrib( EAttLineSpacingControl );
       
   335         paraFormat.iLineSpacingInTwips = lineSpacing;
       
   336         paraFormatMask.SetAttrib( EAttLineSpacing );
       
   337         paraFormat.iLanguage =
       
   338             CAknEnv::Static()->SettingCache().InputLanguage();
       
   339         paraFormatMask.SetAttrib( EAttParaLanguage );
       
   340         paraFormat.iLeftMarginInTwips = KTextMargin;
       
   341         paraFormatMask.SetAttrib( EAttLeftMargin );
       
   342         paraFormat.iSpaceBeforeInTwips = KSpaceBefore;
       
   343         paraFormatMask.SetAttrib( EAttSpaceBefore );
       
   344 
       
   345         TCharFormat charFormat;
       
   346         TCharFormatMask charFormatMask;
       
   347         charFormat.iFontSpec = font->FontSpecInTwips();
       
   348         charFormatMask.SetAttrib( EAttFontTypeface );
       
   349         charFormatMask.SetAttrib( EAttFontHeight );
       
   350         // 215 = Color from application LAF (Smart message)
       
   351         charFormat.iFontPresentation.iTextColor = AKN_LAF_COLOR_STATIC( 215 );
       
   352         charFormatMask.SetAttrib( EAttColor );
       
   353 
       
   354         //can't leave here
       
   355         TRAPD( err, iParaFormatLayer->SetL( &paraFormat, paraFormatMask );
       
   356                iCharFormatLayer->SetL( charFormat, charFormatMask ) );
       
   357         if ( err != KErrNone )
       
   358             {
       
   359             CHAT_DP(
       
   360                 D_CHAT_LIT( "CCAInvitationContainer::SizeChanged leave: %d!" ),
       
   361                 err );
       
   362             CActiveScheduler::Current()->Error( err );
       
   363             }
       
   364 
       
   365         }
       
   366 
       
   367     if ( iTextView )
       
   368         {
       
   369         iTextView->SetRect( Rect() );
       
   370         }
       
   371 
       
   372     if ( iBgContext )
       
   373         {
       
   374         iBgContext->SetRect( Rect() );
       
   375         iBgContext->SetParentPos( PositionRelativeToScreen() );
       
   376         }
       
   377 
       
   378     SetLayout();
       
   379     }
       
   380 
       
   381 // ---------------------------------------------------------
       
   382 //
       
   383 // (other items were commented in a header).
       
   384 // ---------------------------------------------------------
       
   385 //
       
   386 TInt CCAInvitationContainer::CountComponentControls() const
       
   387     {
       
   388     return iControlArray->Count();
       
   389     }
       
   390 
       
   391 // ---------------------------------------------------------
       
   392 //
       
   393 // (other items were commented in a header).
       
   394 // ---------------------------------------------------------
       
   395 //
       
   396 CCoeControl* CCAInvitationContainer::ComponentControl( TInt aIndex ) const
       
   397     {
       
   398     if ( ( aIndex < 0 ) || ( aIndex >= iControlArray->Count() ) )
       
   399         {
       
   400         return NULL;
       
   401         }
       
   402     return iControlArray->At( aIndex );
       
   403     }
       
   404 
       
   405 // ---------------------------------------------------------
       
   406 //
       
   407 // (other items were commented in a header).
       
   408 // ---------------------------------------------------------
       
   409 //
       
   410 TKeyResponse CCAInvitationContainer::OfferKeyEventL( const TKeyEvent& aEvent,
       
   411                                                      TEventCode aType )
       
   412     {
       
   413     if ( aEvent.iScanCode == EStdKeyYes )
       
   414         {
       
   415         return EKeyWasConsumed;
       
   416         }
       
   417 
       
   418     CHAT_DP( D_CHAT_LIT(
       
   419                  "CCAInvitationContainer::OfferKeyEventL %d %d" ),
       
   420              aEvent,
       
   421              aType );
       
   422     switch ( aEvent.iCode )
       
   423         {
       
   424         case EKeyBackspace:
       
   425             {
       
   426             // ask the confirmation
       
   427             HBufC* prompt =
       
   428                 iEikonEnv->AllocReadResourceLC( R_CHAT_CONV_LIST_INV_DEL );
       
   429             CAknQueryDialog* dlg = new( ELeave )CAknQueryDialog();
       
   430             CleanupStack::PushL( dlg );
       
   431             dlg->SetPromptL( prompt->Des() );
       
   432             CleanupStack::Pop( dlg );
       
   433             TInt ret( dlg->ExecuteLD( R_CLOSE_COVERSATION_QUERY ) );
       
   434             CleanupStack::PopAndDestroy( prompt );
       
   435             // should be deleted
       
   436             if ( ( ret == EAknSoftkeyOk ) || ( ret == EAknSoftkeyYes ) )
       
   437                 {
       
   438                 DeleteInvitationL( iInvitationIndex );
       
   439                 if ( iAppUi->CAStatusPane() )
       
   440                     {
       
   441                     iAppUi->CAStatusPane()->SynchroniseAndRemoveTabGroup();
       
   442                     }
       
   443                 iAppUi->SwitchViewBackL( KUidFriendsListView );
       
   444                 }
       
   445             return EKeyWasConsumed;
       
   446             }
       
   447 
       
   448         // Flowthrough, because cases are identical.
       
   449         case EKeyRightArrow:
       
   450         case EKeyLeftArrow:
       
   451             {
       
   452             return iAppUi->OfferTabEventL( aEvent, aType );
       
   453             }
       
   454 
       
   455         case EKeyDownArrow:
       
   456             {
       
   457             //Only if the last line is not visible send the key
       
   458             //to the texControl so that it scrolls, hence dont consume the key
       
   459             //If the lastline is viewable no necessity to scroll any more, hence
       
   460             //consume the key
       
   461 
       
   462             if ( !iTextView->IsVisible( iLastSelection.HigherPos() ) )
       
   463                 {
       
   464                 // we're scrolling down and bottom line is not shown,
       
   465                 // so scroll messages up by one line
       
   466                 return EKeyWasNotConsumed;
       
   467                 }
       
   468 
       
   469             return EKeyWasConsumed;
       
   470             }
       
   471 
       
   472         case EKeyEnter:
       
   473             {
       
   474             iMenuObserver.ShowPopUpMenuL();
       
   475             return EKeyWasConsumed;
       
   476             }
       
   477 
       
   478         default:
       
   479             {
       
   480             break;
       
   481             }
       
   482         }
       
   483 
       
   484     UpdateCbaL();
       
   485     return EKeyWasNotConsumed;
       
   486     }
       
   487 
       
   488 // ---------------------------------------------------------
       
   489 //
       
   490 // (other items were commented in a header).
       
   491 // ---------------------------------------------------------
       
   492 //
       
   493 void CCAInvitationContainer::GetHelpContext(
       
   494     TCoeHelpContext& aContext ) const
       
   495     {
       
   496     aContext.iMajor = KUidChatClient;
       
   497     aContext.iContext = KIMNG_HLP_INVITE ;
       
   498     }
       
   499 
       
   500 // ---------------------------------------------------------
       
   501 //
       
   502 // (other items were commented in a header).
       
   503 // ---------------------------------------------------------
       
   504 //
       
   505 void CCAInvitationContainer::SetLayout()
       
   506     {
       
   507 
       
   508     }
       
   509 // ---------------------------------------------------------
       
   510 // CCAInvitationContainer::HandleError
       
   511 // (other items were commented in a header).
       
   512 // ---------------------------------------------------------
       
   513 //
       
   514 void CCAInvitationContainer::HandleError( TInt aError ) const
       
   515     {
       
   516     CHAT_DP( D_CHAT_LIT( "CCAInvitationContainer::HandleError,\
       
   517                           aError = %d" ), aError );
       
   518 
       
   519     if ( aError )
       
   520         {
       
   521         CActiveScheduler::Current()->Error( aError );
       
   522         }
       
   523     }
       
   524 
       
   525 // -----------------------------------------------------------------------------
       
   526 // CCAInvitationContainer::IsInvitationOpen
       
   527 // (other items were commented in a header)
       
   528 // -----------------------------------------------------------------------------
       
   529 //
       
   530 TBool CCAInvitationContainer::IsInvitationOpen()
       
   531     {
       
   532     return iInvitationOpen;
       
   533     }
       
   534 
       
   535 // -----------------------------------------------------------------------------
       
   536 // CCAInvitationContainer::UpdateCbaL
       
   537 // (other items were commented in a header)
       
   538 // -----------------------------------------------------------------------------
       
   539 //
       
   540 void CCAInvitationContainer::UpdateCbaL()
       
   541     {
       
   542     TInt cbaRes = R_CHAT_SOFTKEYS_OPTIONS_BACK__CONTEXTOPTIONS;
       
   543     iCba->SetCommandSetL( cbaRes );
       
   544     iCba->DrawNow();
       
   545     }
       
   546 
       
   547 // -----------------------------------------------------------------------------
       
   548 // CCAInvitationContainer::SwitchToSingleListViewL
       
   549 // (other items were commented in a header)
       
   550 // -----------------------------------------------------------------------------
       
   551 //
       
   552 void CCAInvitationContainer::SwitchToSingleListViewL( )
       
   553     {
       
   554     iAppUi->SwitchViewL( KUidFriendsListView );
       
   555     }
       
   556 
       
   557 // -----------------------------------------------------------------------------
       
   558 // CCAInvitationContainer::DeleteInvitation
       
   559 // (other items were commented in a header)
       
   560 // -----------------------------------------------------------------------------
       
   561 //
       
   562 void CCAInvitationContainer::DeleteInvitationL( TInt aInviteindex )
       
   563     {
       
   564     iInvitationPC->DeleteInvitationL( aInviteindex );
       
   565     }
       
   566 
       
   567 // -----------------------------------------------------------------------------
       
   568 // CCAInvitationContainer::RejectInvitationL
       
   569 // (other items were commented in a header)
       
   570 // -----------------------------------------------------------------------------
       
   571 //
       
   572 void CCAInvitationContainer::RejectInvitationL( TInt aInviteindex, TPtr aRejectReason )
       
   573     {
       
   574     CHAT_DP_TXT( "invitation rejected" );
       
   575 
       
   576     // and send invitation reply (reject)
       
   577     HBufC* ownWVIDbuf = iAppUi->GetProcessManager().GetSettingsInterface( )->
       
   578                         GetSapSettingValuePCL( TEnumsPC::EOwnWVUserID, NULL );
       
   579     CleanupStack::PushL( ownWVIDbuf );
       
   580 
       
   581     iInvitationPC->ReplyInvitationL( aInviteindex, EFalse, aRejectReason, *ownWVIDbuf );
       
   582     CleanupStack::PopAndDestroy( ownWVIDbuf );
       
   583     }
       
   584 
       
   585 // -----------------------------------------------------------------------------
       
   586 // CCAInvitationContainer::InvitationSwitchTabL
       
   587 // (other items were commented in a header)
       
   588 // -----------------------------------------------------------------------------
       
   589 //
       
   590 void CCAInvitationContainer::InvitationSwitchTabL( TInt iCurrenntActiveTab )
       
   591     {
       
   592     CHAT_DP_TXT( "Switching between invitations" );
       
   593     PrepareTextL( iCurrenntActiveTab );
       
   594 
       
   595     }
       
   596 
       
   597 // -----------------------------------------------------------------------------
       
   598 // CCAInvitationContainer::PrepareTextL
       
   599 // (other items were commented in a header)
       
   600 // -----------------------------------------------------------------------------
       
   601 //
       
   602 void CCAInvitationContainer::PrepareTextL( TInt aInvitationIndex )
       
   603     {
       
   604     TInt invitationIndex = aInvitationIndex;
       
   605 
       
   606     delete iIdentification;
       
   607     iIdentification = NULL;
       
   608 
       
   609     iIdentification = iInvitationPC->InvUserIdentificationL( invitationIndex ).AllocL();
       
   610 
       
   611     // get and format the time/date string
       
   612     HBufC* tFormat = iEikonEnv->AllocReadResourceLC(
       
   613                          R_QTN_TIME_USUAL_WITH_ZERO );
       
   614     HBufC* dFormat = iEikonEnv->AllocReadResourceLC(
       
   615                          R_QTN_DATE_SHORT_WITH_ZERO );
       
   616     CDesCArray* array = new( ELeave )CDesCArrayFlat( 2 ); // two items
       
   617     CleanupStack::PushL( array );
       
   618     array->AppendL( *tFormat );
       
   619     array->AppendL( *dFormat );
       
   620     HBufC* datetime = StringLoader::LoadLC( R_QTN_CHAT_INVITE_DATE_TIME,
       
   621                                             *array );
       
   622 
       
   623     delete iDateTime;
       
   624     iDateTime = NULL;
       
   625 
       
   626     iDateTime = HBufC::NewL( datetime->Length() );
       
   627     TPtr ptr( iDateTime->Des() );
       
   628 
       
   629 
       
   630     TTime receviedTime = iInvitationPC->ReceivedAt( invitationIndex );
       
   631     if ( receviedTime != 0 )
       
   632         {
       
   633         receviedTime.FormatL( ptr, *datetime );
       
   634         }
       
   635 
       
   636     AknTextUtils::LanguageSpecificNumberConversion( ptr );
       
   637 
       
   638 
       
   639     CleanupStack::PopAndDestroy( 4, tFormat );
       
   640 
       
   641 
       
   642     //delete the controls if any - as this might be called when u
       
   643     //switch between tabs
       
   644     if ( iControlArray )
       
   645         {
       
   646         iControlArray->ResetAndDestroy();
       
   647         }
       
   648 
       
   649     delete iRichText;
       
   650 
       
   651     iRichText = NULL;
       
   652     iTextView = NULL;
       
   653 
       
   654     iRichText = CRichText::NewL( iParaFormatLayer, iCharFormatLayer );
       
   655     // Set text colour according to skin
       
   656     TCharFormat charFormat;
       
   657     TCharFormatMask charFormatMask;
       
   658     TRgb defaultSkinTextColor( KRgbBlack );
       
   659     AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
       
   660                                defaultSkinTextColor,
       
   661                                KAknsIIDQsnTextColors,
       
   662                                EAknsCIQsnTextColorsCG6 );
       
   663     charFormat.iFontPresentation.iTextColor = defaultSkinTextColor;
       
   664     charFormatMask.SetAttrib( EAttColor );
       
   665     iRichText->SetInsertCharFormatL( charFormat, charFormatMask, 0 );
       
   666 
       
   667     AknsUtils::RegisterControlPosition( this );
       
   668     DisplayTextL( invitationIndex );
       
   669 
       
   670     }
       
   671 
       
   672 // -----------------------------------------------------------------------------
       
   673 // CCAInvitationContainer::DisplayTextL
       
   674 // (other items were commented in a header)
       
   675 // -----------------------------------------------------------------------------
       
   676 //
       
   677 void CCAInvitationContainer::DisplayTextL( TInt aInvitationindex )	//  End of File
       
   678     {
       
   679     // initialize the textviewcontrol now when we know the size of dialog
       
   680     iTextView = CCATextViewControl::NewL( Rect(), *this, iRichText );
       
   681 
       
   682     iTextView->SetRect( Rect() );
       
   683 
       
   684     iControlArray->AppendL( iTextView );
       
   685 
       
   686     InsertLineL( R_QTN_CHAT_INV_MESSAGE );
       
   687     InsertLineL( iInvitationPC->Message(  aInvitationindex ), ETrue );
       
   688 
       
   689     InsertLineL( R_QTN_CHAT_INV_FROM );
       
   690     InsertLineL( *iIdentification, ETrue );
       
   691 
       
   692     InsertLineL( R_QTN_CHAT_INV_TOGROUP );
       
   693 
       
   694     // Display group name instead of group id, if the process errors, display the group id
       
   695     TPtrC groupNamePtr = iAppUi->GroupUtils()->GetGroupName(
       
   696                              iInvitationPC->GroupName( aInvitationindex ) );
       
   697 
       
   698     if ( groupNamePtr.CompareC( KNullDesC ) )
       
   699         {
       
   700         InsertLineL( groupNamePtr, ETrue );
       
   701         }
       
   702     else
       
   703         {
       
   704         InsertLineL( CCAAppUi::DisplayId( iInvitationPC->GroupName( aInvitationindex ) ), ETrue );
       
   705         }
       
   706 
       
   707     InsertLineL( R_QTN_CHAT_INV_DATE );
       
   708     InsertLineL( *iDateTime, ETrue );
       
   709 
       
   710     // update scrollbars
       
   711     MCATextView* textView = static_cast<MCATextView*>( iTextView );
       
   712     TCursorSelection sel( 0, 0 );
       
   713     textView->ScrollVisibleL( sel, ETrue );
       
   714     textView->SetPenBehaviour( MCATextView::EPenForwardToParent );
       
   715 
       
   716     if ( iBgContext )
       
   717         {
       
   718         iBgContext->SetRect( Rect() );
       
   719         iBgContext->SetParentPos( PositionRelativeToScreen() );
       
   720         }
       
   721 
       
   722     }
       
   723 
       
   724 // -----------------------------------------------------------------------------
       
   725 // CCAInvitationContainer::InsertLineL
       
   726 // (other items were commented in a header).
       
   727 // -----------------------------------------------------------------------------
       
   728 //
       
   729 void CCAInvitationContainer::InsertLineL( TInt aTextResourceId,
       
   730                                           TBool aBold /*= EFalse*/ )
       
   731     {
       
   732     HBufC* text = iEikonEnv->AllocReadResourceLC( aTextResourceId );
       
   733     InsertLineL( *text, aBold );
       
   734     CleanupStack::PopAndDestroy( text );
       
   735     }
       
   736 
       
   737 // -----------------------------------------------------------------------------
       
   738 // CCAInvitationContainer::InsertLineL
       
   739 // (other items were commented in a header).
       
   740 // -----------------------------------------------------------------------------
       
   741 //
       
   742 void CCAInvitationContainer::InsertLineL( const TDesC& aText,
       
   743                                           TBool aBold /*= EFalse*/ )
       
   744     {
       
   745     TInt startPos( iRichText->DocumentLength() );
       
   746 
       
   747     if ( startPos != 0 )
       
   748         {
       
   749         // Start new paragraph if this is not the first line
       
   750         iRichText->InsertL( startPos,
       
   751                             CEditableText::EParagraphDelimiter );
       
   752         startPos++;
       
   753         }
       
   754 
       
   755     iRichText->InsertL( startPos, aText );
       
   756 
       
   757     //Store the cursor position of last line of the text.
       
   758     //this will help us in determining whether the lastline is
       
   759     //viewable or not.
       
   760     TInt endPos( iRichText->DocumentLength() );
       
   761 
       
   762     iLastSelection.SetSelection( endPos - 1, startPos );
       
   763 
       
   764     TCharFormat charFormat;
       
   765     TCharFormatMask charFormatMask;
       
   766 
       
   767     CParaFormat paraFormat;
       
   768     TParaFormatMask paraFormatMask;
       
   769 
       
   770     if ( aBold )
       
   771         {
       
   772         charFormat.iFontSpec.iFontStyle.SetStrokeWeight( EStrokeWeightBold );
       
   773         charFormatMask.SetAttrib( EAttFontStrokeWeight );
       
   774 
       
   775         paraFormat.iLeftMarginInTwips = KBoldMargin;
       
   776         paraFormatMask.SetAttrib( EAttLeftMargin );
       
   777         }
       
   778     else
       
   779         {
       
   780         charFormat.iFontSpec.iFontStyle.SetStrokeWeight( EStrokeWeightNormal );
       
   781         charFormatMask.SetAttrib( EAttFontStrokeWeight );
       
   782 
       
   783         paraFormat.iLeftMarginInTwips = KTextMargin;
       
   784         paraFormatMask.SetAttrib( EAttLeftMargin );
       
   785         }
       
   786 
       
   787     iRichText->ApplyCharFormatL( charFormat, charFormatMask,
       
   788                                  startPos, aText.Length() );
       
   789     iRichText->ApplyParaFormatL( &paraFormat, paraFormatMask,
       
   790                                  startPos, aText.Length() );
       
   791 
       
   792     if ( startPos != 0 )
       
   793         {
       
   794         startPos--;
       
   795         }
       
   796     TCursorSelection sel( iRichText->DocumentLength(), startPos );
       
   797     MCATextView* textView = static_cast<MCATextView*>( iTextView );
       
   798     textView->HandleFormatChangedL( sel );
       
   799     }
       
   800 
       
   801 // --------------------------------------------------------------------------
       
   802 // CCAInvitationContainer::LongTapDetectorL
       
   803 // --------------------------------------------------------------------------
       
   804 //
       
   805 CAknLongTapDetector& CCAInvitationContainer::LongTapDetectorL()
       
   806     {
       
   807     if ( !iLongTapDetector )
       
   808         {
       
   809         iLongTapDetector = CAknLongTapDetector::NewL( this );
       
   810         }
       
   811     return *iLongTapDetector;
       
   812     }
       
   813 
       
   814 // --------------------------------------------------------------------------
       
   815 // CCAInvitationContainer::HandleLongTapEventL
       
   816 // --------------------------------------------------------------------------
       
   817 //
       
   818 void CCAInvitationContainer::HandleLongTapEventL(
       
   819     const TPoint& /*aPenEventLocation*/,
       
   820     const TPoint& /*aPenEventScreenLocation*/ )
       
   821     {
       
   822     if ( CATouchUtils::PenEnabled() )
       
   823         {
       
   824         iLongTapUsed = ETrue;
       
   825         }
       
   826     }
       
   827 
       
   828 // ---------------------------------------------------------
       
   829 // CCAInvitationContainer::GetLayoutFont
       
   830 //
       
   831 // ---------------------------------------------------------
       
   832 //
       
   833 const CFont* CCAInvitationContainer::GetLayoutFont()
       
   834     {
       
   835     TAknLayoutText labelLayout;
       
   836     labelLayout.LayoutText( Rect(),
       
   837                             AppLayout::Smart_Messages_Line_2( 0 ) );
       
   838     return labelLayout.Font();
       
   839     }
       
   840 
       
   841 // ---------------------------------------------------------
       
   842 // CCAInvitationContainer::IsBlocked
       
   843 // ---------------------------------------------------------
       
   844 //
       
   845 TBool CCAInvitationContainer::IsBlocked( const TDesC& aUserId )
       
   846     {
       
   847     TBool isBlocked = EFalse;
       
   848     isBlocked = iAppUi->GetProcessManager().GetBlockingInterface( )->
       
   849                 IsContactBlocked( aUserId );
       
   850     return isBlocked;
       
   851     }
       
   852 
       
   853 
       
   854 // ---------------------------------------------------------
       
   855 // CCAInvitationContainer::HandlePointerEventL
       
   856 // ---------------------------------------------------------
       
   857 //
       
   858 void CCAInvitationContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   859     {
       
   860 
       
   861     if ( !CATouchUtils::PenEnabled() )
       
   862         {
       
   863         return;
       
   864         }
       
   865 
       
   866     // Long tap detect
       
   867     if ( iLongTapDetector )
       
   868         {
       
   869         iLongTapDetector->PointerEventL( aPointerEvent );
       
   870         }
       
   871 
       
   872     // Just return after long tap
       
   873     if ( aPointerEvent.iType == TPointerEvent::EButton1Up && iLongTapUsed )
       
   874         {
       
   875         iLongTapUsed = EFalse;
       
   876         return;
       
   877         }
       
   878 
       
   879     // Single tap on main pane (not on scroll bar)
       
   880     if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   881         {
       
   882         iMenuObserver.ShowPopUpMenuL();
       
   883         }
       
   884 
       
   885     }
       
   886 
       
   887 //End of file