wvuing/wvuiave/AppSrc/CCARecordedChatsArray.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:  Array wrapper for recorded chats view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include	"CCARecordedChatsArray.h"
       
    22 #include	"MCARecordedChatsPC.h"
       
    23 #include    "MCARecordedChatsArrayPC.h"
       
    24 #include	"ChatDefinitions.h"
       
    25 #include	"IMDialogUtils.h"
       
    26 #include    "chatngclient.hrh"
       
    27 #include    "IMUtils.h"
       
    28 
       
    29 #include    <avkon.rsg>
       
    30 #include    <chatNG.rsg>
       
    31 
       
    32 #include    <StringLoader.h>
       
    33 #include    <sendui.h>
       
    34 #include    <s32mem.h> //CBufStore
       
    35 #include    <s32file.h>
       
    36 #include    <txtrich.h>
       
    37 #include    <avkon.hrh>
       
    38 #include    <pathinfo.h>
       
    39 // The Settings have been moved to Cenrep (also retained in the Resource file),
       
    40 // so the enums for keys and central repository header is added here
       
    41 #include 	"VariantKeys.h"
       
    42 
       
    43 // CONSTANTS
       
    44 const TInt KOneSelected = 1;
       
    45 const TInt KNoneSelected = 0;
       
    46 
       
    47 
       
    48 // Format for listbox item.
       
    49 // 1\tTextLabel\tTimeAndDate
       
    50 // 2\tTextLabel\tTimeAndDate
       
    51 // First icon is mandatory and is chosen between group and I-messages (1\t 2\t ).
       
    52 //_LIT( KRecordedIMessageIcon, "1\t" );
       
    53 
       
    54 
       
    55 // ================= MEMBER FUNCTIONS =======================
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CCARecordedChatsArray::CCARecordedChatsArray
       
    59 // C++ default constructor can NOT contain any code, that
       
    60 // might leave.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CCARecordedChatsArray::CCARecordedChatsArray(
       
    64     MCARecordedChatsPC& aRecordedChatsPC,
       
    65     MCARecordedChatsArrayPC& aRecordedChatsArrayPC
       
    66 )
       
    67         : iRecordedChatsPC( aRecordedChatsPC ),
       
    68         iRecordedChatsArrayPC( aRecordedChatsArrayPC )
       
    69     {
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CCARecordedChatsArray::NewL
       
    74 // Two-phased constructor.
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 CCARecordedChatsArray* CCARecordedChatsArray::NewL(
       
    78     MCARecordedChatsPC& aRecordedChatsPC,
       
    79     MCARecordedChatsArrayPC& aRecordedChatsArrayPC )
       
    80     {
       
    81     CCARecordedChatsArray* self = new ( ELeave ) CCARecordedChatsArray(
       
    82         aRecordedChatsPC, aRecordedChatsArrayPC );
       
    83 
       
    84     CleanupStack::PushL( self );
       
    85     self->ConstructL();
       
    86     CleanupStack::Pop( self );
       
    87     return self;
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CCARecordedChatsArray::~CCARecordedChatsArray
       
    92 // Destructor
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 CCARecordedChatsArray::~CCARecordedChatsArray()
       
    96     {
       
    97 
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------
       
   101 // CCARecordedChatsArray::MdcaCount
       
   102 // Returns the number of descriptor elements in a descriptor array.
       
   103 // (other items were commented in a header).
       
   104 // ---------------------------------------------------------
       
   105 //
       
   106 TInt CCARecordedChatsArray::MdcaCount() const
       
   107     {
       
   108     TInt recChatCount = iRecordedChatsArrayPC.MdcaCount();
       
   109     /*if(recChatCount == 0)
       
   110     	{
       
   111     	recChatCount = 2;
       
   112     	}*/
       
   113     return recChatCount;
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CCARecordedChatsArray::MdcaCount
       
   118 // Return pointer to descriptor data in given index of an array
       
   119 // (other items were commented in a header).
       
   120 // ---------------------------------------------------------
       
   121 //
       
   122 TPtrC16 CCARecordedChatsArray::MdcaPoint( TInt aIndex ) const
       
   123     {
       
   124     __ASSERT_ALWAYS( aIndex >= 0,
       
   125                      User::Panic( KPanicText, EAccessArrayOutOfBounds ) );
       
   126     __ASSERT_ALWAYS( iRecordedChatsArrayPC.MdcaCount() > aIndex,
       
   127                      User::Panic( KPanicText, EAccessArrayOutOfBounds ) );
       
   128     TInt recChatCount = iRecordedChatsArrayPC.MdcaCount();
       
   129 
       
   130     return iRecordedChatsArrayPC.MdcaPoint( aIndex );
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CCARecordedChatsArray::ConstructL
       
   135 // Symbian OS default constructor
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CCARecordedChatsArray::ConstructL()
       
   139     {
       
   140     // If loggerheadersinterface is not provided, we cannot continue.
       
   141     // This happens when there is old version of CCAEngine used with
       
   142     // this version of UI.
       
   143     if ( !( &iRecordedChatsPC ) )
       
   144         {
       
   145         User::Leave( KErrNotFound );
       
   146         }
       
   147 
       
   148     }
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CCARecordedChatsArray::Name
       
   152 // Name of history file
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 const TDesC& CCARecordedChatsArray::Name( TInt aIndex ) const
       
   156     {
       
   157     // If history data with aIndex does not exists. iLogger.Name returns
       
   158     // KNullDesC, so index check is not needed.
       
   159     return iRecordedChatsArrayPC.Name( aIndex );
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CCARecordedChatsArray::DeleteHistoryFilesL
       
   164 // Delete history file. One or many.
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 TBool CCARecordedChatsArray::DeleteHistoryFilesL( TInt aIndex )
       
   168     {
       
   169     iRecordedChatsPC.DeleteHistoryFilesL( aIndex, iDeleteCurrentChat );
       
   170     if ( !iDeleteCurrentChat ) // Confirmation is already asked
       
   171         {
       
   172         if ( !ShowConfirmationNoteL( iRecordedChatsArrayPC.GetNextIndex() ) )
       
   173             {
       
   174             return EFalse;
       
   175             }
       
   176         }
       
   177 
       
   178     //Set current chat deletion false
       
   179     iDeleteCurrentChat = EFalse;
       
   180 
       
   181     return ETrue;
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 //  CCARecordedChatsArray::DeleteHistoryFileL
       
   186 //  Delete one file and update index.
       
   187 //	Return ETrue, when there is still work to be done,
       
   188 //  and EFalse, when work is done.
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 TBool CCARecordedChatsArray::DeleteHistoryFileL()
       
   192     {
       
   193     return iRecordedChatsPC.DeleteHistoryFileL();
       
   194     }
       
   195 
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // CCARecordedChatsArray::SetCurrentItemIndex
       
   199 // Set current item.
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 void CCARecordedChatsArray::SetCurrentItemIndex( TInt aIndex )
       
   203     {
       
   204     iRecordedChatsArrayPC.SetCurrentItemIndex( aIndex );
       
   205     }
       
   206 
       
   207 // -----------------------------------------------------------------------------
       
   208 // CCARecordedChatsArray::RecordedChatName
       
   209 // Name of recorded chat item.
       
   210 // -----------------------------------------------------------------------------
       
   211 //
       
   212 const TDesC& CCARecordedChatsArray::RecordedChatName() const
       
   213     {
       
   214     return Name( iRecordedChatsArrayPC.GetCurrentItemIndex() );
       
   215     }
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // CCARecordedChatsArray::RecordedEndDate
       
   219 // End date of recorded chat item.
       
   220 // -----------------------------------------------------------------------------
       
   221 //
       
   222 TTime CCARecordedChatsArray::RecordedEndDate() const
       
   223     {
       
   224     return iRecordedChatsArrayPC.EndTime( iRecordedChatsArrayPC.GetCurrentItemIndex() );
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CCARecordedChatsArray::SendMTML
       
   229 // MTM editor launcher.
       
   230 // Code Scanner warning to be ignored:L-funtion returing error code
       
   231 // -----------------------------------------------------------------------------
       
   232 //
       
   233 TInt CCARecordedChatsArray::SendMTML( TInt aIndex, TUid aTargetUid /*= KNullUid*/ )
       
   234     {
       
   235     return iRecordedChatsPC.SendMTML( aIndex, aTargetUid );
       
   236     }
       
   237 
       
   238 // -----------------------------------------------------------------------------
       
   239 // CCARecordedChatsArray::CheckAndCorrectMTMFilename
       
   240 // Check and correct proposed filename for MTM sending purposes.
       
   241 // -----------------------------------------------------------------------------
       
   242 //
       
   243 void CCARecordedChatsArray::CheckAndCorrectMtmFilename( TFileName& aFilename,
       
   244                                                         MDesCArray& aArray )
       
   245     {
       
   246     iRecordedChatsPC.CheckAndCorrectMtmFilename( aFilename, aArray );
       
   247     }
       
   248 
       
   249 // -----------------------------------------------------------------------------
       
   250 // CCARecordedChatsArray::DeleteChatL()
       
   251 // set current chat to be deleted
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 TBool CCARecordedChatsArray::DeleteChatL()
       
   255     {
       
   256     //set current chat to be deleted.
       
   257     iDeleteCurrentChat = ShowConfirmationNoteL( iRecordedChatsArrayPC.GetCurrentItemIndex() );
       
   258     return iDeleteCurrentChat;
       
   259     }
       
   260 
       
   261 // -----------------------------------------------------------------------------
       
   262 // CCARecordedChatsArray::SendChatViaMTML
       
   263 // Send current chat via MTM
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 void CCARecordedChatsArray::SendChatViaMTML( TUid aTargetUid /*= KNullUid*/ )
       
   267     {
       
   268     SendMTML( iRecordedChatsArrayPC.GetCurrentItemIndex(), aTargetUid );
       
   269     }
       
   270 
       
   271 // -----------------------------------------------------------------------------
       
   272 // CCARecordedChatsArray::CurrentChatDeleteStatus
       
   273 // Is current chat ordered to be deleted.
       
   274 // -----------------------------------------------------------------------------
       
   275 //
       
   276 TBool CCARecordedChatsArray::CurrentChatDeleteStatus()
       
   277     {
       
   278     return iDeleteCurrentChat;
       
   279     }
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CCARecordedChatsArray::ProgressCount
       
   283 // Deletion progress count.
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 TInt CCARecordedChatsArray::ProgressCount() const
       
   287     {
       
   288     return iRecordedChatsArrayPC.GetProgressCount();
       
   289     }
       
   290 
       
   291 // -----------------------------------------------------------------------------
       
   292 // CCARecordedChatsArray::CurrentItemIndex
       
   293 // Return current item index
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 TInt CCARecordedChatsArray::CurrentItemIndex() const
       
   297     {
       
   298     return iRecordedChatsArrayPC.GetCurrentItemIndex();
       
   299     }
       
   300 
       
   301 // -----------------------------------------------------------------------------
       
   302 // CCARecordedChatsArray::ShowConfirmationNoteL
       
   303 // Show confirmation note for deletion.
       
   304 // -----------------------------------------------------------------------------
       
   305 //
       
   306 TBool CCARecordedChatsArray::ShowConfirmationNoteL( TInt aIndex )
       
   307     {
       
   308     HBufC* prompt = NULL;
       
   309 
       
   310     TInt markedCount( KNoneSelected );
       
   311     if ( iRecordedChatsPC.ValidSelectedItems() )
       
   312         {
       
   313         markedCount = iRecordedChatsPC.SelectedItemsCount();
       
   314         }
       
   315     else
       
   316         {
       
   317         markedCount = KOneSelected; // From recorded chat view
       
   318         }
       
   319 
       
   320     // First confirmation note.
       
   321     if ( markedCount <= KOneSelected )
       
   322         {
       
   323         prompt = StringLoader::LoadLC( R_QTN_CHAT_REC_DELETE,
       
   324                                        iRecordedChatsArrayPC.Name( aIndex ) );
       
   325         }
       
   326     else
       
   327         {
       
   328         prompt = StringLoader::LoadLC( R_QTN_CHAT_REC_DELETE_MANY,
       
   329                                        markedCount );
       
   330         }
       
   331 
       
   332     TInt ret( IMDialogUtils::DisplayQueryDialogL(
       
   333                   R_GENERIC_YES_NO_CONFIRMATION_QUERY,
       
   334                   *prompt ) );
       
   335 
       
   336     CleanupStack::PopAndDestroy( prompt );
       
   337 
       
   338     // return confirmation ok status. True, if ok or yes. false if not.
       
   339     return ( ret == EAknSoftkeyOk || ret == EAknSoftkeyYes );
       
   340     }
       
   341 
       
   342 // -----------------------------------------------------------------------------
       
   343 // CCARecordedChatsArray::PrepareArrayForSendingMtmL
       
   344 // Prepares MTM launch component, if not yet prepared.
       
   345 // -----------------------------------------------------------------------------
       
   346 //
       
   347 void CCARecordedChatsArray::PrepareArrayForSendingMtmL()
       
   348     {
       
   349     iRecordedChatsPC.PrepareArrayForSendingMtmL();
       
   350     }
       
   351 
       
   352 // -----------------------------------------------------------------------------
       
   353 // CCARecordedChatsArray::SetSelectedItems
       
   354 // Initialize or uninitialize selected items. NULL means uninitialization.
       
   355 // -----------------------------------------------------------------------------
       
   356 //
       
   357 void CCARecordedChatsArray::SetSelectedItems( const CArrayFix< TInt >* aArray )
       
   358     {
       
   359     iRecordedChatsPC.SetSelectedItems( aArray );
       
   360     }
       
   361 
       
   362 
       
   363 // -----------------------------------------------------------------------------
       
   364 // CCARecordedChatsArray::DynInitSendMenu
       
   365 // Dim not needed menubars.
       
   366 // -----------------------------------------------------------------------------
       
   367 //
       
   368 void CCARecordedChatsArray::DynInitSendMenuL(
       
   369     CEikMenuPane& /* aMenuPane */
       
   370 )
       
   371     {
       
   372     }
       
   373 
       
   374 // -----------------------------------------------------------------------------
       
   375 // CCARecordedChatsArray::DeleteRecordedChatContainerL
       
   376 // -----------------------------------------------------------------------------
       
   377 //
       
   378 void CCARecordedChatsArray::DeleteRecordedChatContainerL()
       
   379     {
       
   380     iRecordedChatsPC.DeleteRecordedChatContainerL();
       
   381     }
       
   382 
       
   383 // -----------------------------------------------------------------------------
       
   384 // CCARecordedChatsArray::InitDeleteArrayL
       
   385 // Init delete array, so we delete items in right order.
       
   386 // -----------------------------------------------------------------------------
       
   387 //
       
   388 void CCARecordedChatsArray::InitDeleteArrayL()
       
   389     {
       
   390     iRecordedChatsPC.InitDeleteArrayL();
       
   391     }
       
   392 
       
   393 // -----------------------------------------------------------------------------
       
   394 // CCARecordedChatsArray::Index
       
   395 // -----------------------------------------------------------------------------
       
   396 //
       
   397 TInt CCARecordedChatsArray::Index( const TDesC& aName ) const
       
   398     {
       
   399     return iRecordedChatsArrayPC.Index( aName );
       
   400     }
       
   401 
       
   402 
       
   403 //  End of File