calendarui/controller/src/calenviewattachmentsdialog.cpp
author hgs
Wed, 03 Nov 2010 17:12:22 +0530
changeset 89 b57382753122
permissions -rw-r--r--
201045
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
89
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
// ========== INCLUDE FILES ================================
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include <eikspane.h>
hgs
parents:
diff changeset
    21
#include <eikmenup.h>
hgs
parents:
diff changeset
    22
#include <AknDef.h>
hgs
parents:
diff changeset
    23
#include <aknappui.h>
hgs
parents:
diff changeset
    24
#include <akntitle.h>
hgs
parents:
diff changeset
    25
#include <aknnavi.h>
hgs
parents:
diff changeset
    26
#include <aknlists.h>
hgs
parents:
diff changeset
    27
#include <gulicon.h>
hgs
parents:
diff changeset
    28
#include <coeutils.h>               // for ConeUtils::FileExists
hgs
parents:
diff changeset
    29
#include <bautils.h>
hgs
parents:
diff changeset
    30
#include <aknnotewrappers.h>
hgs
parents:
diff changeset
    31
#include <AknWaitDialog.h>          // CAknWaitDialog
hgs
parents:
diff changeset
    32
#include <DocumentHandler.h>
hgs
parents:
diff changeset
    33
#include <StringLoader.h>           // StringLoader
hgs
parents:
diff changeset
    34
#include <AiwCommon.h>
hgs
parents:
diff changeset
    35
#include <NpdApi.h>
hgs
parents:
diff changeset
    36
#include <avkon.hrh>
hgs
parents:
diff changeset
    37
#include <aknlayout.cdl.h>
hgs
parents:
diff changeset
    38
#include <aknlayoutscalable_avkon.cdl.h>
hgs
parents:
diff changeset
    39
#include <AknUtils.h>
hgs
parents:
diff changeset
    40
#include <AknsUtils.h>          // skinned icons
hgs
parents:
diff changeset
    41
#include <AknsConstants.h>      // skinned icon ids
hgs
parents:
diff changeset
    42
#include <barsread.h>
hgs
parents:
diff changeset
    43
#include <calendar.mbg>
hgs
parents:
diff changeset
    44
#include <Calendar.rsg>
hgs
parents:
diff changeset
    45
#include <StringLoader.h>
hgs
parents:
diff changeset
    46
#include <AknsBasicBackgroundControlContext.h>
hgs
parents:
diff changeset
    47
#include <calencommonui.rsg>
hgs
parents:
diff changeset
    48
#include <aknlistloadertfx.h>
hgs
parents:
diff changeset
    49
#include <aknlistboxtfxinternal.h>
hgs
parents:
diff changeset
    50
#include <hlplch.h>
hgs
parents:
diff changeset
    51
#include <csxhelp/mail.hlp.hrh>
hgs
parents:
diff changeset
    52
#include <featmgr.h>
hgs
parents:
diff changeset
    53
#include <sysutil.h>
hgs
parents:
diff changeset
    54
#include <ErrorUI.h>
hgs
parents:
diff changeset
    55
#include <calentoolbar.h>
hgs
parents:
diff changeset
    56
hgs
parents:
diff changeset
    57
#include "calenviewattachmentsdialog.h"
hgs
parents:
diff changeset
    58
#include "calencontroller.h"
hgs
parents:
diff changeset
    59
#include "calenattachmentinfo.h"
hgs
parents:
diff changeset
    60
#include "calenattachmentmodel.h"
hgs
parents:
diff changeset
    61
#include "calenattachmentutils.h"
hgs
parents:
diff changeset
    62
#include "calendarui_debug.h"
hgs
parents:
diff changeset
    63
#include "calendar.hrh"
hgs
parents:
diff changeset
    64
#include "calenmultidbeditor.h"
hgs
parents:
diff changeset
    65
#include "CalendarPrivateCRKeys.h"
hgs
parents:
diff changeset
    66
#include "calendarui_debug.h"
hgs
parents:
diff changeset
    67
#include "calenattachmentutils.h"
hgs
parents:
diff changeset
    68
hgs
parents:
diff changeset
    69
//CONSTANTS
hgs
parents:
diff changeset
    70
hgs
parents:
diff changeset
    71
const TInt KMSKControlID(3);
hgs
parents:
diff changeset
    72
_LIT8( KNotePadTextDataType, "text/plain" );
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
// ========================= MEMBER FUNCTIONS ================================
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    77
// CCalenAttachmentSelectionObserver::NewL
hgs
parents:
diff changeset
    78
// 1st phase of construction
hgs
parents:
diff changeset
    79
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    80
//
hgs
parents:
diff changeset
    81
CCalenViewAttachmentsDialog* CCalenViewAttachmentsDialog::NewL(TDesC& aTitle,
hgs
parents:
diff changeset
    82
                                                                CCalenAttachmentModel& aAttachmentModel,
hgs
parents:
diff changeset
    83
                                                                CCalenController& aController)
hgs
parents:
diff changeset
    84
    {
hgs
parents:
diff changeset
    85
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
    86
    
hgs
parents:
diff changeset
    87
    CCalenViewAttachmentsDialog* self = new (ELeave) CCalenViewAttachmentsDialog(aTitle,
hgs
parents:
diff changeset
    88
                                                                                aAttachmentModel,
hgs
parents:
diff changeset
    89
                                                                                aController);
hgs
parents:
diff changeset
    90
    CleanupStack::PushL(self);
hgs
parents:
diff changeset
    91
    self->ConstructL();
hgs
parents:
diff changeset
    92
    CleanupStack::Pop(self);
hgs
parents:
diff changeset
    93
    
hgs
parents:
diff changeset
    94
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
    95
    return self;
hgs
parents:
diff changeset
    96
    }
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    99
// CCalenViewAttachmentsDialog::CCalenViewAttachmentsDialog
hgs
parents:
diff changeset
   100
// Constructor.
hgs
parents:
diff changeset
   101
// (other items were commented in a header).
hgs
parents:
diff changeset
   102
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   103
//
hgs
parents:
diff changeset
   104
CCalenViewAttachmentsDialog::CCalenViewAttachmentsDialog(TDesC& aTitle,
hgs
parents:
diff changeset
   105
      CCalenAttachmentModel& aAttachmentModel,CCalenController& aController )
hgs
parents:
diff changeset
   106
    : iAttachmentModel( aAttachmentModel ),
hgs
parents:
diff changeset
   107
      iController(aController),
hgs
parents:
diff changeset
   108
      iNewTitle( aTitle ),
hgs
parents:
diff changeset
   109
      iEmbeddedFileOpened(EFalse)  
hgs
parents:
diff changeset
   110
    {
hgs
parents:
diff changeset
   111
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   112
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   113
    }
hgs
parents:
diff changeset
   114
hgs
parents:
diff changeset
   115
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   116
// CCalenViewAttachmentsDialog::~CCalenViewAttachmentsDialog
hgs
parents:
diff changeset
   117
// Destructor.
hgs
parents:
diff changeset
   118
// (other items were commented in a header).
hgs
parents:
diff changeset
   119
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   120
//
hgs
parents:
diff changeset
   121
CCalenViewAttachmentsDialog::~CCalenViewAttachmentsDialog()
hgs
parents:
diff changeset
   122
    {
hgs
parents:
diff changeset
   123
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   124
        
hgs
parents:
diff changeset
   125
    delete iOldTitle;
hgs
parents:
diff changeset
   126
hgs
parents:
diff changeset
   127
    // because it's not possible to set externally owned icon array
hgs
parents:
diff changeset
   128
    // for listbox, we delete our icon array here and set listbox
hgs
parents:
diff changeset
   129
    // icon array to NULL.
hgs
parents:
diff changeset
   130
    delete iIconArray;
hgs
parents:
diff changeset
   131
    if ( iListBox )
hgs
parents:
diff changeset
   132
        {
hgs
parents:
diff changeset
   133
        TRAP_IGNORE( iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( NULL ) );
hgs
parents:
diff changeset
   134
        }
hgs
parents:
diff changeset
   135
hgs
parents:
diff changeset
   136
    delete iListItems;
hgs
parents:
diff changeset
   137
    delete iDocHandler;
hgs
parents:
diff changeset
   138
hgs
parents:
diff changeset
   139
    // remove empty navi pane.
hgs
parents:
diff changeset
   140
    if ( iNaviPane )
hgs
parents:
diff changeset
   141
        {
hgs
parents:
diff changeset
   142
        iNaviPane->Pop();
hgs
parents:
diff changeset
   143
        }
hgs
parents:
diff changeset
   144
    delete iOpenParamList;
hgs
parents:
diff changeset
   145
    
hgs
parents:
diff changeset
   146
    iController.CancelNotifications( this );
hgs
parents:
diff changeset
   147
    
hgs
parents:
diff changeset
   148
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   149
    }
hgs
parents:
diff changeset
   150
hgs
parents:
diff changeset
   151
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   152
// CCalenViewAttachmentsDialog::ConstructL
hgs
parents:
diff changeset
   153
// 2nd phase constructor.
hgs
parents:
diff changeset
   154
// (other items were commented in a header).
hgs
parents:
diff changeset
   155
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   156
//
hgs
parents:
diff changeset
   157
void CCalenViewAttachmentsDialog::ConstructL()
hgs
parents:
diff changeset
   158
    {
hgs
parents:
diff changeset
   159
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   160
    
hgs
parents:
diff changeset
   161
    DoConstructL();
hgs
parents:
diff changeset
   162
    
hgs
parents:
diff changeset
   163
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   164
    }
hgs
parents:
diff changeset
   165
hgs
parents:
diff changeset
   166
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   167
// CCalenViewAttachmentsDialog::DoConstructL
hgs
parents:
diff changeset
   168
// (other items were commented in a header).
hgs
parents:
diff changeset
   169
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   170
//
hgs
parents:
diff changeset
   171
void CCalenViewAttachmentsDialog::DoConstructL()
hgs
parents:
diff changeset
   172
    {
hgs
parents:
diff changeset
   173
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   174
    
hgs
parents:
diff changeset
   175
    CAknDialog::ConstructL( R_CALENDAR_ATTACHMENT_MENUBAR );
hgs
parents:
diff changeset
   176
hgs
parents:
diff changeset
   177
    iDocHandler = CDocumentHandler::NewL( iEikonEnv->Process() );
hgs
parents:
diff changeset
   178
hgs
parents:
diff changeset
   179
    // replace navi pane with empty one.
hgs
parents:
diff changeset
   180
    iNaviPane = static_cast<CAknNavigationControlContainer*>
hgs
parents:
diff changeset
   181
        ( iEikonEnv->AppUiFactory()->StatusPane()->ControlL(
hgs
parents:
diff changeset
   182
            TUid::Uid( EEikStatusPaneUidNavi ) ) );
hgs
parents:
diff changeset
   183
        
hgs
parents:
diff changeset
   184
    // CAknNavigationControlContainer internal array of decorators seem to
hgs
parents:
diff changeset
   185
    // have big enough granularity that it does not need realloc
hgs
parents:
diff changeset
   186
    // and therefore PushDefaultL does not leave.
hgs
parents:
diff changeset
   187
    iNaviPane->PushDefaultL();
hgs
parents:
diff changeset
   188
hgs
parents:
diff changeset
   189
    iDocHandler->SetExitObserver( this );
hgs
parents:
diff changeset
   190
    
hgs
parents:
diff changeset
   191
    iController.RegisterForNotificationsL( this, ECalenNotifyAttachmentAdded );
hgs
parents:
diff changeset
   192
    
hgs
parents:
diff changeset
   193
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   194
    }
hgs
parents:
diff changeset
   195
hgs
parents:
diff changeset
   196
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   197
// CCalenViewAttachmentsDialog::CurrentListItemIndex
hgs
parents:
diff changeset
   198
// returns current item index.
hgs
parents:
diff changeset
   199
// (other items were commented in a header).
hgs
parents:
diff changeset
   200
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   201
//
hgs
parents:
diff changeset
   202
TInt CCalenViewAttachmentsDialog::CurrentListItemIndex()
hgs
parents:
diff changeset
   203
    {
hgs
parents:
diff changeset
   204
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   205
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   206
    return iListBox->CurrentItemIndex();
hgs
parents:
diff changeset
   207
    }
hgs
parents:
diff changeset
   208
hgs
parents:
diff changeset
   209
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   210
// CCalenViewAttachmentsDialog::UpdateIcon
hgs
parents:
diff changeset
   211
// (other items were commented in a header).
hgs
parents:
diff changeset
   212
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   213
//
hgs
parents:
diff changeset
   214
void CCalenViewAttachmentsDialog::UpdateIcon( TInt aListIndex )
hgs
parents:
diff changeset
   215
    {
hgs
parents:
diff changeset
   216
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   217
    
hgs
parents:
diff changeset
   218
    iListBox->DrawItem( aListIndex );
hgs
parents:
diff changeset
   219
    
hgs
parents:
diff changeset
   220
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   221
    }
hgs
parents:
diff changeset
   222
hgs
parents:
diff changeset
   223
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   224
// CCalenViewAttachmentsDialog::ProcessCommandL
hgs
parents:
diff changeset
   225
// (other items were commented in a header).
hgs
parents:
diff changeset
   226
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   227
//
hgs
parents:
diff changeset
   228
void CCalenViewAttachmentsDialog::ProcessCommandL( TInt aCommandId )
hgs
parents:
diff changeset
   229
    {
hgs
parents:
diff changeset
   230
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   231
    
hgs
parents:
diff changeset
   232
    HideMenu();
hgs
parents:
diff changeset
   233
hgs
parents:
diff changeset
   234
    TFileName filename;
hgs
parents:
diff changeset
   235
    TInt index = iListBox->CurrentItemIndex();
hgs
parents:
diff changeset
   236
hgs
parents:
diff changeset
   237
    switch ( aCommandId )
hgs
parents:
diff changeset
   238
        {
hgs
parents:
diff changeset
   239
        case ECalenViewAttachmentCmdOpen:
hgs
parents:
diff changeset
   240
            {
hgs
parents:
diff changeset
   241
          	 if ( CheckSpaceBelowCriticalLevelL() )
hgs
parents:
diff changeset
   242
			        {    
hgs
parents:
diff changeset
   243
			        TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   244
			        
hgs
parents:
diff changeset
   245
			        return;
hgs
parents:
diff changeset
   246
			        }
hgs
parents:
diff changeset
   247
            else if(index!=KErrNotFound)
hgs
parents:
diff changeset
   248
                {
hgs
parents:
diff changeset
   249
                //get the attachmentinfo for the current index
hgs
parents:
diff changeset
   250
                CCalenAttachmentInfo& attInfo =
hgs
parents:
diff changeset
   251
                    iAttachmentModel.AttachmentInfoAt( index );
hgs
parents:
diff changeset
   252
hgs
parents:
diff changeset
   253
                TDataType datatype( attInfo.DataType() );
hgs
parents:
diff changeset
   254
                RFile file = iAttachmentModel.GetAttachmentFileL( index );
hgs
parents:
diff changeset
   255
                CleanupClosePushL(file);
hgs
parents:
diff changeset
   256
                OpenAttachmentViewerL(file, *this);
hgs
parents:
diff changeset
   257
                CleanupStack::PopAndDestroy(&file);
hgs
parents:
diff changeset
   258
                }                                
hgs
parents:
diff changeset
   259
            }
hgs
parents:
diff changeset
   260
        break;
hgs
parents:
diff changeset
   261
      
hgs
parents:
diff changeset
   262
        case ECalenViewAttachmentCmdSave:
hgs
parents:
diff changeset
   263
            {
hgs
parents:
diff changeset
   264
            if ( CheckSpaceBelowCriticalLevelL() )
hgs
parents:
diff changeset
   265
               {    
hgs
parents:
diff changeset
   266
               TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   267
               return;
hgs
parents:
diff changeset
   268
               }
hgs
parents:
diff changeset
   269
            //get the attachmentinfo for the current index
hgs
parents:
diff changeset
   270
            CCalenAttachmentInfo& attInfo =
hgs
parents:
diff changeset
   271
            iAttachmentModel.AttachmentInfoAt( index );
hgs
parents:
diff changeset
   272
            
hgs
parents:
diff changeset
   273
            TDataType datatype( attInfo.DataType() );
hgs
parents:
diff changeset
   274
            RFile file = iAttachmentModel.GetAttachmentFileL( index );
hgs
parents:
diff changeset
   275
            CleanupClosePushL(file);
hgs
parents:
diff changeset
   276
            CCalenAttachmentUtils::SaveAttachmentL(file, *this);
hgs
parents:
diff changeset
   277
            CleanupStack::PopAndDestroy(&file);
hgs
parents:
diff changeset
   278
            }
hgs
parents:
diff changeset
   279
            break;
hgs
parents:
diff changeset
   280
      
hgs
parents:
diff changeset
   281
        case ECalenViewAttachmentCmdRemove:
hgs
parents:
diff changeset
   282
            {
hgs
parents:
diff changeset
   283
            if ( index != KErrNotFound )
hgs
parents:
diff changeset
   284
                {          
hgs
parents:
diff changeset
   285
                //modify the model
hgs
parents:
diff changeset
   286
                if(RemoveAttachmentL(index))
hgs
parents:
diff changeset
   287
                    {
hgs
parents:
diff changeset
   288
                    //update the ui
hgs
parents:
diff changeset
   289
                    ItemRemovedL( index );
hgs
parents:
diff changeset
   290
                    }
hgs
parents:
diff changeset
   291
                }
hgs
parents:
diff changeset
   292
            break;
hgs
parents:
diff changeset
   293
            }
hgs
parents:
diff changeset
   294
        case ECalenViewAttachmentAdd:
hgs
parents:
diff changeset
   295
            {
hgs
parents:
diff changeset
   296
            //issue this command and it will be handled by attachmentui. 
hgs
parents:
diff changeset
   297
            iController.Services().IssueCommandL(ECalenAddAttachmentFromViewer);
hgs
parents:
diff changeset
   298
            
hgs
parents:
diff changeset
   299
            }
hgs
parents:
diff changeset
   300
            break;
hgs
parents:
diff changeset
   301
        case ECalenViewerCmdAttachmentCmdExit:
hgs
parents:
diff changeset
   302
            TryExitL(EAknSoftkeyOk);
hgs
parents:
diff changeset
   303
            break;
hgs
parents:
diff changeset
   304
        case EAknCmdHelp:
hgs
parents:
diff changeset
   305
            // Launch help
hgs
parents:
diff changeset
   306
            HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
hgs
parents:
diff changeset
   307
                iEikonEnv->EikAppUi()->AppHelpContextL() );
hgs
parents:
diff changeset
   308
            break;
hgs
parents:
diff changeset
   309
        case EAknCmdExit:
hgs
parents:
diff changeset
   310
        case EEikCmdExit:
hgs
parents:
diff changeset
   311
            {
hgs
parents:
diff changeset
   312
            static_cast<MEikCommandObserver*>( iEikonEnv->EikAppUi() )
hgs
parents:
diff changeset
   313
                ->ProcessCommandL( EAknSoftkeyExit );
hgs
parents:
diff changeset
   314
            break;
hgs
parents:
diff changeset
   315
            }
hgs
parents:
diff changeset
   316
        default:
hgs
parents:
diff changeset
   317
            {
hgs
parents:
diff changeset
   318
            break;
hgs
parents:
diff changeset
   319
            }
hgs
parents:
diff changeset
   320
        }
hgs
parents:
diff changeset
   321
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   322
    }
hgs
parents:
diff changeset
   323
hgs
parents:
diff changeset
   324
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   325
// CCalenViewAttachmentsDialog::DynInitMenuPaneL
hgs
parents:
diff changeset
   326
// (other items were commented in a header).
hgs
parents:
diff changeset
   327
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   328
//
hgs
parents:
diff changeset
   329
void CCalenViewAttachmentsDialog::DynInitMenuPaneL(
hgs
parents:
diff changeset
   330
    TInt aMenuId, CEikMenuPane* aMenuPane )
hgs
parents:
diff changeset
   331
    {
hgs
parents:
diff changeset
   332
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   333
    
hgs
parents:
diff changeset
   334
    switch(aMenuId)
hgs
parents:
diff changeset
   335
          {
hgs
parents:
diff changeset
   336
          case R_CALENDAR_ATTACHMENT_MENUPANE:
hgs
parents:
diff changeset
   337
              {
hgs
parents:
diff changeset
   338
              if(!(iAttachmentModel.NumberOfItems()))                  
hgs
parents:
diff changeset
   339
                  {                  
hgs
parents:
diff changeset
   340
                  //remove the options open and remove if count is 0.
hgs
parents:
diff changeset
   341
                  
hgs
parents:
diff changeset
   342
                  aMenuPane->SetItemDimmed(ECalenViewAttachmentCmdOpen,ETrue);
hgs
parents:
diff changeset
   343
                  aMenuPane->SetItemDimmed(ECalenViewAttachmentCmdSave,ETrue);
hgs
parents:
diff changeset
   344
                  aMenuPane->SetItemDimmed(ECalenViewAttachmentCmdRemove,ETrue);
hgs
parents:
diff changeset
   345
                  }  
hgs
parents:
diff changeset
   346
              else
hgs
parents:
diff changeset
   347
                  {
hgs
parents:
diff changeset
   348
                  aMenuPane->SetItemDimmed(ECalenViewAttachmentCmdOpen,EFalse);
hgs
parents:
diff changeset
   349
				  aMenuPane->SetItemDimmed(ECalenViewAttachmentCmdSave,EFalse);
hgs
parents:
diff changeset
   350
                  aMenuPane->SetItemDimmed(ECalenViewAttachmentCmdRemove,EFalse);
hgs
parents:
diff changeset
   351
                  }
hgs
parents:
diff changeset
   352
               }
hgs
parents:
diff changeset
   353
            break;  
hgs
parents:
diff changeset
   354
          default:
hgs
parents:
diff changeset
   355
           break;  
hgs
parents:
diff changeset
   356
            }
hgs
parents:
diff changeset
   357
  
hgs
parents:
diff changeset
   358
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   359
    }
hgs
parents:
diff changeset
   360
hgs
parents:
diff changeset
   361
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   362
// CCalenViewAttachmentsDialog::HandleResourceChangeL
hgs
parents:
diff changeset
   363
// (other items were commented in a header).
hgs
parents:
diff changeset
   364
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   365
//
hgs
parents:
diff changeset
   366
void CCalenViewAttachmentsDialog::HandleResourceChange(TInt aType)
hgs
parents:
diff changeset
   367
    {
hgs
parents:
diff changeset
   368
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   369
    
hgs
parents:
diff changeset
   370
    if ( aType == KEikDynamicLayoutVariantSwitch ||
hgs
parents:
diff changeset
   371
        aType == KAknsMessageSkinChange )
hgs
parents:
diff changeset
   372
        {
hgs
parents:
diff changeset
   373
        TRAP_IGNORE( iAttachmentModel.LoadResourcesL() );
hgs
parents:
diff changeset
   374
        }    
hgs
parents:
diff changeset
   375
    CEikDialog::HandleResourceChange( aType );
hgs
parents:
diff changeset
   376
    
hgs
parents:
diff changeset
   377
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   378
    }
hgs
parents:
diff changeset
   379
hgs
parents:
diff changeset
   380
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   381
// CCalenViewAttachmentsDialog::HandleServerAppExit
hgs
parents:
diff changeset
   382
// (other items were commented in a header).
hgs
parents:
diff changeset
   383
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   384
//
hgs
parents:
diff changeset
   385
void CCalenViewAttachmentsDialog::HandleServerAppExit( TInt aReason)
hgs
parents:
diff changeset
   386
    {
hgs
parents:
diff changeset
   387
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   388
    
hgs
parents:
diff changeset
   389
    iEmbeddedFileOpened = EFalse;
hgs
parents:
diff changeset
   390
    if (aReason == EAknCmdExit)
hgs
parents:
diff changeset
   391
        {
hgs
parents:
diff changeset
   392
        //issue this notification, which will be handled by attachmentui.
hgs
parents:
diff changeset
   393
        iController.BroadcastNotification(ECalenNotifyAttachmentViewerClosed);
hgs
parents:
diff changeset
   394
        }
hgs
parents:
diff changeset
   395
    
hgs
parents:
diff changeset
   396
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   397
    }
hgs
parents:
diff changeset
   398
hgs
parents:
diff changeset
   399
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   400
// CCalenViewAttachmentsDialog::HandleControlStateChangeL
hgs
parents:
diff changeset
   401
// (other items were commented in a header).
hgs
parents:
diff changeset
   402
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   403
//
hgs
parents:
diff changeset
   404
void CCalenViewAttachmentsDialog::HandleControlStateChangeL( TInt aControlId )
hgs
parents:
diff changeset
   405
    {
hgs
parents:
diff changeset
   406
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   407
    
hgs
parents:
diff changeset
   408
    if ( aControlId == ECalenAttachmentListBoxId )
hgs
parents:
diff changeset
   409
        {
hgs
parents:
diff changeset
   410
        DoUpdateUiL();
hgs
parents:
diff changeset
   411
        }
hgs
parents:
diff changeset
   412
        
hgs
parents:
diff changeset
   413
    CAknDialog::HandleControlStateChangeL( aControlId );
hgs
parents:
diff changeset
   414
    
hgs
parents:
diff changeset
   415
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   416
    }
hgs
parents:
diff changeset
   417
hgs
parents:
diff changeset
   418
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   419
// CCalenViewAttachmentsDialog::OkToExitL
hgs
parents:
diff changeset
   420
// (other items were commented in a header).
hgs
parents:
diff changeset
   421
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   422
//
hgs
parents:
diff changeset
   423
TBool CCalenViewAttachmentsDialog::HandleOkToExitL( TInt aButtonId )
hgs
parents:
diff changeset
   424
    {
hgs
parents:
diff changeset
   425
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   426
    
hgs
parents:
diff changeset
   427
hgs
parents:
diff changeset
   428
    if ( aButtonId == EAknSoftkeyBack )
hgs
parents:
diff changeset
   429
        {
hgs
parents:
diff changeset
   430
        iTitlePane->SetTextL( *iOldTitle );
hgs
parents:
diff changeset
   431
        
hgs
parents:
diff changeset
   432
        //issue this notification, which will be handled by attachmentui.
hgs
parents:
diff changeset
   433
        iController.BroadcastNotification(ECalenNotifyAttachmentViewerClosed);
hgs
parents:
diff changeset
   434
        }
hgs
parents:
diff changeset
   435
    else if ( aButtonId == EAknSoftkeyOpen )
hgs
parents:
diff changeset
   436
        {
hgs
parents:
diff changeset
   437
        if(iAttachmentModel.NumberOfItems()!= 0)
hgs
parents:
diff changeset
   438
                {
hgs
parents:
diff changeset
   439
                //open the attachment if user taps on the item.
hgs
parents:
diff changeset
   440
                ProcessCommandL( ECalenViewAttachmentCmdOpen );
hgs
parents:
diff changeset
   441
                }
hgs
parents:
diff changeset
   442
        TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   443
        
hgs
parents:
diff changeset
   444
        return EFalse;
hgs
parents:
diff changeset
   445
        }
hgs
parents:
diff changeset
   446
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   447
    
hgs
parents:
diff changeset
   448
    return CAknDialog::OkToExitL( aButtonId );
hgs
parents:
diff changeset
   449
    }
hgs
parents:
diff changeset
   450
hgs
parents:
diff changeset
   451
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   452
// CCalenViewAttachmentsDialog::CreateCustomControlL
hgs
parents:
diff changeset
   453
// (other items were commented in a header).
hgs
parents:
diff changeset
   454
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   455
//
hgs
parents:
diff changeset
   456
SEikControlInfo CCalenViewAttachmentsDialog::CreateCustomControlL( TInt aControlType )
hgs
parents:
diff changeset
   457
    {
hgs
parents:
diff changeset
   458
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   459
    
hgs
parents:
diff changeset
   460
    SEikControlInfo controlInfo;
hgs
parents:
diff changeset
   461
    controlInfo.iControl = NULL;
hgs
parents:
diff changeset
   462
    controlInfo.iTrailerTextId = 0;
hgs
parents:
diff changeset
   463
    controlInfo.iFlags = 0;
hgs
parents:
diff changeset
   464
hgs
parents:
diff changeset
   465
    if ( aControlType == ECalenAttachmentListBox )
hgs
parents:
diff changeset
   466
        {
hgs
parents:
diff changeset
   467
        //create the attachment listbox to list all the attachments
hgs
parents:
diff changeset
   468
        controlInfo.iControl = new ( ELeave ) CCalenAttachmentsListBox( iAttachmentModel );
hgs
parents:
diff changeset
   469
        }
hgs
parents:
diff changeset
   470
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   471
    
hgs
parents:
diff changeset
   472
    return controlInfo;
hgs
parents:
diff changeset
   473
    }
hgs
parents:
diff changeset
   474
hgs
parents:
diff changeset
   475
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   476
// CCalenViewAttachmentsDialog::HandleListBoxEventL
hgs
parents:
diff changeset
   477
// (other items were commented in a header).
hgs
parents:
diff changeset
   478
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   479
//
hgs
parents:
diff changeset
   480
#ifdef RD_SCALABLE_UI_V2
hgs
parents:
diff changeset
   481
void CCalenViewAttachmentsDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/, 
hgs
parents:
diff changeset
   482
                                                              TListBoxEvent aEventType )
hgs
parents:
diff changeset
   483
    {
hgs
parents:
diff changeset
   484
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   485
 
hgs
parents:
diff changeset
   486
    if ( !MenuShowing() )
hgs
parents:
diff changeset
   487
       {
hgs
parents:
diff changeset
   488
	    //Single click integration
hgs
parents:
diff changeset
   489
       if ( aEventType == EEventEnterKeyPressed ||
hgs
parents:
diff changeset
   490
            
hgs
parents:
diff changeset
   491
            aEventType == EEventItemSingleClicked )
hgs
parents:
diff changeset
   492
           {
hgs
parents:
diff changeset
   493
           const TInt index(CurrentListItemIndex());
hgs
parents:
diff changeset
   494
           if ( index != KErrNotFound )
hgs
parents:
diff changeset
   495
               {
hgs
parents:
diff changeset
   496
               UpdateMiddleSoftKeyL( index );
hgs
parents:
diff changeset
   497
               OpenAttachmentL();
hgs
parents:
diff changeset
   498
               }
hgs
parents:
diff changeset
   499
           }
hgs
parents:
diff changeset
   500
       }
hgs
parents:
diff changeset
   501
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   502
    }
hgs
parents:
diff changeset
   503
#else
hgs
parents:
diff changeset
   504
void CCalenViewAttachmentsDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/, 
hgs
parents:
diff changeset
   505
                                                              TListBoxEvent /*aEventType*/ )
hgs
parents:
diff changeset
   506
    {
hgs
parents:
diff changeset
   507
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   508
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   509
    }
hgs
parents:
diff changeset
   510
#endif // RD_SCALABLE_UI_V2
hgs
parents:
diff changeset
   511
hgs
parents:
diff changeset
   512
hgs
parents:
diff changeset
   513
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   514
// CCalenViewAttachmentsDialog::PreLayoutDynInitL
hgs
parents:
diff changeset
   515
// (other items were commented in a header).
hgs
parents:
diff changeset
   516
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   517
//
hgs
parents:
diff changeset
   518
void CCalenViewAttachmentsDialog::PreLayoutDynInitL()
hgs
parents:
diff changeset
   519
    {
hgs
parents:
diff changeset
   520
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   521
    
hgs
parents:
diff changeset
   522
    CEikStatusPane *sp = static_cast<CAknAppUi*>
hgs
parents:
diff changeset
   523
        ( iEikonEnv->EikAppUi() )->StatusPane();
hgs
parents:
diff changeset
   524
        
hgs
parents:
diff changeset
   525
    iTitlePane = static_cast<CAknTitlePane*>
hgs
parents:
diff changeset
   526
        ( sp->ControlL( TUid::Uid(EEikStatusPaneUidTitle ) ) );
hgs
parents:
diff changeset
   527
hgs
parents:
diff changeset
   528
    const TDesC* title = iTitlePane->Text();
hgs
parents:
diff changeset
   529
    iOldTitle = title->AllocL();
hgs
parents:
diff changeset
   530
hgs
parents:
diff changeset
   531
    iTitlePane->SetTextL( iNewTitle );
hgs
parents:
diff changeset
   532
hgs
parents:
diff changeset
   533
    iListBox = static_cast<CCalenAttachmentsListBox*>
hgs
parents:
diff changeset
   534
        ( Control( ECalenAttachmentListBoxId ) );
hgs
parents:
diff changeset
   535
hgs
parents:
diff changeset
   536
    iListBox->SetContainerWindowL( *this);    
hgs
parents:
diff changeset
   537
    iListBox->CreateScrollBarFrameL( ETrue );
hgs
parents:
diff changeset
   538
   
hgs
parents:
diff changeset
   539
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
hgs
parents:
diff changeset
   540
        CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
hgs
parents:
diff changeset
   541
    
hgs
parents:
diff changeset
   542
    iListBox->SetListBoxObserver( this );
hgs
parents:
diff changeset
   543
    
hgs
parents:
diff changeset
   544
    LoadFormDataL();
hgs
parents:
diff changeset
   545
    
hgs
parents:
diff changeset
   546
    if(iAttachmentModel.NumberOfItems() == 0)
hgs
parents:
diff changeset
   547
        {    
hgs
parents:
diff changeset
   548
		UpdateButtonVisiblity( ECalenViewAttachmentCmdOpen, EFalse );
hgs
parents:
diff changeset
   549
        }
hgs
parents:
diff changeset
   550
    
hgs
parents:
diff changeset
   551
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   552
    }
hgs
parents:
diff changeset
   553
hgs
parents:
diff changeset
   554
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   555
// CCalenViewAttachmentsDialog::LoadFormDataL
hgs
parents:
diff changeset
   556
// (other items were commented in a header).
hgs
parents:
diff changeset
   557
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   558
//
hgs
parents:
diff changeset
   559
void CCalenViewAttachmentsDialog::LoadFormDataL()
hgs
parents:
diff changeset
   560
    {
hgs
parents:
diff changeset
   561
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   562
    
hgs
parents:
diff changeset
   563
    // iconarray for two icons.
hgs
parents:
diff changeset
   564
    // index 0: application icon.
hgs
parents:
diff changeset
   565
    // index 1: indicator.
hgs
parents:
diff changeset
   566
    iIconArray = new ( ELeave ) CArrayPtrFlat<CGulIcon>( 2 );
hgs
parents:
diff changeset
   567
hgs
parents:
diff changeset
   568
    iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( iIconArray );
hgs
parents:
diff changeset
   569
hgs
parents:
diff changeset
   570
    // list items is not actually an array but object that returns
hgs
parents:
diff changeset
   571
    // list item text for listbox in MdcaPoint method.
hgs
parents:
diff changeset
   572
    iListItems = CCalenAttaListItemArray::NewL( iAttachmentModel, iIconArray );
hgs
parents:
diff changeset
   573
    iListBox->Model()->SetItemTextArray( iListItems );
hgs
parents:
diff changeset
   574
    iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
hgs
parents:
diff changeset
   575
    }
hgs
parents:
diff changeset
   576
hgs
parents:
diff changeset
   577
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   578
// CCalenViewAttachmentsDialog::ItemAddedL
hgs
parents:
diff changeset
   579
// (other items were commented in a header).
hgs
parents:
diff changeset
   580
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   581
void CCalenViewAttachmentsDialog::ItemAddedL( TInt aIndex )
hgs
parents:
diff changeset
   582
    {
hgs
parents:
diff changeset
   583
    iTitlePane->SetTextL( iNewTitle );
hgs
parents:
diff changeset
   584
    iListBox->View()->CalcBottomItemIndex();
hgs
parents:
diff changeset
   585
    
hgs
parents:
diff changeset
   586
    TInt itemIndex = aIndex;
hgs
parents:
diff changeset
   587
    
hgs
parents:
diff changeset
   588
    if ( aIndex == -1 )
hgs
parents:
diff changeset
   589
        {
hgs
parents:
diff changeset
   590
        itemIndex = Max( iListBox->Model()->NumberOfItems() - 1, 0 );
hgs
parents:
diff changeset
   591
        }
hgs
parents:
diff changeset
   592
    
hgs
parents:
diff changeset
   593
    iListBox->SetCurrentItemIndexAndDraw(itemIndex);
hgs
parents:
diff changeset
   594
    
hgs
parents:
diff changeset
   595
    if ( !ButtonGroupContainer().IsCommandVisible( EAknSoftkeyOpen ) )
hgs
parents:
diff changeset
   596
        {
hgs
parents:
diff changeset
   597
        // Set middle button visible if invisible and inserted attachment
hgs
parents:
diff changeset
   598
        // has content (i.e. it is not empty)        
hgs
parents:
diff changeset
   599
		UpdateButtonVisiblity( ECalenViewAttachmentCmdOpen, ETrue );
hgs
parents:
diff changeset
   600
        }
hgs
parents:
diff changeset
   601
    
hgs
parents:
diff changeset
   602
    iListBox->HandleItemAdditionL();
hgs
parents:
diff changeset
   603
    iListBox->DrawNow();
hgs
parents:
diff changeset
   604
hgs
parents:
diff changeset
   605
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   606
    }
hgs
parents:
diff changeset
   607
hgs
parents:
diff changeset
   608
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   609
// CCalenViewAttachmentsDialog::ItemRemovedL
hgs
parents:
diff changeset
   610
// (other items were commented in a header).
hgs
parents:
diff changeset
   611
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   612
void CCalenViewAttachmentsDialog::ItemRemovedL( TInt aIndex )
hgs
parents:
diff changeset
   613
    {
hgs
parents:
diff changeset
   614
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   615
    
hgs
parents:
diff changeset
   616
    iTitlePane->SetTextL( iNewTitle );
hgs
parents:
diff changeset
   617
    iListBox->HandleItemRemovalL();
hgs
parents:
diff changeset
   618
    TInt lastItem = Max( iListBox->Model()->NumberOfItems() - 1, 0 );
hgs
parents:
diff changeset
   619
hgs
parents:
diff changeset
   620
    if ( aIndex - 1 == lastItem )
hgs
parents:
diff changeset
   621
        {
hgs
parents:
diff changeset
   622
        TInt numItems = iListBox->View()->NumberOfItemsThatFitInRect(
hgs
parents:
diff changeset
   623
            iListBox->View()->ViewRect() );
hgs
parents:
diff changeset
   624
        TInt topItem  = Max( lastItem - numItems, 0 );
hgs
parents:
diff changeset
   625
        iListBox->SetTopItemIndex( topItem );
hgs
parents:
diff changeset
   626
        }
hgs
parents:
diff changeset
   627
hgs
parents:
diff changeset
   628
    iListBox->SetCurrentItemIndex( Min( aIndex, lastItem ) );    
hgs
parents:
diff changeset
   629
    iListBox->DrawNow();    
hgs
parents:
diff changeset
   630
    
hgs
parents:
diff changeset
   631
    if ( iAttachmentModel.NumberOfItems() == 0 )
hgs
parents:
diff changeset
   632
        {        
hgs
parents:
diff changeset
   633
        UpdateButtonVisiblity( ECalenViewAttachmentCmdOpen, EFalse ); 
hgs
parents:
diff changeset
   634
        }
hgs
parents:
diff changeset
   635
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   636
    }
hgs
parents:
diff changeset
   637
hgs
parents:
diff changeset
   638
hgs
parents:
diff changeset
   639
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   640
// CCalenViewAttachmentsDialog::RemoveAttachmentL
hgs
parents:
diff changeset
   641
// (other items were commented in a header).
hgs
parents:
diff changeset
   642
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   643
//
hgs
parents:
diff changeset
   644
TBool CCalenViewAttachmentsDialog::RemoveAttachmentL( TInt aIndex )
hgs
parents:
diff changeset
   645
    {
hgs
parents:
diff changeset
   646
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   647
    
hgs
parents:
diff changeset
   648
    TBool attachmentDeleted(EFalse);
hgs
parents:
diff changeset
   649
    // delete item from attachment model (notifies its observer about deletion).
hgs
parents:
diff changeset
   650
    attachmentDeleted = iAttachmentModel.DeleteAttachment( aIndex );
hgs
parents:
diff changeset
   651
    
hgs
parents:
diff changeset
   652
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   653
    return attachmentDeleted;
hgs
parents:
diff changeset
   654
    }
hgs
parents:
diff changeset
   655
hgs
parents:
diff changeset
   656
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   657
// CCalenViewAttachmentsDialog::CleanupWaitDialog
hgs
parents:
diff changeset
   658
// (other items were commented in a header).
hgs
parents:
diff changeset
   659
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   660
//
hgs
parents:
diff changeset
   661
void CCalenViewAttachmentsDialog::CleanupWaitDialog( TAny* aAny )
hgs
parents:
diff changeset
   662
    {
hgs
parents:
diff changeset
   663
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   664
    
hgs
parents:
diff changeset
   665
    //not used as of now, but we can use when attaching is in progress 
hgs
parents:
diff changeset
   666
    CAknWaitDialog** dialog = (CAknWaitDialog**) aAny;
hgs
parents:
diff changeset
   667
    if ( dialog && *dialog )
hgs
parents:
diff changeset
   668
        {
hgs
parents:
diff changeset
   669
        delete *dialog;
hgs
parents:
diff changeset
   670
        }
hgs
parents:
diff changeset
   671
    
hgs
parents:
diff changeset
   672
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   673
    }
hgs
parents:
diff changeset
   674
hgs
parents:
diff changeset
   675
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   676
// CCalenViewAttachmentsDialog::DoUpdateUiL
hgs
parents:
diff changeset
   677
// (other items were commented in a header).
hgs
parents:
diff changeset
   678
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   679
//
hgs
parents:
diff changeset
   680
void CCalenViewAttachmentsDialog::DoUpdateUiL()
hgs
parents:
diff changeset
   681
    {
hgs
parents:
diff changeset
   682
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   683
    
hgs
parents:
diff changeset
   684
    if ( iAttachmentModel.NumberOfItems() == 0 )
hgs
parents:
diff changeset
   685
        {        
hgs
parents:
diff changeset
   686
		UpdateButtonVisiblity( ECalenViewAttachmentCmdOpen, EFalse );
hgs
parents:
diff changeset
   687
        }
hgs
parents:
diff changeset
   688
    else
hgs
parents:
diff changeset
   689
        {        
hgs
parents:
diff changeset
   690
		UpdateButtonVisiblity( ECalenViewAttachmentCmdOpen, ETrue );
hgs
parents:
diff changeset
   691
        }
hgs
parents:
diff changeset
   692
    
hgs
parents:
diff changeset
   693
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   694
    }
hgs
parents:
diff changeset
   695
hgs
parents:
diff changeset
   696
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   697
// CCalenViewAttachmentsDialog::UpdateButtonVisiblity
hgs
parents:
diff changeset
   698
// (other items were commented in a header).
hgs
parents:
diff changeset
   699
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   700
//
hgs
parents:
diff changeset
   701
void CCalenViewAttachmentsDialog::UpdateButtonVisiblity( TInt aCommandId, TBool aValue )
hgs
parents:
diff changeset
   702
    {
hgs
parents:
diff changeset
   703
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   704
    
hgs
parents:
diff changeset
   705
    if ( ButtonGroupContainer().ControlOrNull( aCommandId ) )
hgs
parents:
diff changeset
   706
        {
hgs
parents:
diff changeset
   707
        ButtonGroupContainer().MakeCommandVisible( aCommandId, aValue );
hgs
parents:
diff changeset
   708
        }
hgs
parents:
diff changeset
   709
    
hgs
parents:
diff changeset
   710
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   711
    }
hgs
parents:
diff changeset
   712
hgs
parents:
diff changeset
   713
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   714
// CCalenViewAttachmentsDialog::HandleNotification
hgs
parents:
diff changeset
   715
// Calls back when notifications that it has been registered for are broadcast
hgs
parents:
diff changeset
   716
// (other items were commented in a header).
hgs
parents:
diff changeset
   717
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   718
//
hgs
parents:
diff changeset
   719
void CCalenViewAttachmentsDialog::HandleNotification(const TCalenNotification aNotification )
hgs
parents:
diff changeset
   720
    {
hgs
parents:
diff changeset
   721
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   722
    
hgs
parents:
diff changeset
   723
    PIM_TRAPD_HANDLE( HandleNotificationL( aNotification ) );
hgs
parents:
diff changeset
   724
  
hgs
parents:
diff changeset
   725
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   726
    }
hgs
parents:
diff changeset
   727
hgs
parents:
diff changeset
   728
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   729
// CCalenViewAttachmentsDialog::HandleNotificationL
hgs
parents:
diff changeset
   730
// Called from HandleNotification() when notifications that it has been
hgs
parents:
diff changeset
   731
//  registered for are broadcast
hgs
parents:
diff changeset
   732
// (other items were commented in a header).
hgs
parents:
diff changeset
   733
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   734
//
hgs
parents:
diff changeset
   735
void CCalenViewAttachmentsDialog::HandleNotificationL( TCalenNotification aNotification )
hgs
parents:
diff changeset
   736
    {
hgs
parents:
diff changeset
   737
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   738
    
hgs
parents:
diff changeset
   739
    switch( aNotification )
hgs
parents:
diff changeset
   740
        {
hgs
parents:
diff changeset
   741
        case ECalenNotifyAttachmentAdded:
hgs
parents:
diff changeset
   742
            {
hgs
parents:
diff changeset
   743
            TInt currentItemIndex = iAttachmentModel.NumberOfItems()-1;
hgs
parents:
diff changeset
   744
            ItemAddedL(currentItemIndex);
hgs
parents:
diff changeset
   745
            }
hgs
parents:
diff changeset
   746
            break;
hgs
parents:
diff changeset
   747
        default:
hgs
parents:
diff changeset
   748
            break; 
hgs
parents:
diff changeset
   749
        }
hgs
parents:
diff changeset
   750
hgs
parents:
diff changeset
   751
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   752
    }
hgs
parents:
diff changeset
   753
hgs
parents:
diff changeset
   754
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   755
// CCalenViewAttachmentsDialog::CountComponentControls
hgs
parents:
diff changeset
   756
// Gets the number of controls contained in a compound control.
hgs
parents:
diff changeset
   757
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   758
//
hgs
parents:
diff changeset
   759
TInt CCalenViewAttachmentsDialog::CountComponentControls() const
hgs
parents:
diff changeset
   760
    {
hgs
parents:
diff changeset
   761
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   762
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   763
hgs
parents:
diff changeset
   764
    return 1;
hgs
parents:
diff changeset
   765
    }
hgs
parents:
diff changeset
   766
hgs
parents:
diff changeset
   767
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   768
// CCalenViewAttachmentsDialog::ComponentControl
hgs
parents:
diff changeset
   769
// Gets the specified component of a compound control.
hgs
parents:
diff changeset
   770
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   771
//
hgs
parents:
diff changeset
   772
CCoeControl* CCalenViewAttachmentsDialog::ComponentControl(TInt aIndex) const
hgs
parents:
diff changeset
   773
    {
hgs
parents:
diff changeset
   774
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   775
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   776
    switch (aIndex)
hgs
parents:
diff changeset
   777
        {
hgs
parents:
diff changeset
   778
        case 0:
hgs
parents:
diff changeset
   779
            return iListBox;
hgs
parents:
diff changeset
   780
        default:
hgs
parents:
diff changeset
   781
            return NULL;
hgs
parents:
diff changeset
   782
        }
hgs
parents:
diff changeset
   783
    }
hgs
parents:
diff changeset
   784
hgs
parents:
diff changeset
   785
hgs
parents:
diff changeset
   786
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   787
// CCalenViewAttachmentsDialog::HandlePointerEventL
hgs
parents:
diff changeset
   788
// Process pointer event.
hgs
parents:
diff changeset
   789
// (other items were commented in a header).
hgs
parents:
diff changeset
   790
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   791
//
hgs
parents:
diff changeset
   792
void CCalenViewAttachmentsDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent)
hgs
parents:
diff changeset
   793
    {
hgs
parents:
diff changeset
   794
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   795
     //Single click integration
hgs
parents:
diff changeset
   796
    if ( iListBox && !iEmbeddedFileOpened)
hgs
parents:
diff changeset
   797
        {
hgs
parents:
diff changeset
   798
        iListBox->HandlePointerEventL( aPointerEvent );
hgs
parents:
diff changeset
   799
        }
hgs
parents:
diff changeset
   800
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   801
    } 
hgs
parents:
diff changeset
   802
hgs
parents:
diff changeset
   803
hgs
parents:
diff changeset
   804
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   805
// CCalenViewAttachmentsDialog::NotifySizeChanged
hgs
parents:
diff changeset
   806
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   807
//
hgs
parents:
diff changeset
   808
void CCalenViewAttachmentsDialog::NotifySizeChanged()
hgs
parents:
diff changeset
   809
    {    
hgs
parents:
diff changeset
   810
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   811
    
hgs
parents:
diff changeset
   812
    if(iListBox)
hgs
parents:
diff changeset
   813
        {
hgs
parents:
diff changeset
   814
        iListBox->SizeChanged();
hgs
parents:
diff changeset
   815
        }    
hgs
parents:
diff changeset
   816
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   817
    }
hgs
parents:
diff changeset
   818
hgs
parents:
diff changeset
   819
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   820
// CCalenViewAttachmentsDialog::UpdateAttachmentsFetchFlags
hgs
parents:
diff changeset
   821
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   822
//
hgs
parents:
diff changeset
   823
void CCalenViewAttachmentsDialog::UpdateAttachmentsFetchFlags()
hgs
parents:
diff changeset
   824
    {    
hgs
parents:
diff changeset
   825
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   826
    
hgs
parents:
diff changeset
   827
    //Update attachmentmodel to secure model is up to date.
hgs
parents:
diff changeset
   828
    for(TInt itemIndex=0; itemIndex<iAttachmentModel.NumberOfItems(); itemIndex++)
hgs
parents:
diff changeset
   829
        {
hgs
parents:
diff changeset
   830
        CCalenAttachmentInfo& attInfo =
hgs
parents:
diff changeset
   831
        iAttachmentModel.AttachmentInfoAt(itemIndex);                      
hgs
parents:
diff changeset
   832
        attInfo.SetFetched( ETrue );               
hgs
parents:
diff changeset
   833
        }
hgs
parents:
diff changeset
   834
        
hgs
parents:
diff changeset
   835
    //If there are attachments update the middle soft key
hgs
parents:
diff changeset
   836
    //according to the first attachment
hgs
parents:
diff changeset
   837
    if( iAttachmentModel.NumberOfItems() > 0 )
hgs
parents:
diff changeset
   838
        {
hgs
parents:
diff changeset
   839
        TRAP_IGNORE( UpdateMiddleSoftKeyL(CurrentListItemIndex()) );    
hgs
parents:
diff changeset
   840
        }
hgs
parents:
diff changeset
   841
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   842
    
hgs
parents:
diff changeset
   843
    }
hgs
parents:
diff changeset
   844
hgs
parents:
diff changeset
   845
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   846
// CCalenViewAttachmentsDialog::OfferKeyEventL
hgs
parents:
diff changeset
   847
// (other items were commented in a header).
hgs
parents:
diff changeset
   848
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   849
//
hgs
parents:
diff changeset
   850
TKeyResponse CCalenViewAttachmentsDialog::OfferKeyEventL(
hgs
parents:
diff changeset
   851
    const TKeyEvent& aKeyEvent, TEventCode aType)
hgs
parents:
diff changeset
   852
    {
hgs
parents:
diff changeset
   853
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   854
    
hgs
parents:
diff changeset
   855
    // Consume send keys, so that they are not handled in the appui
hgs
parents:
diff changeset
   856
    if( aType == EEventKey && aKeyEvent.iCode == EKeyYes )
hgs
parents:
diff changeset
   857
        {
hgs
parents:
diff changeset
   858
        TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   859
        
hgs
parents:
diff changeset
   860
        return EKeyWasConsumed;
hgs
parents:
diff changeset
   861
        }  
hgs
parents:
diff changeset
   862
    
hgs
parents:
diff changeset
   863
    TInt index( CurrentListItemIndex() );
hgs
parents:
diff changeset
   864
     if ( index != KErrNotFound && !MenuShowing() )
hgs
parents:
diff changeset
   865
        {
hgs
parents:
diff changeset
   866
        if ( aType == EEventKey )
hgs
parents:
diff changeset
   867
            {
hgs
parents:
diff changeset
   868
            if( aKeyEvent.iCode == EKeyOK )
hgs
parents:
diff changeset
   869
                {
hgs
parents:
diff changeset
   870
                 //Single click integration
hgs
parents:
diff changeset
   871
                iListBox->OfferKeyEventL( aKeyEvent, aType );
hgs
parents:
diff changeset
   872
                return EKeyWasConsumed;
hgs
parents:
diff changeset
   873
                }
hgs
parents:
diff changeset
   874
            else if( aKeyEvent.iCode == EKeyBackspace
hgs
parents:
diff changeset
   875
                    && iMenuBar->ItemSpecificCommandsEnabled() )
hgs
parents:
diff changeset
   876
                {
hgs
parents:
diff changeset
   877
                //todo isssue a confirmation query
hgs
parents:
diff changeset
   878
                CCalenAttachmentInfo& attaInfo =
hgs
parents:
diff changeset
   879
                    iAttachmentModel.AttachmentInfoAt(index);
hgs
parents:
diff changeset
   880
                if ( CanRemoveAttachment( attaInfo ) )
hgs
parents:
diff changeset
   881
                    {
hgs
parents:
diff changeset
   882
                    ProcessCommandL(ECalenViewAttachmentCmdRemove);
hgs
parents:
diff changeset
   883
                    }
hgs
parents:
diff changeset
   884
                TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   885
                
hgs
parents:
diff changeset
   886
                return EKeyWasConsumed;
hgs
parents:
diff changeset
   887
                }
hgs
parents:
diff changeset
   888
            else if(aKeyEvent.iCode == EKeyNo)
hgs
parents:
diff changeset
   889
               {
hgs
parents:
diff changeset
   890
               iController.BroadcastNotification(ECalenNotifyAttachmentViewerClosed);
hgs
parents:
diff changeset
   891
               }
hgs
parents:
diff changeset
   892
			   else if(aKeyEvent.iCode == EKeyEscape)
hgs
parents:
diff changeset
   893
               {
hgs
parents:
diff changeset
   894
               MCalenToolbar* toolbar = iController.Services().ToolbarOrNull();
hgs
parents:
diff changeset
   895
				if(toolbar)
hgs
parents:
diff changeset
   896
                {
hgs
parents:
diff changeset
   897
                    toolbar->SetToolbarVisibilityL(ETrue);
hgs
parents:
diff changeset
   898
                }
hgs
parents:
diff changeset
   899
			   iController.BroadcastNotification(ECalenNotifyAttachmentViewerClosed);
hgs
parents:
diff changeset
   900
               }
hgs
parents:
diff changeset
   901
            }
hgs
parents:
diff changeset
   902
        else if ( aType == EEventKeyUp )
hgs
parents:
diff changeset
   903
            {
hgs
parents:
diff changeset
   904
            UpdateMiddleSoftKeyL( index );
hgs
parents:
diff changeset
   905
            }
hgs
parents:
diff changeset
   906
        }
hgs
parents:
diff changeset
   907
     TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   908
hgs
parents:
diff changeset
   909
    return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
hgs
parents:
diff changeset
   910
    }
hgs
parents:
diff changeset
   911
hgs
parents:
diff changeset
   912
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   913
// CCalenViewAttachmentsDialog::OpenAttachmentL
hgs
parents:
diff changeset
   914
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   915
//
hgs
parents:
diff changeset
   916
void CCalenViewAttachmentsDialog::OpenAttachmentL()
hgs
parents:
diff changeset
   917
    {
hgs
parents:
diff changeset
   918
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   919
    
hgs
parents:
diff changeset
   920
    if ( CheckSpaceBelowCriticalLevelL() )
hgs
parents:
diff changeset
   921
        {    
hgs
parents:
diff changeset
   922
        TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   923
        
hgs
parents:
diff changeset
   924
        return;
hgs
parents:
diff changeset
   925
        }
hgs
parents:
diff changeset
   926
    else
hgs
parents:
diff changeset
   927
        {
hgs
parents:
diff changeset
   928
        CCalenViewAttachmentsDialog::ProcessCommandL(ECalenViewAttachmentCmdOpen);
hgs
parents:
diff changeset
   929
        } 
hgs
parents:
diff changeset
   930
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   931
    
hgs
parents:
diff changeset
   932
    }
hgs
parents:
diff changeset
   933
hgs
parents:
diff changeset
   934
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   935
// CCalenViewAttachmentsDialog::CanRemoveAttachment
hgs
parents:
diff changeset
   936
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   937
//
hgs
parents:
diff changeset
   938
TBool CCalenViewAttachmentsDialog::CanRemoveAttachment(
hgs
parents:
diff changeset
   939
    CCalenAttachmentInfo& aInfo )
hgs
parents:
diff changeset
   940
    {    
hgs
parents:
diff changeset
   941
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   942
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   943
    return (aInfo.IsFetched() );
hgs
parents:
diff changeset
   944
    }
hgs
parents:
diff changeset
   945
hgs
parents:
diff changeset
   946
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   947
// CCalenViewAttachmentsDialog::SetMiddleSoftKeyLabelL
hgs
parents:
diff changeset
   948
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   949
//
hgs
parents:
diff changeset
   950
void CCalenViewAttachmentsDialog::SetMiddleSoftKeyLabelL(
hgs
parents:
diff changeset
   951
    TInt aResourceId, TInt aCommandId )
hgs
parents:
diff changeset
   952
    {
hgs
parents:
diff changeset
   953
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   954
    
hgs
parents:
diff changeset
   955
    HBufC* middleSKText = StringLoader::LoadLC( aResourceId );
hgs
parents:
diff changeset
   956
hgs
parents:
diff changeset
   957
    ButtonGroupContainer().AddCommandToStackL(
hgs
parents:
diff changeset
   958
        KMSKControlID,
hgs
parents:
diff changeset
   959
        aCommandId,
hgs
parents:
diff changeset
   960
        *middleSKText );
hgs
parents:
diff changeset
   961
    CleanupStack::PopAndDestroy( middleSKText );
hgs
parents:
diff changeset
   962
    
hgs
parents:
diff changeset
   963
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   964
    }
hgs
parents:
diff changeset
   965
hgs
parents:
diff changeset
   966
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   967
// CCalenViewAttachmentsDialog::UpdateMiddleSoftKeyL
hgs
parents:
diff changeset
   968
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   969
//
hgs
parents:
diff changeset
   970
void CCalenViewAttachmentsDialog::UpdateMiddleSoftKeyL( TInt aIndex )
hgs
parents:
diff changeset
   971
    {
hgs
parents:
diff changeset
   972
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   973
    
hgs
parents:
diff changeset
   974
    ASSERT( aIndex >= 0 && aIndex < iAttachmentModel.NumberOfItems() );
hgs
parents:
diff changeset
   975
hgs
parents:
diff changeset
   976
        // set command as "open"
hgs
parents:
diff changeset
   977
        ButtonGroupContainer().RemoveCommandFromStack(
hgs
parents:
diff changeset
   978
            KMSKControlID, EAknSoftkeyOpen );
hgs
parents:
diff changeset
   979
        SetMiddleSoftKeyLabelL(
hgs
parents:
diff changeset
   980
            R_QTN_MSK_FETCH, ECalenViewAttachmentCmdOpen );
hgs
parents:
diff changeset
   981
    
hgs
parents:
diff changeset
   982
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   983
    }
hgs
parents:
diff changeset
   984
hgs
parents:
diff changeset
   985
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   986
// CCalenViewAttachmentsDialog::GetHelpContext
hgs
parents:
diff changeset
   987
// This function is called when Help application is launched.
hgs
parents:
diff changeset
   988
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   989
//
hgs
parents:
diff changeset
   990
void CCalenViewAttachmentsDialog::GetHelpContext(TCoeHelpContext& /*aContext*/) const
hgs
parents:
diff changeset
   991
    {
hgs
parents:
diff changeset
   992
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
   993
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
   994
    }
hgs
parents:
diff changeset
   995
hgs
parents:
diff changeset
   996
 // -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   997
// CCalenViewAttachmentsDialog::OkToExitL
hgs
parents:
diff changeset
   998
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
   999
//
hgs
parents:
diff changeset
  1000
TBool CCalenViewAttachmentsDialog::OkToExitL(TInt aButtonId)
hgs
parents:
diff changeset
  1001
    {
hgs
parents:
diff changeset
  1002
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
  1003
    
hgs
parents:
diff changeset
  1004
    //Check if user has selected exit from menu
hgs
parents:
diff changeset
  1005
    // -> whole application shall be closed.
hgs
parents:
diff changeset
  1006
    if ( aButtonId == EAknSoftkeyOk )
hgs
parents:
diff changeset
  1007
        {
hgs
parents:
diff changeset
  1008
        if ( CCalenViewAttachmentsDialog::HandleOkToExitL(aButtonId) )
hgs
parents:
diff changeset
  1009
           {
hgs
parents:
diff changeset
  1010
           CEikAppUi* appUi = iEikonEnv->EikAppUi();
hgs
parents:
diff changeset
  1011
           static_cast<MEikCommandObserver*>(appUi)->ProcessCommandL(
hgs
parents:
diff changeset
  1012
            EAknCmdExit );
hgs
parents:
diff changeset
  1013
           return ETrue;
hgs
parents:
diff changeset
  1014
           }
hgs
parents:
diff changeset
  1015
        else
hgs
parents:
diff changeset
  1016
           {
hgs
parents:
diff changeset
  1017
           TRACE_EXIT_POINT;
hgs
parents:
diff changeset
  1018
           
hgs
parents:
diff changeset
  1019
           return EFalse;
hgs
parents:
diff changeset
  1020
           }
hgs
parents:
diff changeset
  1021
        }
hgs
parents:
diff changeset
  1022
hgs
parents:
diff changeset
  1023
     else if ( aButtonId == ECalenViewAttachmentCmdOpen )
hgs
parents:
diff changeset
  1024
        {
hgs
parents:
diff changeset
  1025
        ProcessCommandL( aButtonId );
hgs
parents:
diff changeset
  1026
        
hgs
parents:
diff changeset
  1027
        TRACE_EXIT_POINT;
hgs
parents:
diff changeset
  1028
        
hgs
parents:
diff changeset
  1029
        return EFalse;
hgs
parents:
diff changeset
  1030
        }
hgs
parents:
diff changeset
  1031
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
  1032
    
hgs
parents:
diff changeset
  1033
    //Let base class decide if it ok to exit
hgs
parents:
diff changeset
  1034
    return CCalenViewAttachmentsDialog::HandleOkToExitL(aButtonId);
hgs
parents:
diff changeset
  1035
    }
hgs
parents:
diff changeset
  1036
hgs
parents:
diff changeset
  1037
hgs
parents:
diff changeset
  1038
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
  1039
// CCalenViewAttachmentsDialog::UpdateAttatchmentListL
hgs
parents:
diff changeset
  1040
// Update attatchmentlist
hgs
parents:
diff changeset
  1041
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
  1042
//
hgs
parents:
diff changeset
  1043
void CCalenViewAttachmentsDialog::UpdateAttatchmentListL()
hgs
parents:
diff changeset
  1044
    {
hgs
parents:
diff changeset
  1045
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
  1046
    
hgs
parents:
diff changeset
  1047
    // Handles item addition
hgs
parents:
diff changeset
  1048
    ItemAddedL();   
hgs
parents:
diff changeset
  1049
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
  1050
    }
hgs
parents:
diff changeset
  1051
hgs
parents:
diff changeset
  1052
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
  1053
// CCalenViewAttachmentsDialog::CheckSpaceBelowCriticalLevelL
hgs
parents:
diff changeset
  1054
// Checks if the Flash File System storage will fall below critical level. 
hgs
parents:
diff changeset
  1055
// If there is not enough space, display an error message and return EFalse.
hgs
parents:
diff changeset
  1056
// Return ETrue otherwise.
hgs
parents:
diff changeset
  1057
// (other items were commented in a header).
hgs
parents:
diff changeset
  1058
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
  1059
//
hgs
parents:
diff changeset
  1060
TBool CCalenViewAttachmentsDialog::CheckSpaceBelowCriticalLevelL()
hgs
parents:
diff changeset
  1061
    {
hgs
parents:
diff changeset
  1062
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
  1063
    
hgs
parents:
diff changeset
  1064
    // FIXME: Could be moved to commonui 
hgs
parents:
diff changeset
  1065
    TBool retcode(EFalse);
hgs
parents:
diff changeset
  1066
hgs
parents:
diff changeset
  1067
    if (SysUtil::FFSSpaceBelowCriticalLevelL(&(iCoeEnv->FsSession())))
hgs
parents:
diff changeset
  1068
        {
hgs
parents:
diff changeset
  1069
        CErrorUI* errorUi = CErrorUI::NewLC();
hgs
parents:
diff changeset
  1070
        errorUi->ShowGlobalErrorNoteL(KErrDiskFull);
hgs
parents:
diff changeset
  1071
        CleanupStack::PopAndDestroy( errorUi ); 
hgs
parents:
diff changeset
  1072
        retcode = ETrue;
hgs
parents:
diff changeset
  1073
        }
hgs
parents:
diff changeset
  1074
    TRACE_EXIT_POINT;
hgs
parents:
diff changeset
  1075
    
hgs
parents:
diff changeset
  1076
    return retcode;
hgs
parents:
diff changeset
  1077
    }
hgs
parents:
diff changeset
  1078
hgs
parents:
diff changeset
  1079
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
  1080
// CCalenViewAttachmentsDialog::OpenAttachmentL
hgs
parents:
diff changeset
  1081
// Opens a particular attachment
hgs
parents:
diff changeset
  1082
// -----------------------------------------------------------------------------
hgs
parents:
diff changeset
  1083
//
hgs
parents:
diff changeset
  1084
void CCalenViewAttachmentsDialog::OpenAttachmentViewerL(RFile& aFile, MAknServerAppExitObserver& /*aExitObserver*/)
hgs
parents:
diff changeset
  1085
    {
hgs
parents:
diff changeset
  1086
    TRACE_ENTRY_POINT;
hgs
parents:
diff changeset
  1087
    
hgs
parents:
diff changeset
  1088
    TBuf<250> fileName;
hgs
parents:
diff changeset
  1089
    aFile.FullName(fileName);
hgs
parents:
diff changeset
  1090
    TDataType datatype( CCalenAttachmentUtils::GetMimeType(aFile) );
hgs
parents:
diff changeset
  1091
    
hgs
parents:
diff changeset
  1092
    TInt ret = KErrNone;
hgs
parents:
diff changeset
  1093
    
hgs
parents:
diff changeset
  1094
    if(datatype == KNotePadTextDataType())
hgs
parents:
diff changeset
  1095
        {
hgs
parents:
diff changeset
  1096
        if(iEmbeddedFileOpened)
hgs
parents:
diff changeset
  1097
            {
hgs
parents:
diff changeset
  1098
            return;
hgs
parents:
diff changeset
  1099
            }
hgs
parents:
diff changeset
  1100
        iEmbeddedFileOpened = ETrue;   
hgs
parents:
diff changeset
  1101
        const TDesC& notepadTitle = _L("NotePad");
hgs
parents:
diff changeset
  1102
        ret = CNotepadApi::ExecFileViewerL( aFile, 
hgs
parents:
diff changeset
  1103
                                           &notepadTitle,
hgs
parents:
diff changeset
  1104
                                           ETrue,
hgs
parents:
diff changeset
  1105
                                           ETrue,
hgs
parents:
diff changeset
  1106
                                           KCharacterSetIdentifierIso88591 );
hgs
parents:
diff changeset
  1107
        iEmbeddedFileOpened = EFalse;        
hgs
parents:
diff changeset
  1108
        }
hgs
parents:
diff changeset
  1109
    else
hgs
parents:
diff changeset
  1110
        {
hgs
parents:
diff changeset
  1111
        //doc handler will open the other files (other than text file).
hgs
parents:
diff changeset
  1112
        TRAP( ret, iDocHandler->OpenFileEmbeddedL( aFile, datatype ) );
hgs
parents:
diff changeset
  1113
        if(ret == KErrNone)
hgs
parents:
diff changeset
  1114
            {
hgs
parents:
diff changeset
  1115
            iEmbeddedFileOpened = ETrue;
hgs
parents:
diff changeset
  1116
            }
hgs
parents:
diff changeset
  1117
        }
hgs
parents:
diff changeset
  1118
hgs
parents:
diff changeset
  1119
    switch(ret)
hgs
parents:
diff changeset
  1120
        {
hgs
parents:
diff changeset
  1121
        case KErrNone:
hgs
parents:
diff changeset
  1122
            break;
hgs
parents:
diff changeset
  1123
        default:
hgs
parents:
diff changeset
  1124
            {
hgs
parents:
diff changeset
  1125
            CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
hgs
parents:
diff changeset
  1126
            HBufC* cannotOpen = StringLoader::LoadLC( 
hgs
parents:
diff changeset
  1127
                    R_QTN_CALEN_INFO_CANNOT_OPEN, CEikonEnv::Static() );
hgs
parents:
diff changeset
  1128
            note->ExecuteLD( *cannotOpen );
hgs
parents:
diff changeset
  1129
            CleanupStack::PopAndDestroy();
hgs
parents:
diff changeset
  1130
            }
hgs
parents:
diff changeset
  1131
            break;
hgs
parents:
diff changeset
  1132
        }
hgs
parents:
diff changeset
  1133
    TRACE_EXIT_POINT
hgs
parents:
diff changeset
  1134
    }  
hgs
parents:
diff changeset
  1135
hgs
parents:
diff changeset
  1136
// End of File