calendarui/controller/src/calenviewmanager.cpp
author hgs
Wed, 03 Nov 2010 17:12:22 +0530
changeset 89 b57382753122
parent 81 ce92091cbd61
permissions -rw-r--r--
201045
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:  Calendar view manager
89
hgs
parents: 81
diff changeset
    15
*
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
89
hgs
parents: 81
diff changeset
    19
#include <aknViewAppUi.h>
hgs
parents: 81
diff changeset
    20
#include <centralrepository.h>
hgs
parents: 81
diff changeset
    21
#include <AknQueryDialog.h>
hgs
parents: 81
diff changeset
    22
#include <Calendar.rsg>
hgs
parents: 81
diff changeset
    23
#include <calencommonui.rsg>
hgs
parents: 81
diff changeset
    24
#include <akntoolbar.h>
hgs
parents: 81
diff changeset
    25
#include <calendateutils.h>
hgs
parents: 81
diff changeset
    26
#include <calencommandhandler.h>
hgs
parents: 81
diff changeset
    27
#include <calencommands.hrh>                // Calendar commands
hgs
parents: 81
diff changeset
    28
#include <calentoolbar.h>
hgs
parents: 81
diff changeset
    29
#include <akntoolbarextension.h>
hgs
parents: 81
diff changeset
    30
#include <calenactionuiutils.h>
hgs
parents: 81
diff changeset
    31
#include <featmgr.h>
hgs
parents: 81
diff changeset
    32
hgs
parents: 81
diff changeset
    33
#include "calendarui_debug.h"
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include "calenviewmanager.h"
89
hgs
parents: 81
diff changeset
    35
#include "CalenUid.h"
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include "calencontroller.h"
89
hgs
parents: 81
diff changeset
    37
#include "calenviewpopulator.h"
hgs
parents: 81
diff changeset
    38
#include "calenglobaldata.h"
hgs
parents: 81
diff changeset
    39
#include "CalendarPrivateCRKeys.h"          // includes CalendarInternalCRKeys.h
hgs
parents: 81
diff changeset
    40
#include "calenmonthview.h"                 // Native month view
hgs
parents: 81
diff changeset
    41
#include "calenweekview.h"                  // Native week view
hgs
parents: 81
diff changeset
    42
#include "calendayview.h"                   // Native day view
hgs
parents: 81
diff changeset
    43
#include "calentodoview.h"                  // Native todo view
hgs
parents: 81
diff changeset
    44
#include "caleneventview.h"                 // Event View
hgs
parents: 81
diff changeset
    45
#include "calenmissedalarmsview.h"			// Missed alarms view
hgs
parents: 81
diff changeset
    46
#include "calenmissedeventview.h"			// Missed event view
hgs
parents: 81
diff changeset
    47
#include "calensetting.h"                   // CCalenSetting::TViewType
hgs
parents: 81
diff changeset
    48
#include "calencmdlinelauncher.h"           // Command line launcher
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
#include "calenservicesimpl.h"
89
hgs
parents: 81
diff changeset
    50
#include "CleanupResetAndDestroy.h"
hgs
parents: 81
diff changeset
    51
#include "calentoolbarimpl.h"
hgs
parents: 81
diff changeset
    52
#include "calencustomisationmanager.h"
hgs
parents: 81
diff changeset
    53
#include "calenviewinfo.h"
hgs
parents: 81
diff changeset
    54
#include "calentitlepane.h"
hgs
parents: 81
diff changeset
    55
#include "calenicons.h"
hgs
parents: 81
diff changeset
    56
#include "calendummyview.h"
hgs
parents: 81
diff changeset
    57
hgs
parents: 81
diff changeset
    58
const TInt KArrayGranularity = 5;
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
    61
// CCalenViewManager::NewL
hgs
parents: 81
diff changeset
    62
// 1st phase of construction
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
// (other items were commented in a header).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
//
89
hgs
parents: 81
diff changeset
    66
CCalenViewManager* CCalenViewManager::NewL( CAknViewAppUi& aAppUi,
hgs
parents: 81
diff changeset
    67
                                            CCalenController& aController )
hgs
parents: 81
diff changeset
    68
    {
hgs
parents: 81
diff changeset
    69
    TRACE_ENTRY_POINT;
81
hgs
parents: 75
diff changeset
    70
89
hgs
parents: 81
diff changeset
    71
    CCalenViewManager* self = new( ELeave ) CCalenViewManager( aAppUi,aController );
hgs
parents: 81
diff changeset
    72
    CleanupStack::PushL( self );
hgs
parents: 81
diff changeset
    73
    self->ConstructL();
hgs
parents: 81
diff changeset
    74
    CleanupStack::Pop( self );
45
hgs
parents: 23
diff changeset
    75
89
hgs
parents: 81
diff changeset
    76
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
    77
    return self;
45
hgs
parents: 23
diff changeset
    78
    }
hgs
parents: 23
diff changeset
    79
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
    81
// CCalenViewManager::CCalenViewManager
hgs
parents: 81
diff changeset
    82
// C++ default Constructor.
hgs
parents: 81
diff changeset
    83
// (other items were commented in a header).
hgs
parents: 81
diff changeset
    84
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
    85
//
hgs
parents: 81
diff changeset
    86
CCalenViewManager::CCalenViewManager( CAknViewAppUi& aAppUi, 
hgs
parents: 81
diff changeset
    87
                                      CCalenController& aController )
hgs
parents: 81
diff changeset
    88
    : iAppUi( aAppUi ), iController( aController )
hgs
parents: 81
diff changeset
    89
    {
hgs
parents: 81
diff changeset
    90
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
    91
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
    92
    }
hgs
parents: 81
diff changeset
    93
hgs
parents: 81
diff changeset
    94
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
    95
// CCalenViewManager::~CCalenViewManager
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    96
// Destructor.
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
// (other items were commented in a header).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
//
89
hgs
parents: 81
diff changeset
   100
CCalenViewManager::~CCalenViewManager()
hgs
parents: 81
diff changeset
   101
    {
hgs
parents: 81
diff changeset
   102
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   103
hgs
parents: 81
diff changeset
   104
    delete iPopulator;
hgs
parents: 81
diff changeset
   105
    if(iToolbar)
hgs
parents: 81
diff changeset
   106
        {
hgs
parents: 81
diff changeset
   107
        delete iToolbar;
hgs
parents: 81
diff changeset
   108
        iToolbar = NULL;
hgs
parents: 81
diff changeset
   109
        }
hgs
parents: 81
diff changeset
   110
    if( iSetting )
hgs
parents: 81
diff changeset
   111
        {
hgs
parents: 81
diff changeset
   112
        iSetting->Release();
hgs
parents: 81
diff changeset
   113
        }
hgs
parents: 81
diff changeset
   114
hgs
parents: 81
diff changeset
   115
    if( iGlobalData )
hgs
parents: 81
diff changeset
   116
        {
hgs
parents: 81
diff changeset
   117
        iGlobalData->Release();
hgs
parents: 81
diff changeset
   118
        }
hgs
parents: 81
diff changeset
   119
hgs
parents: 81
diff changeset
   120
    iViewInfoArray.ResetAndDestroy();
hgs
parents: 81
diff changeset
   121
    iKnownPlugins.Reset();
51
hgs
parents: 45
diff changeset
   122
    
89
hgs
parents: 81
diff changeset
   123
    delete iRemovedActiveView;
hgs
parents: 81
diff changeset
   124
    delete iViewRemovalCallback;
hgs
parents: 81
diff changeset
   125
    delete iIcons;
hgs
parents: 81
diff changeset
   126
hgs
parents: 81
diff changeset
   127
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   128
    }
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   131
// CCalenViewManager::ConstructL
hgs
parents: 81
diff changeset
   132
// 2nd phase of construction.
hgs
parents: 81
diff changeset
   133
// (other items were commented in a header).
hgs
parents: 81
diff changeset
   134
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   135
//
hgs
parents: 81
diff changeset
   136
void CCalenViewManager::ConstructL()
hgs
parents: 81
diff changeset
   137
    {
hgs
parents: 81
diff changeset
   138
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   139
hgs
parents: 81
diff changeset
   140
    iGlobalData = CCalenGlobalData::InstanceL();
hgs
parents: 81
diff changeset
   141
    iPopulator = CCalenViewPopulator::NewL( iController );
hgs
parents: 81
diff changeset
   142
hgs
parents: 81
diff changeset
   143
    // Only create a toolbar impl if touch is enabled and a CAknToolbar exists
hgs
parents: 81
diff changeset
   144
    if( AknLayoutUtils::PenEnabled() )
hgs
parents: 81
diff changeset
   145
        {
hgs
parents: 81
diff changeset
   146
        CAknAppUi* appUi = static_cast<CAknAppUi*>( CEikonEnv::Static()->EikAppUi() );
hgs
parents: 81
diff changeset
   147
        if (appUi->CurrentFixedToolbar())
hgs
parents: 81
diff changeset
   148
            {
hgs
parents: 81
diff changeset
   149
            if ( FeatureManager::FeatureSupported( KFeatureIdFfCalDayView  ) )
hgs
parents: 81
diff changeset
   150
                {
hgs
parents: 81
diff changeset
   151
                appUi->CurrentFixedToolbar()->SetToolbarVisibility( EFalse );
hgs
parents: 81
diff changeset
   152
                }
hgs
parents: 81
diff changeset
   153
            else
hgs
parents: 81
diff changeset
   154
                {
hgs
parents: 81
diff changeset
   155
                iToolbar = CCalenToolbarImpl::NewL( iController );
hgs
parents: 81
diff changeset
   156
                }
hgs
parents: 81
diff changeset
   157
            }
hgs
parents: 81
diff changeset
   158
        }
hgs
parents: 81
diff changeset
   159
hgs
parents: 81
diff changeset
   160
    iSetting = CCalenSetting::InstanceL();
hgs
parents: 81
diff changeset
   161
    iPreviousViewId.iViewUid = KNullUid;
hgs
parents: 81
diff changeset
   162
    iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
   163
    iStartupComplete = ETrue;
hgs
parents: 81
diff changeset
   164
    iFakeExit = EFalse;
hgs
parents: 81
diff changeset
   165
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   166
    }
hgs
parents: 81
diff changeset
   167
hgs
parents: 81
diff changeset
   168
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   169
// CCalenViewManager::SetCustomisationManagerL
hgs
parents: 81
diff changeset
   170
// Creates custom views.
hgs
parents: 81
diff changeset
   171
// (other items were commented in a header).
hgs
parents: 81
diff changeset
   172
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   173
//
hgs
parents: 81
diff changeset
   174
void CCalenViewManager::ConstructCustomViewsL(
hgs
parents: 81
diff changeset
   175
                             CCalenCustomisationManager& aCustomisationManager )
hgs
parents: 81
diff changeset
   176
    {
hgs
parents: 81
diff changeset
   177
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   178
hgs
parents: 81
diff changeset
   179
    iCustomisationManager = &aCustomisationManager;
hgs
parents: 81
diff changeset
   180
    ConstructCustomViewsL();
hgs
parents: 81
diff changeset
   181
    ConstructNativeViewsL();
hgs
parents: 81
diff changeset
   182
hgs
parents: 81
diff changeset
   183
    TUid defViewUid = iSetting->DefaultView();
hgs
parents: 81
diff changeset
   184
    ActivateDefaultViewL( defViewUid );
hgs
parents: 81
diff changeset
   185
    	
hgs
parents: 81
diff changeset
   186
    // Register for view activation events
hgs
parents: 81
diff changeset
   187
    iAppUi.AddViewActivationObserverL( this );
hgs
parents: 81
diff changeset
   188
hgs
parents: 81
diff changeset
   189
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   190
    }
hgs
parents: 81
diff changeset
   191
hgs
parents: 81
diff changeset
   192
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   193
// CCalenViewManager::ViewInfoArray
hgs
parents: 81
diff changeset
   194
// Get info array
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
// (other items were commented in a header).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
//
89
hgs
parents: 81
diff changeset
   198
RPointerArray<CCalenViewInfo>& CCalenViewManager::ViewInfoArray()
hgs
parents: 81
diff changeset
   199
    {
hgs
parents: 81
diff changeset
   200
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   201
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   202
    return iViewInfoArray;
hgs
parents: 81
diff changeset
   203
    }
hgs
parents: 81
diff changeset
   204
hgs
parents: 81
diff changeset
   205
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   206
// CCalenViewManager::CustomiszationManager
hgs
parents: 81
diff changeset
   207
// Return reference to the customisation manager
hgs
parents: 81
diff changeset
   208
// (other items were commented in a header).
hgs
parents: 81
diff changeset
   209
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   210
//
hgs
parents: 81
diff changeset
   211
CCalenCustomisationManager& CCalenViewManager::CustomisationManager()
hgs
parents: 81
diff changeset
   212
    {
hgs
parents: 81
diff changeset
   213
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   214
hgs
parents: 81
diff changeset
   215
    ASSERT( iCustomisationManager );
hgs
parents: 81
diff changeset
   216
hgs
parents: 81
diff changeset
   217
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   218
    return *iCustomisationManager;
hgs
parents: 81
diff changeset
   219
    }
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   220
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   222
// CCalenViewManager::ConstructNativeViewsL
hgs
parents: 81
diff changeset
   223
// Constructs the S60 native views and registers them with the view server
hgs
parents: 81
diff changeset
   224
// (other items were commented in a header).
hgs
parents: 81
diff changeset
   225
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   226
//
hgs
parents: 81
diff changeset
   227
void CCalenViewManager::ConstructNativeViewsL()
hgs
parents: 81
diff changeset
   228
    {
hgs
parents: 81
diff changeset
   229
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   230
hgs
parents: 81
diff changeset
   231
    CCalenTitlePane::NewAndSwapL(iAppUi.StatusPane());
hgs
parents: 81
diff changeset
   232
    MCalenServices& services = iController.Services();
hgs
parents: 81
diff changeset
   233
    
hgs
parents: 81
diff changeset
   234
    
hgs
parents: 81
diff changeset
   235
    // Add the native views for the todo view, week view, day view , month
hgs
parents: 81
diff changeset
   236
    // view and event view unless they are already provided by custom views 
hgs
parents: 81
diff changeset
   237
    // in ROM.This is enforced by the customisation manager rejecting any 
hgs
parents: 81
diff changeset
   238
    // views that try to replace the native views but are not in ROM.
hgs
parents: 81
diff changeset
   239
hgs
parents: 81
diff changeset
   240
    if (CreateNativeViewL(KUidCalenMonthView))
hgs
parents: 81
diff changeset
   241
        {
hgs
parents: 81
diff changeset
   242
        // Views take ownership of services object instantly. 
hgs
parents: 81
diff changeset
   243
        // No need for cleanup stack.
hgs
parents: 81
diff changeset
   244
        CCalenMonthView* monthView = CCalenMonthView::NewL(services);
hgs
parents: 81
diff changeset
   245
        AddNativeViewL(monthView); // takes ownership immediately.
hgs
parents: 81
diff changeset
   246
        }
hgs
parents: 81
diff changeset
   247
hgs
parents: 81
diff changeset
   248
    if (CreateNativeViewL(KUidCalenWeekView))
hgs
parents: 81
diff changeset
   249
        {
hgs
parents: 81
diff changeset
   250
        // Views take ownership of services object instantly. 
hgs
parents: 81
diff changeset
   251
        // No need for cleanup stack.
hgs
parents: 81
diff changeset
   252
        CCalenWeekView* weekView = CCalenWeekView::NewL(services);
hgs
parents: 81
diff changeset
   253
        AddNativeViewL(weekView); // takes ownership immediately.
hgs
parents: 81
diff changeset
   254
        }
hgs
parents: 81
diff changeset
   255
        
hgs
parents: 81
diff changeset
   256
    if (CreateNativeViewL(KUidCalenDayView))
hgs
parents: 81
diff changeset
   257
        {  
hgs
parents: 81
diff changeset
   258
        // Views take ownership of services object instantly. 
hgs
parents: 81
diff changeset
   259
        // No need for cleanup stack.
hgs
parents: 81
diff changeset
   260
        CCalenDayView* dayView = CCalenDayView::NewL(services);
hgs
parents: 81
diff changeset
   261
        AddNativeViewL(dayView); // takes ownership immediately.
hgs
parents: 81
diff changeset
   262
        }
hgs
parents: 81
diff changeset
   263
    
hgs
parents: 81
diff changeset
   264
    if (CreateNativeViewL(KUidCalenTodoView))
hgs
parents: 81
diff changeset
   265
        {
hgs
parents: 81
diff changeset
   266
        // Views take ownership of services object instantly. 
hgs
parents: 81
diff changeset
   267
        // No need for cleanup stack.
hgs
parents: 81
diff changeset
   268
        CCalenTodoView* todoView = CCalenTodoView::NewL(services);
hgs
parents: 81
diff changeset
   269
        AddNativeViewL(todoView); // takes ownership immediately.
hgs
parents: 81
diff changeset
   270
        }
hgs
parents: 81
diff changeset
   271
	
hgs
parents: 81
diff changeset
   272
	if( CreateNativeViewL(KUidCalenEventView))
hgs
parents: 81
diff changeset
   273
		{
hgs
parents: 81
diff changeset
   274
        // Views take ownership of services object instantly. 
hgs
parents: 81
diff changeset
   275
		// No need for cleanup stack.
hgs
parents: 81
diff changeset
   276
        CCalenEventView* eventView = CCalenEventView::NewL(services);
hgs
parents: 81
diff changeset
   277
        AddNativeViewL(eventView); // takes ownership immediately.
hgs
parents: 81
diff changeset
   278
		}
hgs
parents: 81
diff changeset
   279
hgs
parents: 81
diff changeset
   280
	if( CreateNativeViewL(KUidCalenMissedAlarmsView))
hgs
parents: 81
diff changeset
   281
		{
hgs
parents: 81
diff changeset
   282
        // Views take ownership of services object instantly. 
hgs
parents: 81
diff changeset
   283
		// No need for cleanup stack.
hgs
parents: 81
diff changeset
   284
        CCalenMissedAlarmsView* missedAlarmsView = CCalenMissedAlarmsView::NewL(services);
hgs
parents: 81
diff changeset
   285
        AddNativeViewL(missedAlarmsView); // takes ownership immediately.
hgs
parents: 81
diff changeset
   286
		}
hgs
parents: 81
diff changeset
   287
hgs
parents: 81
diff changeset
   288
	if( CreateNativeViewL(KUidCalenMissedEventView))
hgs
parents: 81
diff changeset
   289
		{
hgs
parents: 81
diff changeset
   290
        // Views take ownership of services object instantly. 
hgs
parents: 81
diff changeset
   291
		// No need for cleanup stack.
hgs
parents: 81
diff changeset
   292
        CCalenMissedEventView* missedEventView = CCalenMissedEventView::NewL(services);
hgs
parents: 81
diff changeset
   293
        AddNativeViewL(missedEventView); // takes ownership immediately.
hgs
parents: 81
diff changeset
   294
		}
hgs
parents: 81
diff changeset
   295
	
hgs
parents: 81
diff changeset
   296
	if(CreateNativeViewL(KUidCalenDummyView))
hgs
parents: 81
diff changeset
   297
	    {
hgs
parents: 81
diff changeset
   298
	    CCalenDummyView* dummyView = CCalenDummyView::NewL(services);
hgs
parents: 81
diff changeset
   299
	    AddNativeViewL(dummyView);
hgs
parents: 81
diff changeset
   300
	    }
hgs
parents: 81
diff changeset
   301
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   302
    }
hgs
parents: 81
diff changeset
   303
hgs
parents: 81
diff changeset
   304
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   305
// CCalenViewManager::CreateNativeViewL
hgs
parents: 81
diff changeset
   306
// Checks to see if the native view needs to created.
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
// (other items were commented in a header).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
//
89
hgs
parents: 81
diff changeset
   310
TBool CCalenViewManager::CreateNativeViewL(TUid aViewUid)
hgs
parents: 81
diff changeset
   311
    {
hgs
parents: 81
diff changeset
   312
    TRACE_ENTRY_POINT;
51
hgs
parents: 45
diff changeset
   313
    
89
hgs
parents: 81
diff changeset
   314
    TBool createNativeView = ETrue;
hgs
parents: 81
diff changeset
   315
    TBool (*compareFn)(const TUid*, const CCalenViewInfo&) 
hgs
parents: 81
diff changeset
   316
                                         = CCalenViewInfo::ViewInfoIdentifier;
hgs
parents: 81
diff changeset
   317
                                            
hgs
parents: 81
diff changeset
   318
    TInt position = iViewInfoArray.Find( aViewUid, compareFn );
hgs
parents: 81
diff changeset
   319
    if ( position != KErrNotFound )
hgs
parents: 81
diff changeset
   320
        {
hgs
parents: 81
diff changeset
   321
        // A plugin is trying to replace a native view, find if it is rom
hgs
parents: 81
diff changeset
   322
        // based or not
hgs
parents: 81
diff changeset
   323
        TBool romBased = CustomisationManager().IsViewRomBased( aViewUid );
hgs
parents: 81
diff changeset
   324
        if ( romBased )
hgs
parents: 81
diff changeset
   325
            {
hgs
parents: 81
diff changeset
   326
            createNativeView = EFalse;
hgs
parents: 81
diff changeset
   327
            }
hgs
parents: 81
diff changeset
   328
        else
hgs
parents: 81
diff changeset
   329
            {
hgs
parents: 81
diff changeset
   330
            // A non-rom plugin cannot replace the native views, so the view is
hgs
parents: 81
diff changeset
   331
            // removed
hgs
parents: 81
diff changeset
   332
            iAppUi.RemoveView( aViewUid );
hgs
parents: 81
diff changeset
   333
            
hgs
parents: 81
diff changeset
   334
            // Remove the entry from the view info array
hgs
parents: 81
diff changeset
   335
            iViewInfoArray.Remove( position );
hgs
parents: 81
diff changeset
   336
            
hgs
parents: 81
diff changeset
   337
            createNativeView = ETrue;
hgs
parents: 81
diff changeset
   338
            }
hgs
parents: 81
diff changeset
   339
        }
hgs
parents: 81
diff changeset
   340
        
hgs
parents: 81
diff changeset
   341
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   342
    return createNativeView;
hgs
parents: 81
diff changeset
   343
    }
hgs
parents: 81
diff changeset
   344
 
hgs
parents: 81
diff changeset
   345
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   346
// CCalenViewManager::ConstructCustomViewsL
hgs
parents: 81
diff changeset
   347
// Constructs any custom views from all the plugins and registers them 
hgs
parents: 81
diff changeset
   348
// with the view server
hgs
parents: 81
diff changeset
   349
// (other items were commented in a header).
hgs
parents: 81
diff changeset
   350
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   351
//
hgs
parents: 81
diff changeset
   352
void CCalenViewManager::ConstructCustomViewsL()
hgs
parents: 81
diff changeset
   353
    {
hgs
parents: 81
diff changeset
   354
    TRACE_ENTRY_POINT;
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
89
hgs
parents: 81
diff changeset
   356
    // Get the array of active plugins
hgs
parents: 81
diff changeset
   357
    const RArray<TUid>& plugins = CustomisationManager().ActivePlugins();
hgs
parents: 81
diff changeset
   358
hgs
parents: 81
diff changeset
   359
    // For every active plugin, discover if it offers any customised views
hgs
parents: 81
diff changeset
   360
    // and adds them to the view server.
hgs
parents: 81
diff changeset
   361
    TInt numPlugins = plugins.Count();
hgs
parents: 81
diff changeset
   362
    for( TInt pluginIndex( 0 ); pluginIndex < numPlugins; ++pluginIndex )
hgs
parents: 81
diff changeset
   363
        {
hgs
parents: 81
diff changeset
   364
        TUid pluginUid = plugins[pluginIndex];
hgs
parents: 81
diff changeset
   365
        ConstructCustomViewL( pluginUid );
hgs
parents: 81
diff changeset
   366
        }
hgs
parents: 81
diff changeset
   367
hgs
parents: 81
diff changeset
   368
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   369
    }
hgs
parents: 81
diff changeset
   370
    
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   372
// CCalenViewManager::ConstructCustomViewsL
hgs
parents: 81
diff changeset
   373
// Constructs the custom views from a particular plugin and registers them
hgs
parents: 81
diff changeset
   374
//  with the view server
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
// (other items were commented in a header).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
//
89
hgs
parents: 81
diff changeset
   378
void CCalenViewManager::ConstructCustomViewL( TUid aPluginUid )
hgs
parents: 81
diff changeset
   379
    {
hgs
parents: 81
diff changeset
   380
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   381
hgs
parents: 81
diff changeset
   382
    iKnownPlugins.AppendL( aPluginUid );
hgs
parents: 81
diff changeset
   383
hgs
parents: 81
diff changeset
   384
    RPointerArray<CCalenView> customViews;
hgs
parents: 81
diff changeset
   385
    CleanupResetAndDestroyPushL( customViews );
hgs
parents: 81
diff changeset
   386
hgs
parents: 81
diff changeset
   387
    TRAP_IGNORE(CustomisationManager().GetCustomViewsL( aPluginUid, customViews ));
hgs
parents: 81
diff changeset
   388
    for( TInt viewIndex( customViews.Count()-1 ); viewIndex >= 0; --viewIndex )
hgs
parents: 81
diff changeset
   389
        {
hgs
parents: 81
diff changeset
   390
        CCalenView* customView = customViews[viewIndex];
hgs
parents: 81
diff changeset
   391
        iAppUi.AddViewL( customView );
hgs
parents: 81
diff changeset
   392
        customViews.Remove( viewIndex );
hgs
parents: 81
diff changeset
   393
        }
hgs
parents: 81
diff changeset
   394
    CleanupStack::PopAndDestroy(); // customViews
hgs
parents: 81
diff changeset
   395
hgs
parents: 81
diff changeset
   396
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   397
    }    
hgs
parents: 81
diff changeset
   398
hgs
parents: 81
diff changeset
   399
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   400
// CCalenViewManager::ActivateDefaultViewL
hgs
parents: 81
diff changeset
   401
// Activates the default view (retrieved from settings).
hgs
parents: 81
diff changeset
   402
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   403
//
hgs
parents: 81
diff changeset
   404
void CCalenViewManager::ActivateDefaultViewL( TUid aDefaultView )
hgs
parents: 81
diff changeset
   405
    {
hgs
parents: 81
diff changeset
   406
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   407
hgs
parents: 81
diff changeset
   408
    // Find the default view in the view cycle list
hgs
parents: 81
diff changeset
   409
    TInt position = iViewInfoArray.Find(
hgs
parents: 81
diff changeset
   410
                            aDefaultView, CCalenViewInfo::ViewInfoIdentifier );
hgs
parents: 81
diff changeset
   411
    if( position != KErrNotFound )
hgs
parents: 81
diff changeset
   412
        {
hgs
parents: 81
diff changeset
   413
        iAppUi.SetDefaultViewL( *iAppUi.View( aDefaultView ) );
hgs
parents: 81
diff changeset
   414
        iViewCycleIndex = position;
hgs
parents: 81
diff changeset
   415
        }
hgs
parents: 81
diff changeset
   416
	else
hgs
parents: 81
diff changeset
   417
	    {
hgs
parents: 81
diff changeset
   418
	    CRepository* repository = CRepository::NewL( KCRUidCalendar );
hgs
parents: 81
diff changeset
   419
	    CleanupStack::PushL(repository);
hgs
parents: 81
diff changeset
   420
	    TInt tmp( static_cast<TInt>( KUidCalenMonthView.iUid ) );
hgs
parents: 81
diff changeset
   421
	    TInt position = iViewInfoArray.Find( KUidCalenMonthView, CCalenViewInfo::ViewInfoIdentifier );
hgs
parents: 81
diff changeset
   422
	    User::LeaveIfError( repository->Set( KCalendarDefaultStartView, tmp ) );
hgs
parents: 81
diff changeset
   423
	    iAppUi.SetDefaultViewL( *iAppUi.View( KUidCalenMonthView ) );
hgs
parents: 81
diff changeset
   424
	    iViewCycleIndex = position;
hgs
parents: 81
diff changeset
   425
	    CleanupStack::PopAndDestroy(repository);  
hgs
parents: 81
diff changeset
   426
	    }
hgs
parents: 81
diff changeset
   427
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   428
hgs
parents: 81
diff changeset
   429
    }
hgs
parents: 81
diff changeset
   430
hgs
parents: 81
diff changeset
   431
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   432
// CCalenViewManager::InterruptPopulationL
hgs
parents: 81
diff changeset
   433
// Interrupts the population of the current view. When the editors are launched
hgs
parents: 81
diff changeset
   434
// the view population is interrupted as it will be repopulated when the
hgs
parents: 81
diff changeset
   435
// the editor closes.
hgs
parents: 81
diff changeset
   436
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   437
//
hgs
parents: 81
diff changeset
   438
void CCalenViewManager::InterruptPopulationL()
hgs
parents: 81
diff changeset
   439
    {
hgs
parents: 81
diff changeset
   440
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   441
hgs
parents: 81
diff changeset
   442
    // Cancel population of current view, if it's ongoing.
hgs
parents: 81
diff changeset
   443
    iPopulator->InterruptPopulationL();
hgs
parents: 81
diff changeset
   444
hgs
parents: 81
diff changeset
   445
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   446
    }
45
hgs
parents: 23
diff changeset
   447
hgs
parents: 23
diff changeset
   448
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   449
// CCalenViewManager::RemoveCurrentViewFromMenu
hgs
parents: 81
diff changeset
   450
// Removes the current view from the cascading view switch menu
hgs
parents: 81
diff changeset
   451
// (other items were commented in a header).
55
hgs
parents: 51
diff changeset
   452
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   453
//
hgs
parents: 81
diff changeset
   454
void CCalenViewManager::RemoveCurrentViewFromMenu( CEikMenuPane* aMenuPane )
hgs
parents: 81
diff changeset
   455
    {
hgs
parents: 81
diff changeset
   456
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   457
hgs
parents: 81
diff changeset
   458
    TUid uid = CurrentView();
hgs
parents: 81
diff changeset
   459
hgs
parents: 81
diff changeset
   460
    if( uid == KUidCalenMonthView )
hgs
parents: 81
diff changeset
   461
        {
hgs
parents: 81
diff changeset
   462
        aMenuPane->DeleteMenuItem( ECalenMonthView );
55
hgs
parents: 51
diff changeset
   463
        }
89
hgs
parents: 81
diff changeset
   464
    else if( uid == KUidCalenWeekView )
hgs
parents: 81
diff changeset
   465
        {
hgs
parents: 81
diff changeset
   466
        aMenuPane->DeleteMenuItem( ECalenWeekView );
hgs
parents: 81
diff changeset
   467
        }
hgs
parents: 81
diff changeset
   468
    else if( uid == KUidCalenDayView )
hgs
parents: 81
diff changeset
   469
        {
hgs
parents: 81
diff changeset
   470
        aMenuPane->DeleteMenuItem( ECalenDayView );
55
hgs
parents: 51
diff changeset
   471
        }
89
hgs
parents: 81
diff changeset
   472
    else if( uid == KUidCalenTodoView )
hgs
parents: 81
diff changeset
   473
        {
hgs
parents: 81
diff changeset
   474
        aMenuPane->DeleteMenuItem( ECalenTodoView );
hgs
parents: 81
diff changeset
   475
        }
hgs
parents: 81
diff changeset
   476
    else
hgs
parents: 81
diff changeset
   477
        {
hgs
parents: 81
diff changeset
   478
        // Assert as this point should never be reached
hgs
parents: 81
diff changeset
   479
        ASSERT( 0 );
hgs
parents: 81
diff changeset
   480
        }
hgs
parents: 81
diff changeset
   481
hgs
parents: 81
diff changeset
   482
    TRACE_EXIT_POINT;
55
hgs
parents: 51
diff changeset
   483
    }
hgs
parents: 51
diff changeset
   484
hgs
parents: 51
diff changeset
   485
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   486
// CCalenViewManager::AddNativeViewL
hgs
parents: 81
diff changeset
   487
// Adds a view to the array.
hgs
parents: 81
diff changeset
   488
// (other items were commented in a header).
hgs
parents: 81
diff changeset
   489
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   490
//
hgs
parents: 81
diff changeset
   491
void CCalenViewManager::AddNativeViewL( CCalenView* aView )
hgs
parents: 81
diff changeset
   492
    {
hgs
parents: 81
diff changeset
   493
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   494
hgs
parents: 81
diff changeset
   495
    CleanupStack::PushL( aView );
hgs
parents: 81
diff changeset
   496
    iAppUi.AddViewL( aView );
hgs
parents: 81
diff changeset
   497
    CleanupStack::Pop( aView );
hgs
parents: 81
diff changeset
   498
hgs
parents: 81
diff changeset
   499
    const TDesC& menuName = aView->LocalisedViewNameL( CCalenView::EMenuName );
hgs
parents: 81
diff changeset
   500
    const TDesC& settingsName = aView->LocalisedViewNameL( CCalenView::ESettingsName );
hgs
parents: 81
diff changeset
   501
hgs
parents: 81
diff changeset
   502
    TUid viewUid = aView->Id();
hgs
parents: 81
diff changeset
   503
    
hgs
parents: 81
diff changeset
   504
hgs
parents: 81
diff changeset
   505
    CCalenViewInfo* viewInfo = CCalenViewInfo::NewL( aView->Id(),
hgs
parents: 81
diff changeset
   506
                                                     KUidCalendar,
hgs
parents: 81
diff changeset
   507
                                                     menuName,
hgs
parents: 81
diff changeset
   508
                                                     settingsName,
hgs
parents: 81
diff changeset
   509
                                                     aView->CyclePosition() );
hgs
parents: 81
diff changeset
   510
        
hgs
parents: 81
diff changeset
   511
    // Discover if a native view has been hidden by a plugin.                                             
hgs
parents: 81
diff changeset
   512
    TBool hidden = iCustomisationManager->HiddenView( viewUid );
hgs
parents: 81
diff changeset
   513
    viewInfo->Hide( hidden );
hgs
parents: 81
diff changeset
   514
    
hgs
parents: 81
diff changeset
   515
    // Append to view info array
hgs
parents: 81
diff changeset
   516
    iViewInfoArray.InsertInOrderAllowRepeatsL( viewInfo, 
hgs
parents: 81
diff changeset
   517
                                       CCalenViewInfo::CyclePositionComparison );
hgs
parents: 81
diff changeset
   518
hgs
parents: 81
diff changeset
   519
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   520
    }
hgs
parents: 81
diff changeset
   521
hgs
parents: 81
diff changeset
   522
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   523
// CCalenViewManager::HandleCommandL
hgs
parents: 81
diff changeset
   524
// Handles view manager commands.
45
hgs
parents: 23
diff changeset
   525
// (other items were commented in a header).
hgs
parents: 23
diff changeset
   526
// ----------------------------------------------------------------------------
hgs
parents: 23
diff changeset
   527
//
89
hgs
parents: 81
diff changeset
   528
TBool  CCalenViewManager::HandleCommandL( const TCalenCommand& aCommand )
hgs
parents: 81
diff changeset
   529
    {
hgs
parents: 81
diff changeset
   530
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   531
    
hgs
parents: 81
diff changeset
   532
    TBool commandUsed(EFalse);
51
hgs
parents: 45
diff changeset
   533
    
89
hgs
parents: 81
diff changeset
   534
    switch( aCommand.Command() )
hgs
parents: 81
diff changeset
   535
        {
hgs
parents: 81
diff changeset
   536
        case ECalenMonthView:
hgs
parents: 81
diff changeset
   537
            {
hgs
parents: 81
diff changeset
   538
            RequestActivationL( KUidCalenMonthView );
hgs
parents: 81
diff changeset
   539
            }
hgs
parents: 81
diff changeset
   540
            break;
hgs
parents: 81
diff changeset
   541
        case ECalenWeekView:
hgs
parents: 81
diff changeset
   542
            {
hgs
parents: 81
diff changeset
   543
            RequestActivationL( KUidCalenWeekView );
hgs
parents: 81
diff changeset
   544
            }
hgs
parents: 81
diff changeset
   545
            break;
hgs
parents: 81
diff changeset
   546
        case ECalenDayView:
hgs
parents: 81
diff changeset
   547
            {
hgs
parents: 81
diff changeset
   548
            // reset the flag iForwardedToDayView as view switching is active
hgs
parents: 81
diff changeset
   549
            if(iPreviousToDayView.iViewUid!=KNullUid)
hgs
parents: 81
diff changeset
   550
                {
hgs
parents: 81
diff changeset
   551
                iPreviousToDayView.iViewUid = KNullUid;
hgs
parents: 81
diff changeset
   552
                }
hgs
parents: 81
diff changeset
   553
            
hgs
parents: 81
diff changeset
   554
            TUid viewUid;
hgs
parents: 81
diff changeset
   555
            if ( !iController.IsLaunchFromExternalApp() && FeatureManager::FeatureSupported( KFeatureIdFfCalDayView ) )
hgs
parents: 81
diff changeset
   556
                {
hgs
parents: 81
diff changeset
   557
                viewUid = KUidCalenBCDayViewPlugin;
hgs
parents: 81
diff changeset
   558
                }
hgs
parents: 81
diff changeset
   559
            else
hgs
parents: 81
diff changeset
   560
                {
hgs
parents: 81
diff changeset
   561
                viewUid = KUidCalenDayView;
hgs
parents: 81
diff changeset
   562
                }
hgs
parents: 81
diff changeset
   563
            
hgs
parents: 81
diff changeset
   564
            RequestActivationL( viewUid, KCalenDummyUid, KNullDesC8() );
hgs
parents: 81
diff changeset
   565
            if(iController.IsLaunchFromExternalApp())
hgs
parents: 81
diff changeset
   566
                {
hgs
parents: 81
diff changeset
   567
                iAvoidRepopulation = ETrue;
hgs
parents: 81
diff changeset
   568
                }
hgs
parents: 81
diff changeset
   569
            }
hgs
parents: 81
diff changeset
   570
            break;
hgs
parents: 81
diff changeset
   571
        case ECalenTodoView:
hgs
parents: 81
diff changeset
   572
            {
hgs
parents: 81
diff changeset
   573
            if (iAvoidRepopulation)
hgs
parents: 81
diff changeset
   574
                {
hgs
parents: 81
diff changeset
   575
                iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
   576
                }
hgs
parents: 81
diff changeset
   577
            RequestActivationL( KUidCalenTodoView );
hgs
parents: 81
diff changeset
   578
            }
hgs
parents: 81
diff changeset
   579
            break;
hgs
parents: 81
diff changeset
   580
        case ECalenEventView:
hgs
parents: 81
diff changeset
   581
            {
hgs
parents: 81
diff changeset
   582
            // Fix for EJCU-7LKC2C :: to prevent the display of blank view, 
hgs
parents: 81
diff changeset
   583
            // just set the iAvoidRepopulation to EFalse, 
hgs
parents: 81
diff changeset
   584
            // so that view is populated properly
57
hgs
parents: 55
diff changeset
   585
89
hgs
parents: 81
diff changeset
   586
            if (iAvoidRepopulation)
hgs
parents: 81
diff changeset
   587
                {
hgs
parents: 81
diff changeset
   588
                iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
   589
                }
57
hgs
parents: 55
diff changeset
   590
89
hgs
parents: 81
diff changeset
   591
        	RequestActivationL( KUidCalenEventView );
hgs
parents: 81
diff changeset
   592
            }
hgs
parents: 81
diff changeset
   593
        	break;
hgs
parents: 81
diff changeset
   594
        case ECalenForwardsToDayView:
hgs
parents: 81
diff changeset
   595
            {
hgs
parents: 81
diff changeset
   596
            // set the view iPreviousToDayView to handle the day view's cba
hgs
parents: 81
diff changeset
   597
            // when returning from event view.
hgs
parents: 81
diff changeset
   598
            // From month/week view -> day view -> event view -> day view
hgs
parents: 81
diff changeset
   599
            iPreviousToDayView = iCurrentViewId;
hgs
parents: 81
diff changeset
   600
                        
hgs
parents: 81
diff changeset
   601
            TUid viewUid;
hgs
parents: 81
diff changeset
   602
            if ( FeatureManager::FeatureSupported( KFeatureIdFfCalDayView  ) )
hgs
parents: 81
diff changeset
   603
            	{
hgs
parents: 81
diff changeset
   604
				viewUid = KUidCalenBCDayViewPlugin;
hgs
parents: 81
diff changeset
   605
            	}
hgs
parents: 81
diff changeset
   606
            else
hgs
parents: 81
diff changeset
   607
            	{
hgs
parents: 81
diff changeset
   608
				viewUid = KUidCalenDayView;
hgs
parents: 81
diff changeset
   609
            	}
hgs
parents: 81
diff changeset
   610
			if(iAvoidRepopulation)
hgs
parents: 81
diff changeset
   611
				{
hgs
parents: 81
diff changeset
   612
				iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
   613
				}	
hgs
parents: 81
diff changeset
   614
            RequestActivationL( viewUid, KUidCalenShowBackCba );
hgs
parents: 81
diff changeset
   615
            }
hgs
parents: 81
diff changeset
   616
            break;
hgs
parents: 81
diff changeset
   617
        case ECalenForwardsToWeekView:
hgs
parents: 81
diff changeset
   618
            {
hgs
parents: 81
diff changeset
   619
            // set the view iPreviousToWeekView to handle the week view's cba
hgs
parents: 81
diff changeset
   620
            // From month view -> week view 
hgs
parents: 81
diff changeset
   621
            iPreviousToWeekView = iCurrentViewId;
hgs
parents: 81
diff changeset
   622
            if(iAvoidRepopulation)
hgs
parents: 81
diff changeset
   623
                {
hgs
parents: 81
diff changeset
   624
                iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
   625
                }
hgs
parents: 81
diff changeset
   626
            RequestActivationL( KUidCalenWeekView, KUidCalenShowBackCba );
hgs
parents: 81
diff changeset
   627
            }
hgs
parents: 81
diff changeset
   628
            break;
hgs
parents: 81
diff changeset
   629
        case ECalenNextView:
hgs
parents: 81
diff changeset
   630
            {
hgs
parents: 81
diff changeset
   631
            CycleNextViewL();
hgs
parents: 81
diff changeset
   632
            }
hgs
parents: 81
diff changeset
   633
            break;
hgs
parents: 81
diff changeset
   634
        case ECalenPrevView:
hgs
parents: 81
diff changeset
   635
            {
hgs
parents: 81
diff changeset
   636
            CyclePrevViewL();
hgs
parents: 81
diff changeset
   637
            }
hgs
parents: 81
diff changeset
   638
            break;
hgs
parents: 81
diff changeset
   639
        case ECalenSwitchView:
hgs
parents: 81
diff changeset
   640
            {
hgs
parents: 81
diff changeset
   641
            ShowSwitchViewQueryL();
hgs
parents: 81
diff changeset
   642
            }
hgs
parents: 81
diff changeset
   643
            break;
hgs
parents: 81
diff changeset
   644
        case ECalenStartActiveStep:
hgs
parents: 81
diff changeset
   645
            {
hgs
parents: 81
diff changeset
   646
            StartActiveStepL();
hgs
parents: 81
diff changeset
   647
            }
hgs
parents: 81
diff changeset
   648
            break;
hgs
parents: 81
diff changeset
   649
        case ECalenFasterAppExit:
hgs
parents: 81
diff changeset
   650
        	{
hgs
parents: 81
diff changeset
   651
        	HandleFasterAppExitCommandL();
hgs
parents: 81
diff changeset
   652
        	}
hgs
parents: 81
diff changeset
   653
            break;
hgs
parents: 81
diff changeset
   654
        case ECalenGotoToday:
hgs
parents: 81
diff changeset
   655
            {
hgs
parents: 81
diff changeset
   656
            // get today's date
hgs
parents: 81
diff changeset
   657
            TTime today = CalenDateUtils::Today();
hgs
parents: 81
diff changeset
   658
hgs
parents: 81
diff changeset
   659
            // get the context    
hgs
parents: 81
diff changeset
   660
            MCalenContext& context = iController.Services().Context();
hgs
parents: 81
diff changeset
   661
            TCalTime todayCalTime;
hgs
parents: 81
diff changeset
   662
            todayCalTime.SetTimeLocalL( today );
hgs
parents: 81
diff changeset
   663
            // set today's date to the context
hgs
parents: 81
diff changeset
   664
            context.SetFocusDateAndTimeL( todayCalTime, iCurrentViewId  );
hgs
parents: 81
diff changeset
   665
            
hgs
parents: 81
diff changeset
   666
            SetRepopulation(EFalse);
hgs
parents: 81
diff changeset
   667
            // reactivate the current view
hgs
parents: 81
diff changeset
   668
            //RequestActivationL(iCurrentViewId.iViewUid);
hgs
parents: 81
diff changeset
   669
            RequestActivationL(KUidCalenDayView);
hgs
parents: 81
diff changeset
   670
hgs
parents: 81
diff changeset
   671
			// dim "today" toolbar item since focus is on today            
hgs
parents: 81
diff changeset
   672
            //iToolbar->Toolbar().SetItemDimmed( ECalenGotoToday, ETrue, ETrue);
hgs
parents: 81
diff changeset
   673
            }
hgs
parents: 81
diff changeset
   674
            break;
hgs
parents: 81
diff changeset
   675
        case ECalenGotoNextDay:
hgs
parents: 81
diff changeset
   676
            {
hgs
parents: 81
diff changeset
   677
            ChangeDayL( ETrue );
hgs
parents: 81
diff changeset
   678
            
hgs
parents: 81
diff changeset
   679
            // reactivate the current view
hgs
parents: 81
diff changeset
   680
            RequestActivationL(iCurrentViewId.iViewUid);
hgs
parents: 81
diff changeset
   681
            }
hgs
parents: 81
diff changeset
   682
            break;
hgs
parents: 81
diff changeset
   683
        case ECalenGotoPrevDay:
hgs
parents: 81
diff changeset
   684
            {
hgs
parents: 81
diff changeset
   685
            ChangeDayL( EFalse );
hgs
parents: 81
diff changeset
   686
            
hgs
parents: 81
diff changeset
   687
            // reactivate the current view
hgs
parents: 81
diff changeset
   688
            RequestActivationL(iCurrentViewId.iViewUid);
hgs
parents: 81
diff changeset
   689
            }
hgs
parents: 81
diff changeset
   690
            break;
hgs
parents: 81
diff changeset
   691
        default:
hgs
parents: 81
diff changeset
   692
            break;
hgs
parents: 81
diff changeset
   693
        }
hgs
parents: 81
diff changeset
   694
hgs
parents: 81
diff changeset
   695
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   696
    return commandUsed;
hgs
parents: 81
diff changeset
   697
    }
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   700
// CCalenViewManager::CalenCommandHandlerExtensionL
hgs
parents: 81
diff changeset
   701
// Dummy implementation.
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
// (other items were commented in a header).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
//
89
hgs
parents: 81
diff changeset
   705
TAny* CCalenViewManager::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ )
hgs
parents: 81
diff changeset
   706
    {
hgs
parents: 81
diff changeset
   707
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   708
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   709
    return NULL;
75
hgs
parents: 64
diff changeset
   710
    }
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   711
89
hgs
parents: 81
diff changeset
   712
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   713
// CCalenViewManager::CurrentView
hgs
parents: 81
diff changeset
   714
// Returns the current view's view uid.
hgs
parents: 81
diff changeset
   715
// (other items were commented in a header).
hgs
parents: 81
diff changeset
   716
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   717
//
hgs
parents: 81
diff changeset
   718
TUid CCalenViewManager::CurrentView() const
hgs
parents: 81
diff changeset
   719
    {
hgs
parents: 81
diff changeset
   720
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   721
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   722
    return iCurrentViewId.iViewUid;
hgs
parents: 81
diff changeset
   723
    }
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   726
// CCalenViewManager::HandleViewActivation
hgs
parents: 81
diff changeset
   727
// From MCoeViewActivationObserver
hgs
parents: 81
diff changeset
   728
// Called just before a view in this application is activated by the view server
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
// (other items were commented in a header).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   730
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
//
89
hgs
parents: 81
diff changeset
   732
void CCalenViewManager::HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId,
hgs
parents: 81
diff changeset
   733
                                             const TVwsViewId& aViewIdToBeDeactivated )
hgs
parents: 81
diff changeset
   734
    {
hgs
parents: 81
diff changeset
   735
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   736
hgs
parents: 81
diff changeset
   737
    TBool externalViewSwitch( EFalse );
hgs
parents: 81
diff changeset
   738
    // See if this is an internal or external view switch request
hgs
parents: 81
diff changeset
   739
    if( aViewIdToBeDeactivated.iAppUid != KUidCalendar )
hgs
parents: 81
diff changeset
   740
        {
hgs
parents: 81
diff changeset
   741
        externalViewSwitch = ETrue;
hgs
parents: 81
diff changeset
   742
        }
hgs
parents: 81
diff changeset
   743
hgs
parents: 81
diff changeset
   744
    // If this is an internal view switch (view cycling from the '*' key)
hgs
parents: 81
diff changeset
   745
    // then ActivateLocalViewL will handle any necessary state changes.
hgs
parents: 81
diff changeset
   746
    // If this is an external view switch then we need to find out if Calendar was already
hgs
parents: 81
diff changeset
   747
    // running or if it is being launched to a specific view by another application
hgs
parents: 81
diff changeset
   748
    // calling ActivateViewL with Calendars UID and the UID of one of the standard views.
hgs
parents: 81
diff changeset
   749
    // In this case we need to set the current view in the state or we would get the
hgs
parents: 81
diff changeset
   750
    // default view (from the settings) activated instead of the requested view.
hgs
parents: 81
diff changeset
   751
    if( externalViewSwitch )
hgs
parents: 81
diff changeset
   752
        {
hgs
parents: 81
diff changeset
   753
        // Check that the view being activated belongs to Calendar.  Although I don't see
hgs
parents: 81
diff changeset
   754
        // how this would be called if this was false anyway.
hgs
parents: 81
diff changeset
   755
        if( aNewlyActivatedViewId.iAppUid == KUidCalendar )
hgs
parents: 81
diff changeset
   756
            {
hgs
parents: 81
diff changeset
   757
            // Make sure that any when any open dialogs are closed Calendar will not close as well.
hgs
parents: 81
diff changeset
   758
            // This could be true if Calendar was originally launched directly to the editor, and
hgs
parents: 81
diff changeset
   759
            // so should be closed when the dialog is closed.  If an external view switch request
hgs
parents: 81
diff changeset
   760
            // arrives, we want the dialog to close but Calendar to remain open.
hgs
parents: 81
diff changeset
   761
            // Otherwise we get a CONE 44 panic.
hgs
parents: 81
diff changeset
   762
            //iIsExitOnDlgClose = EFalse;
hgs
parents: 81
diff changeset
   763
            if( iFakeExit )
hgs
parents: 81
diff changeset
   764
                {
hgs
parents: 81
diff changeset
   765
                iCurrentViewId.iViewUid = iSetting->DefaultView();
hgs
parents: 81
diff changeset
   766
                }
hgs
parents: 81
diff changeset
   767
            else
hgs
parents: 81
diff changeset
   768
                {
hgs
parents: 81
diff changeset
   769
            iCurrentViewId = aNewlyActivatedViewId;
hgs
parents: 81
diff changeset
   770
            }
hgs
parents: 81
diff changeset
   771
        }
hgs
parents: 81
diff changeset
   772
        }
hgs
parents: 81
diff changeset
   773
    iFakeExit = EFalse;
hgs
parents: 81
diff changeset
   774
    iViewsActivated = ETrue;
51
hgs
parents: 45
diff changeset
   775
    
89
hgs
parents: 81
diff changeset
   776
    // check for iAvoidRepopulation to avoid repopulation whenever
hgs
parents: 81
diff changeset
   777
    // 1) Application comes to foreground
hgs
parents: 81
diff changeset
   778
    // 2) Applictaion is opened after fake exit
hgs
parents: 81
diff changeset
   779
    if(!iAvoidRepopulation || iController.IsLaunchFromExternalApp() )
hgs
parents: 81
diff changeset
   780
        {
hgs
parents: 81
diff changeset
   781
        TRAPD(error,StartActiveStepL());
hgs
parents: 81
diff changeset
   782
        if(error!=KErrNone)
hgs
parents: 81
diff changeset
   783
            {
hgs
parents: 81
diff changeset
   784
            // do avoid warning
hgs
parents: 81
diff changeset
   785
            }
hgs
parents: 81
diff changeset
   786
        }
hgs
parents: 81
diff changeset
   787
    
hgs
parents: 81
diff changeset
   788
    // Reset the flag iAvoidRepopulation
hgs
parents: 81
diff changeset
   789
    if (iAvoidRepopulation)
hgs
parents: 81
diff changeset
   790
        {
hgs
parents: 81
diff changeset
   791
        iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
   792
        }
hgs
parents: 81
diff changeset
   793
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   794
    }
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   795
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   796
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   797
// CCalenViewManager::RemoveDeActivatedView
hgs
parents: 81
diff changeset
   798
// Asyncronous callback function to remove the current view after it has been 
hgs
parents: 81
diff changeset
   799
// disabled.
hgs
parents: 81
diff changeset
   800
// (other items were commented in a header).
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   802
//
89
hgs
parents: 81
diff changeset
   803
TInt CCalenViewManager::RemoveDeActivatedView( TAny* aObject )
hgs
parents: 81
diff changeset
   804
    {
hgs
parents: 81
diff changeset
   805
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   806
    
hgs
parents: 81
diff changeset
   807
    CCalenViewManager* thisPtr( static_cast<CCalenViewManager*>( aObject ) );
hgs
parents: 81
diff changeset
   808
    TRAP_IGNORE( thisPtr->RemoveDeActivatedViewL() );
hgs
parents: 81
diff changeset
   809
    
hgs
parents: 81
diff changeset
   810
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   811
    return 0;
hgs
parents: 81
diff changeset
   812
    }
hgs
parents: 81
diff changeset
   813
 
hgs
parents: 81
diff changeset
   814
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   815
// CCalenViewManager::RemoveDeActivatedViewL.
hgs
parents: 81
diff changeset
   816
// (Leaving version)
hgs
parents: 81
diff changeset
   817
// Asyncronous callback function to remove the current view after it has been 
hgs
parents: 81
diff changeset
   818
// disabled.
hgs
parents: 81
diff changeset
   819
// (other items were commented in a header).
hgs
parents: 81
diff changeset
   820
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   821
//   
hgs
parents: 81
diff changeset
   822
void CCalenViewManager::RemoveDeActivatedViewL()
hgs
parents: 81
diff changeset
   823
    {
hgs
parents: 81
diff changeset
   824
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   825
    
hgs
parents: 81
diff changeset
   826
    TUid removedViewUid = iRemovedActiveView->ViewUid();
hgs
parents: 81
diff changeset
   827
    TUid removedPluginUid = iRemovedActiveView->PluginUid();
51
hgs
parents: 45
diff changeset
   828
    
89
hgs
parents: 81
diff changeset
   829
    // The view isn't the current view, so we
hgs
parents: 81
diff changeset
   830
    // can remove it directly from the view server
hgs
parents: 81
diff changeset
   831
    iAppUi.RemoveView( removedViewUid );
hgs
parents: 81
diff changeset
   832
hgs
parents: 81
diff changeset
   833
    // Delete the view info
hgs
parents: 81
diff changeset
   834
    delete iRemovedActiveView;;
hgs
parents: 81
diff changeset
   835
    iRemovedActiveView = NULL;
hgs
parents: 81
diff changeset
   836
    
hgs
parents: 81
diff changeset
   837
    // Unload the plugin.
hgs
parents: 81
diff changeset
   838
    RArray<TUid> pluginArray;
hgs
parents: 81
diff changeset
   839
    CleanupClosePushL( pluginArray );
hgs
parents: 81
diff changeset
   840
    
hgs
parents: 81
diff changeset
   841
    pluginArray.AppendL( removedPluginUid );
hgs
parents: 81
diff changeset
   842
    iCustomisationManager->UnloadPluginsL( pluginArray );
hgs
parents: 81
diff changeset
   843
    CleanupStack::PopAndDestroy(); // pluginArray
hgs
parents: 81
diff changeset
   844
    
hgs
parents: 81
diff changeset
   845
    if(!iController.IsFasterAppFlagEnabled())
hgs
parents: 81
diff changeset
   846
        {
hgs
parents: 81
diff changeset
   847
        // Refresh the current view by simulating a settings close
hgs
parents: 81
diff changeset
   848
        iController.BroadcastNotification( ECalenNotifySettingsClosed );
hgs
parents: 81
diff changeset
   849
        }
hgs
parents: 81
diff changeset
   850
    else
hgs
parents: 81
diff changeset
   851
        {
hgs
parents: 81
diff changeset
   852
        iController.BroadcastNotification( ECalenNotifyCheckPluginUnloading );
hgs
parents: 81
diff changeset
   853
        }
hgs
parents: 81
diff changeset
   854
hgs
parents: 81
diff changeset
   855
    TRACE_EXIT_POINT;
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
    }
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   858
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   859
// CCalenViewManager::CycleNextViewL
hgs
parents: 81
diff changeset
   860
// Requests activation for the next view in the view cycle
hgs
parents: 81
diff changeset
   861
// (other items were commented in a header).
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   862
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
//
89
hgs
parents: 81
diff changeset
   864
void CCalenViewManager::CycleNextViewL()
hgs
parents: 81
diff changeset
   865
    {
hgs
parents: 81
diff changeset
   866
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   867
hgs
parents: 81
diff changeset
   868
    // Increment until we get to a valid view.
hgs
parents: 81
diff changeset
   869
    do{
hgs
parents: 81
diff changeset
   870
        ++iViewCycleIndex;
hgs
parents: 81
diff changeset
   871
hgs
parents: 81
diff changeset
   872
        if( iViewCycleIndex >= iViewInfoArray.Count() )
hgs
parents: 81
diff changeset
   873
            {
hgs
parents: 81
diff changeset
   874
            iViewCycleIndex = 0;
hgs
parents: 81
diff changeset
   875
            }
hgs
parents: 81
diff changeset
   876
        }
hgs
parents: 81
diff changeset
   877
    while( iViewInfoArray[iViewCycleIndex]->CyclePosition() == CCalenView::ENoCyclePosition );
hgs
parents: 81
diff changeset
   878
hgs
parents: 81
diff changeset
   879
    RequestActivationL( iViewInfoArray[iViewCycleIndex]->ViewUid() );
hgs
parents: 81
diff changeset
   880
hgs
parents: 81
diff changeset
   881
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   882
    }
hgs
parents: 81
diff changeset
   883
hgs
parents: 81
diff changeset
   884
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   885
// CCalenViewManager::CyclePrevViewL
hgs
parents: 81
diff changeset
   886
// Requests activation for the previous view in the view cycle
hgs
parents: 81
diff changeset
   887
// (other items were commented in a header).
hgs
parents: 81
diff changeset
   888
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   889
//
hgs
parents: 81
diff changeset
   890
void CCalenViewManager::CyclePrevViewL()
hgs
parents: 81
diff changeset
   891
    {
hgs
parents: 81
diff changeset
   892
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   893
hgs
parents: 81
diff changeset
   894
    // Decrement until we get to a valid view.
hgs
parents: 81
diff changeset
   895
    do{
hgs
parents: 81
diff changeset
   896
        --iViewCycleIndex;
hgs
parents: 81
diff changeset
   897
hgs
parents: 81
diff changeset
   898
        if( iViewCycleIndex < 0 )
hgs
parents: 81
diff changeset
   899
            {
hgs
parents: 81
diff changeset
   900
            iViewCycleIndex = iViewInfoArray.Count()-1;
hgs
parents: 81
diff changeset
   901
            }
hgs
parents: 81
diff changeset
   902
        }
hgs
parents: 81
diff changeset
   903
    while ( iViewInfoArray[iViewCycleIndex]->CyclePosition() == CCalenView::ENoCyclePosition );
hgs
parents: 81
diff changeset
   904
hgs
parents: 81
diff changeset
   905
    RequestActivationL( iViewInfoArray[iViewCycleIndex]->ViewUid() );
hgs
parents: 81
diff changeset
   906
hgs
parents: 81
diff changeset
   907
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   908
    }
hgs
parents: 81
diff changeset
   909
hgs
parents: 81
diff changeset
   910
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   911
// CCalenViewManager::RequestActivationL
hgs
parents: 81
diff changeset
   912
// Request activation of a specific view.
hgs
parents: 81
diff changeset
   913
// (other items were commented in a header).
hgs
parents: 81
diff changeset
   914
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   915
//
hgs
parents: 81
diff changeset
   916
void CCalenViewManager::RequestActivationL( const TVwsViewId& aViewId )
hgs
parents: 81
diff changeset
   917
    {
hgs
parents: 81
diff changeset
   918
    TRACE_ENTRY_POINT;
51
hgs
parents: 45
diff changeset
   919
    
89
hgs
parents: 81
diff changeset
   920
    RequestActivationL( aViewId.iViewUid );
hgs
parents: 81
diff changeset
   921
hgs
parents: 81
diff changeset
   922
    TRACE_EXIT_POINT;
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
    }
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   924
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   925
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   926
// CCalenViewManager::RequestActivationL
hgs
parents: 81
diff changeset
   927
// Call this to try to activate a view
hgs
parents: 81
diff changeset
   928
// (other items were commented in a header).
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   929
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   930
//
89
hgs
parents: 81
diff changeset
   931
void CCalenViewManager::RequestActivationL( const TUid& aViewUid,
hgs
parents: 81
diff changeset
   932
                                            const TUid& aMessageId,
hgs
parents: 81
diff changeset
   933
                                            const TDesC8& aMessage )
hgs
parents: 81
diff changeset
   934
    {
hgs
parents: 81
diff changeset
   935
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   936
hgs
parents: 81
diff changeset
   937
    // Cancel population of current view, if it's ongoing.
hgs
parents: 81
diff changeset
   938
    iPopulator->InterruptPopulationL();
hgs
parents: 81
diff changeset
   939
    // We start population of the newly activated view in HandleViewActivationL.
hgs
parents: 81
diff changeset
   940
    
hgs
parents: 81
diff changeset
   941
    // cache the previousviewid as we are getting aViewUid as reference.
hgs
parents: 81
diff changeset
   942
    TUid cachePreviousViewId = iCurrentViewId.iViewUid;
hgs
parents: 81
diff changeset
   943
    
hgs
parents: 81
diff changeset
   944
    iCurrentViewId.iViewUid = aViewUid;
hgs
parents: 81
diff changeset
   945
    // Update the view cycle index as iViewInfoArray would have changed
hgs
parents: 81
diff changeset
   946
	iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, 
hgs
parents: 81
diff changeset
   947
                                            CCalenViewInfo::ViewInfoIdentifier );
51
hgs
parents: 45
diff changeset
   948
    
89
hgs
parents: 81
diff changeset
   949
	if( iController.IsFasterAppFlagEnabled() )
hgs
parents: 81
diff changeset
   950
		{
hgs
parents: 81
diff changeset
   951
	    // Leave the application in background
hgs
parents: 81
diff changeset
   952
	    iAppUi.HideInBackground();
hgs
parents: 81
diff changeset
   953
	    // Disable bring-to-foreground on view activation
hgs
parents: 81
diff changeset
   954
		iAppUi.SetCustomControl(1); 
hgs
parents: 81
diff changeset
   955
		
hgs
parents: 81
diff changeset
   956
		// activate the view
hgs
parents: 81
diff changeset
   957
		iAppUi.ActivateLocalViewL( aViewUid, KCalenHideInBackGround, KNullDesC8() );
hgs
parents: 81
diff changeset
   958
	
hgs
parents: 81
diff changeset
   959
		// Enable bring-to-foreground on view activation.
hgs
parents: 81
diff changeset
   960
		iAppUi.SetCustomControl(0);  
45
hgs
parents: 23
diff changeset
   961
		}
89
hgs
parents: 81
diff changeset
   962
	else
hgs
parents: 81
diff changeset
   963
		{
hgs
parents: 81
diff changeset
   964
		iAppUi.ActivateLocalViewL( aViewUid, aMessageId, aMessage );
hgs
parents: 81
diff changeset
   965
		}
hgs
parents: 81
diff changeset
   966
	
hgs
parents: 81
diff changeset
   967
	// set the previous view id
hgs
parents: 81
diff changeset
   968
	if(cachePreviousViewId != KUidCalenEventView || cachePreviousViewId != iCurrentViewId.iViewUid) 
hgs
parents: 81
diff changeset
   969
	    {
hgs
parents: 81
diff changeset
   970
        iPreviousViewId.iViewUid = cachePreviousViewId; 
hgs
parents: 81
diff changeset
   971
	    }	
hgs
parents: 81
diff changeset
   972
	TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   973
    }
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   974
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   975
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
   976
// CCalenViewManager::StartActiveStepL
hgs
parents: 81
diff changeset
   977
// Starts population of the current view.
hgs
parents: 81
diff changeset
   978
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   979
//
hgs
parents: 81
diff changeset
   980
void CCalenViewManager::StartActiveStepL()
hgs
parents: 81
diff changeset
   981
    {
hgs
parents: 81
diff changeset
   982
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
   983
    
hgs
parents: 81
diff changeset
   984
    // check for current viewid
hgs
parents: 81
diff changeset
   985
    // populate the view only if iCurrentViewId is set
hgs
parents: 81
diff changeset
   986
    if(iCurrentViewId.iViewUid != KNullUid)
hgs
parents: 81
diff changeset
   987
        {
hgs
parents: 81
diff changeset
   988
        iPopulator->InterruptPopulationL();
hgs
parents: 81
diff changeset
   989
        iPopulator->BeginPopulationL(reinterpret_cast<CCalenView*>(iAppUi.View(CurrentView())));
hgs
parents: 81
diff changeset
   990
        }
hgs
parents: 81
diff changeset
   991
hgs
parents: 81
diff changeset
   992
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
   993
    }
hgs
parents: 81
diff changeset
   994
hgs
parents: 81
diff changeset
   995
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
   996
// CCalenViewManager::ShowSwitchViewQueryL
hgs
parents: 81
diff changeset
   997
// Prompts the user to chose a view to switch to. If cancelled, returns
hgs
parents: 81
diff changeset
   998
// KErrCancel, otherwise one of ECalen*view.
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   999
// (other items were commented in a header).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1000
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1001
//
89
hgs
parents: 81
diff changeset
  1002
void CCalenViewManager::ShowSwitchViewQueryL()
hgs
parents: 81
diff changeset
  1003
    {
hgs
parents: 81
diff changeset
  1004
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1005
hgs
parents: 81
diff changeset
  1006
    // Create list of view names and uids
hgs
parents: 81
diff changeset
  1007
    CDesCArrayFlat* viewNames = new( ELeave ) CDesCArrayFlat( KArrayGranularity );
hgs
parents: 81
diff changeset
  1008
    CleanupStack::PushL( viewNames );
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1009
89
hgs
parents: 81
diff changeset
  1010
    RArray<TUid> viewUids;
hgs
parents: 81
diff changeset
  1011
    CleanupClosePushL( viewUids );
hgs
parents: 81
diff changeset
  1012
											
hgs
parents: 81
diff changeset
  1013
	const RArray<TUid>& activePlugins = CustomisationManager().ActivePlugins();											
hgs
parents: 81
diff changeset
  1014
											
hgs
parents: 81
diff changeset
  1015
    for( TInt index( 0 ); index < iViewInfoArray.Count(); ++index )
hgs
parents: 81
diff changeset
  1016
        {
hgs
parents: 81
diff changeset
  1017
        CCalenViewInfo& viewInfo = *( iViewInfoArray[index] );
hgs
parents: 81
diff changeset
  1018
        if( index != iViewCycleIndex )
hgs
parents: 81
diff changeset
  1019
            {
hgs
parents: 81
diff changeset
  1020
            TUid pluginUid = viewInfo.PluginUid();
hgs
parents: 81
diff changeset
  1021
            TInt position = activePlugins.Find( pluginUid );
hgs
parents: 81
diff changeset
  1022
	        	
hgs
parents: 81
diff changeset
  1023
            // If the view is from plugin or native view with cycle position,
hgs
parents: 81
diff changeset
  1024
            // then add it to the switch view list
hgs
parents: 81
diff changeset
  1025
            if(( position != KErrNotFound ) ||
hgs
parents: 81
diff changeset
  1026
                 ( viewInfo.CyclePosition() != CCalenView::ENoCyclePosition ))
hgs
parents: 81
diff changeset
  1027
                {
hgs
parents: 81
diff changeset
  1028
                // Fetch the view name
hgs
parents: 81
diff changeset
  1029
                TUid viewUid = viewInfo.ViewUid();
hgs
parents: 81
diff changeset
  1030
                const TDesC& viewName = viewInfo.MenuName();
hgs
parents: 81
diff changeset
  1031
                viewNames->AppendL( viewName );
hgs
parents: 81
diff changeset
  1032
                viewUids.AppendL(viewUid );      
hgs
parents: 81
diff changeset
  1033
                }
hgs
parents: 81
diff changeset
  1034
            }
hgs
parents: 81
diff changeset
  1035
        }
hgs
parents: 81
diff changeset
  1036
        
hgs
parents: 81
diff changeset
  1037
    // Show list query.
hgs
parents: 81
diff changeset
  1038
    TInt choice = KErrCancel; //KErrNotFound;
hgs
parents: 81
diff changeset
  1039
    CAknListQueryDialog* dlg = new( ELeave ) CAknListQueryDialog( &choice );
hgs
parents: 81
diff changeset
  1040
    dlg->PrepareLC( R_CALENDAR_SWITCH_VIEW_QUERY ); // pushes dlg to CS
hgs
parents: 81
diff changeset
  1041
    dlg->SetItemTextArray( viewNames );
hgs
parents: 81
diff changeset
  1042
    dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
hgs
parents: 81
diff changeset
  1043
hgs
parents: 81
diff changeset
  1044
    // Set title
hgs
parents: 81
diff changeset
  1045
    CAknPopupHeadingPane* heading = dlg->Heading();
hgs
parents: 81
diff changeset
  1046
    HBufC* title = NULL;
hgs
parents: 81
diff changeset
  1047
    title = CCoeEnv::Static()->AllocReadResourceLC( R_CALENDAR_SWITCH_VIEW_QUERY_TITLE );
hgs
parents: 81
diff changeset
  1048
    heading->SetTextL( *title );
hgs
parents: 81
diff changeset
  1049
    CleanupStack::PopAndDestroy( title );
hgs
parents: 81
diff changeset
  1050
hgs
parents: 81
diff changeset
  1051
    if( dlg->RunLD() )
hgs
parents: 81
diff changeset
  1052
        {
hgs
parents: 81
diff changeset
  1053
        // user made a choice
hgs
parents: 81
diff changeset
  1054
        TUid viewUid = viewUids[choice];
hgs
parents: 81
diff changeset
  1055
        iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
  1056
        RequestActivationL( viewUid );
hgs
parents: 81
diff changeset
  1057
        }
hgs
parents: 81
diff changeset
  1058
hgs
parents: 81
diff changeset
  1059
    CleanupStack::PopAndDestroy(); // viewUids
hgs
parents: 81
diff changeset
  1060
    CleanupStack::PopAndDestroy( viewNames );
hgs
parents: 81
diff changeset
  1061
hgs
parents: 81
diff changeset
  1062
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1063
    }
51
hgs
parents: 45
diff changeset
  1064
    
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1065
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1066
// CCalenViewManager::HandleNotification
hgs
parents: 81
diff changeset
  1067
// Calls back when notifications that it has been registered for are broadcast
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1068
// (other items were commented in a header).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1069
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1070
//
hgs
parents: 81
diff changeset
  1071
void CCalenViewManager::HandleNotification(const TCalenNotification aNotification )
hgs
parents: 81
diff changeset
  1072
    {
hgs
parents: 81
diff changeset
  1073
    TRACE_ENTRY_POINT;
51
hgs
parents: 45
diff changeset
  1074
    
89
hgs
parents: 81
diff changeset
  1075
    PIM_TRAPD_HANDLE( HandleNotificationL( aNotification ) );
hgs
parents: 81
diff changeset
  1076
  
hgs
parents: 81
diff changeset
  1077
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1078
    }
hgs
parents: 81
diff changeset
  1079
    
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1080
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1081
// CCalenViewManager::HandleNotificationL
hgs
parents: 81
diff changeset
  1082
// Called from HandleNotification() when notifications that it has been
hgs
parents: 81
diff changeset
  1083
//  registered for are broadcast
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1084
// (other items were commented in a header).
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1085
// ----------------------------------------------------------------------------
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1086
//
89
hgs
parents: 81
diff changeset
  1087
void CCalenViewManager::HandleNotificationL( TCalenNotification aNotification )
hgs
parents: 81
diff changeset
  1088
    {
hgs
parents: 81
diff changeset
  1089
    TRACE_ENTRY_POINT;
51
hgs
parents: 45
diff changeset
  1090
    
89
hgs
parents: 81
diff changeset
  1091
    switch( aNotification )
hgs
parents: 81
diff changeset
  1092
        {
hgs
parents: 81
diff changeset
  1093
        case ECalenNotifyPluginEnabledDisabled:
hgs
parents: 81
diff changeset
  1094
            {
hgs
parents: 81
diff changeset
  1095
            UpdatePluginListL();
hgs
parents: 81
diff changeset
  1096
            }
hgs
parents: 81
diff changeset
  1097
            break;
hgs
parents: 81
diff changeset
  1098
        case ECalenNotifySettingsClosed:
hgs
parents: 81
diff changeset
  1099
            {
hgs
parents: 81
diff changeset
  1100
            // Nothing has changed, refresh statuspane only.
hgs
parents: 81
diff changeset
  1101
            iAppUi.StatusPane()->DrawNow();
hgs
parents: 81
diff changeset
  1102
            }
hgs
parents: 81
diff changeset
  1103
            break;
hgs
parents: 81
diff changeset
  1104
        case ECalenNotifySettingsChanged:
hgs
parents: 81
diff changeset
  1105
            {
hgs
parents: 81
diff changeset
  1106
            HandleSettingsChangeNotificationL();
hgs
parents: 81
diff changeset
  1107
            }
hgs
parents: 81
diff changeset
  1108
            break;       
hgs
parents: 81
diff changeset
  1109
        case ECalenNotifyEntryDeleted:
hgs
parents: 81
diff changeset
  1110
        case ECalenNotifyInstanceDeleted:    
hgs
parents: 81
diff changeset
  1111
			{
hgs
parents: 81
diff changeset
  1112
			iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
  1113
			HandleEntryDeleteNotificationL();
hgs
parents: 81
diff changeset
  1114
			}
hgs
parents: 81
diff changeset
  1115
			break;
hgs
parents: 81
diff changeset
  1116
        case ECalenNotifySystemLocaleChanged:	
hgs
parents: 81
diff changeset
  1117
        case ECalenNotifyEntrySaved:
hgs
parents: 81
diff changeset
  1118
        case ECalenNotifyMultipleEntriesDeleted:
hgs
parents: 81
diff changeset
  1119
        case ECalenNotifyExternalDatabaseChanged:
hgs
parents: 81
diff changeset
  1120
        case ECalenNotifyCancelDelete:
hgs
parents: 81
diff changeset
  1121
        case ECalenNotifyCalendarFieldChanged:
hgs
parents: 81
diff changeset
  1122
        case ECalenNotifyMarkedEntryCompleted:
hgs
parents: 81
diff changeset
  1123
        case ECalenNotifyCalendarInfoCreated:
hgs
parents: 81
diff changeset
  1124
        case ECalenNotifyCalendarInfoUpdated:
hgs
parents: 81
diff changeset
  1125
            {
hgs
parents: 81
diff changeset
  1126
            StartActiveStepL();
hgs
parents: 81
diff changeset
  1127
            }
hgs
parents: 81
diff changeset
  1128
            break;
hgs
parents: 81
diff changeset
  1129
        case ECalenNotifyCalendarFileDeleted:
hgs
parents: 81
diff changeset
  1130
            {
hgs
parents: 81
diff changeset
  1131
            if(iCurrentViewId.iViewUid==KUidCalenEventView)
hgs
parents: 81
diff changeset
  1132
                {
hgs
parents: 81
diff changeset
  1133
                //If the entry which is being viewed belongs to a calendar 
hgs
parents: 81
diff changeset
  1134
                //that is deleted we check for collection ids of entry and 
hgs
parents: 81
diff changeset
  1135
                //calendar session if they are same return to previous view
hgs
parents: 81
diff changeset
  1136
                TPtrC calFileName = iGlobalData->Context().GetCalendarFileNameL();
hgs
parents: 81
diff changeset
  1137
                TPtrC calFileNameForColId = 
hgs
parents: 81
diff changeset
  1138
                        iGlobalData->GetCalFileNameForCollectionId(iGlobalData->Context().InstanceId().iColId);
hgs
parents: 81
diff changeset
  1139
                if(!calFileNameForColId.CompareF(calFileName))
hgs
parents: 81
diff changeset
  1140
                    {
hgs
parents: 81
diff changeset
  1141
                    ActivateDefaultViewL(iPreviousToDayView.iViewUid);
hgs
parents: 81
diff changeset
  1142
                    }
hgs
parents: 81
diff changeset
  1143
                }
hgs
parents: 81
diff changeset
  1144
            else
hgs
parents: 81
diff changeset
  1145
                {
hgs
parents: 81
diff changeset
  1146
                // refresh the current view
hgs
parents: 81
diff changeset
  1147
                StartActiveStepL();
hgs
parents: 81
diff changeset
  1148
                }
hgs
parents: 81
diff changeset
  1149
            }
hgs
parents: 81
diff changeset
  1150
            break;         
hgs
parents: 81
diff changeset
  1151
        case ECalenNotifyEntryClosed:
hgs
parents: 81
diff changeset
  1152
            {
hgs
parents: 81
diff changeset
  1153
            HandleEntryClosedNotificationL();
hgs
parents: 81
diff changeset
  1154
            }
hgs
parents: 81
diff changeset
  1155
            break;
hgs
parents: 81
diff changeset
  1156
        case ECalenNotifySystemTimeChanged:
hgs
parents: 81
diff changeset
  1157
            {
hgs
parents: 81
diff changeset
  1158
            HandleSystemTimeChangeNotificationL();
hgs
parents: 81
diff changeset
  1159
            }
hgs
parents: 81
diff changeset
  1160
            break;
hgs
parents: 81
diff changeset
  1161
        case ECalenNotifyAppForegrounded:
hgs
parents: 81
diff changeset
  1162
        	{
hgs
parents: 81
diff changeset
  1163
        	// check for system time change whenever fake exit is done
hgs
parents: 81
diff changeset
  1164
        	// or application comes to foreground
hgs
parents: 81
diff changeset
  1165
            if(!iStartupComplete)
hgs
parents: 81
diff changeset
  1166
                {
hgs
parents: 81
diff changeset
  1167
                iController.CheckSystemTimeAtStartUpL();
hgs
parents: 81
diff changeset
  1168
                }
hgs
parents: 81
diff changeset
  1169
        	
hgs
parents: 81
diff changeset
  1170
            if( iController.IsFasterAppFlagEnabled() )
hgs
parents: 81
diff changeset
  1171
			    {
hgs
parents: 81
diff changeset
  1172
			    iAppUi.HideApplicationFromFSW(EFalse);
hgs
parents: 81
diff changeset
  1173
			    iController.SetFasterAppFlag( EFalse );
hgs
parents: 81
diff changeset
  1174
			    
hgs
parents: 81
diff changeset
  1175
			    ReloadAllPluginsL();
hgs
parents: 81
diff changeset
  1176
			    }
hgs
parents: 81
diff changeset
  1177
            else
hgs
parents: 81
diff changeset
  1178
                {
hgs
parents: 81
diff changeset
  1179
                iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
  1180
                }
hgs
parents: 81
diff changeset
  1181
        	}
hgs
parents: 81
diff changeset
  1182
        	break;
hgs
parents: 81
diff changeset
  1183
        case ECalenNotifyDayViewClosed:
hgs
parents: 81
diff changeset
  1184
            {
hgs
parents: 81
diff changeset
  1185
            if(iPreviousToDayView.iViewUid!= KNullUid)
hgs
parents: 81
diff changeset
  1186
                {
hgs
parents: 81
diff changeset
  1187
                // activate the previous view from where day view is launched
hgs
parents: 81
diff changeset
  1188
                // From month/week view -> day view
hgs
parents: 81
diff changeset
  1189
                RequestActivationL(iPreviousToDayView.iViewUid);
hgs
parents: 81
diff changeset
  1190
                }
hgs
parents: 81
diff changeset
  1191
            }
hgs
parents: 81
diff changeset
  1192
            break;
hgs
parents: 81
diff changeset
  1193
        case ECalenNotifyWeekViewClosed:
hgs
parents: 81
diff changeset
  1194
            {
hgs
parents: 81
diff changeset
  1195
            if(iPreviousToWeekView.iViewUid!= KNullUid)
hgs
parents: 81
diff changeset
  1196
                {
hgs
parents: 81
diff changeset
  1197
                // activate the previous view from where day view is launched
hgs
parents: 81
diff changeset
  1198
                // From month/week view -> day view
hgs
parents: 81
diff changeset
  1199
                RequestActivationL(iPreviousToWeekView.iViewUid);
hgs
parents: 81
diff changeset
  1200
                }
hgs
parents: 81
diff changeset
  1201
            }
hgs
parents: 81
diff changeset
  1202
            break;
hgs
parents: 81
diff changeset
  1203
        case ECalenNotifyAppBackgrounded:
hgs
parents: 81
diff changeset
  1204
            {
hgs
parents: 81
diff changeset
  1205
            // set the flag iAvoidRepopulation to prevent repopulation
hgs
parents: 81
diff changeset
  1206
            // whenever application is brought to foreground
hgs
parents: 81
diff changeset
  1207
            iAvoidRepopulation = ETrue;
hgs
parents: 81
diff changeset
  1208
            
hgs
parents: 81
diff changeset
  1209
            if( iController.IsFasterAppFlagEnabled() )
hgs
parents: 81
diff changeset
  1210
                {
hgs
parents: 81
diff changeset
  1211
                TRAP_IGNORE(iController.RemoveDeadCalendarsL());
hgs
parents: 81
diff changeset
  1212
                }
hgs
parents: 81
diff changeset
  1213
            }
hgs
parents: 81
diff changeset
  1214
            break;
hgs
parents: 81
diff changeset
  1215
        case ECalenNotifyViewPopulationComplete:
hgs
parents: 81
diff changeset
  1216
            {
hgs
parents: 81
diff changeset
  1217
            if(iStartupComplete)
hgs
parents: 81
diff changeset
  1218
                {
hgs
parents: 81
diff changeset
  1219
                iController.CheckSystemTimeAtStartUpL();
hgs
parents: 81
diff changeset
  1220
                iStartupComplete = EFalse;
hgs
parents: 81
diff changeset
  1221
                }
hgs
parents: 81
diff changeset
  1222
            break;
hgs
parents: 81
diff changeset
  1223
            }
hgs
parents: 81
diff changeset
  1224
        case ECalenNotifyAttachmentViewerClosed:
hgs
parents: 81
diff changeset
  1225
        		{
hgs
parents: 81
diff changeset
  1226
            if( iCurrentViewId.iViewUid==KUidCalenEventView)
hgs
parents: 81
diff changeset
  1227
                {
hgs
parents: 81
diff changeset
  1228
                StartActiveStepL();
hgs
parents: 81
diff changeset
  1229
                }
hgs
parents: 81
diff changeset
  1230
            }            
hgs
parents: 81
diff changeset
  1231
        case ECalenNotifyAttachmentRemoved:
hgs
parents: 81
diff changeset
  1232
        case ECalenNotifyAttachmentAdded:    
hgs
parents: 81
diff changeset
  1233
            {
hgs
parents: 81
diff changeset
  1234
            if( iCurrentViewId.iViewUid==KUidCalenEventView && 
hgs
parents: 81
diff changeset
  1235
                !iAvoidRepopulation    )
hgs
parents: 81
diff changeset
  1236
                {
hgs
parents: 81
diff changeset
  1237
                StartActiveStepL();
hgs
parents: 81
diff changeset
  1238
                }
hgs
parents: 81
diff changeset
  1239
            }
hgs
parents: 81
diff changeset
  1240
        case ECalenNotifyDeleteFailed:
hgs
parents: 81
diff changeset
  1241
        // Do nothing on deletion failed
hgs
parents: 81
diff changeset
  1242
        default:
hgs
parents: 81
diff changeset
  1243
            break; 
hgs
parents: 81
diff changeset
  1244
        }
hgs
parents: 81
diff changeset
  1245
hgs
parents: 81
diff changeset
  1246
    TRACE_EXIT_POINT;
45
hgs
parents: 23
diff changeset
  1247
    }
89
hgs
parents: 81
diff changeset
  1248
    
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1249
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1250
// CCalenViewManager::UpdatePluginListL
hgs
parents: 81
diff changeset
  1251
// Discovers if a plugin has been enabled or disabled 
hgs
parents: 81
diff changeset
  1252
// (other items were commented in a header).
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1253
// ----------------------------------------------------------------------------
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1254
//
89
hgs
parents: 81
diff changeset
  1255
void CCalenViewManager::UpdatePluginListL()
hgs
parents: 81
diff changeset
  1256
    {
hgs
parents: 81
diff changeset
  1257
    TRACE_ENTRY_POINT;
51
hgs
parents: 45
diff changeset
  1258
    
89
hgs
parents: 81
diff changeset
  1259
    const RArray<TUid>& activePlugins = CustomisationManager().ActivePlugins();
51
hgs
parents: 45
diff changeset
  1260
    
89
hgs
parents: 81
diff changeset
  1261
    // Check for any new plugins
hgs
parents: 81
diff changeset
  1262
    TInt activeCount = activePlugins.Count();
hgs
parents: 81
diff changeset
  1263
    for( TInt index( 0 ); index < activeCount; ++index )
hgs
parents: 81
diff changeset
  1264
        {
hgs
parents: 81
diff changeset
  1265
        // For every active plugin, check to see if it is in the known list,
hgs
parents: 81
diff changeset
  1266
        // if it isn't construct any custom views.
hgs
parents: 81
diff changeset
  1267
        TUid pluginUid = activePlugins[index];
hgs
parents: 81
diff changeset
  1268
        TInt position = iKnownPlugins.Find( pluginUid );
hgs
parents: 81
diff changeset
  1269
        if( position == KErrNotFound )
hgs
parents: 81
diff changeset
  1270
            {
hgs
parents: 81
diff changeset
  1271
            ConstructCustomViewL( pluginUid );
hgs
parents: 81
diff changeset
  1272
            }
hgs
parents: 81
diff changeset
  1273
        }
hgs
parents: 81
diff changeset
  1274
hgs
parents: 81
diff changeset
  1275
    RArray<TUid> disabledPlugins;
hgs
parents: 81
diff changeset
  1276
    CleanupClosePushL( disabledPlugins );
hgs
parents: 81
diff changeset
  1277
        
hgs
parents: 81
diff changeset
  1278
    // Check for any disabled plugins
hgs
parents: 81
diff changeset
  1279
    TInt knownCount = iKnownPlugins.Count();
hgs
parents: 81
diff changeset
  1280
    for( TInt index( knownCount - 1 ); index >= 0; --index )
hgs
parents: 81
diff changeset
  1281
        {
hgs
parents: 81
diff changeset
  1282
        // For every known plugin, check to see if it is in the active list,
hgs
parents: 81
diff changeset
  1283
        // if it isn't add to the disable plugin list, and remove from the
hgs
parents: 81
diff changeset
  1284
        // known list.
hgs
parents: 81
diff changeset
  1285
        TUid pluginUid = iKnownPlugins[index];
hgs
parents: 81
diff changeset
  1286
        TInt position = activePlugins.Find( pluginUid );
hgs
parents: 81
diff changeset
  1287
        if ( position == KErrNotFound )
45
hgs
parents: 23
diff changeset
  1288
            {
89
hgs
parents: 81
diff changeset
  1289
            disabledPlugins.AppendL( pluginUid );
hgs
parents: 81
diff changeset
  1290
            iKnownPlugins.Remove( index );
hgs
parents: 81
diff changeset
  1291
            }
hgs
parents: 81
diff changeset
  1292
        }
55
hgs
parents: 51
diff changeset
  1293
    
89
hgs
parents: 81
diff changeset
  1294
    TInt disabledPluginCount = disabledPlugins.Count();
hgs
parents: 81
diff changeset
  1295
    if( disabledPluginCount != 0 )
hgs
parents: 81
diff changeset
  1296
        {
hgs
parents: 81
diff changeset
  1297
        RemoveDisabledPluginsViewsL( disabledPlugins );
hgs
parents: 81
diff changeset
  1298
        // Re sort the view info array
hgs
parents: 81
diff changeset
  1299
        iViewInfoArray.Sort(  CCalenViewInfo::CyclePositionComparison );
hgs
parents: 81
diff changeset
  1300
        }
hgs
parents: 81
diff changeset
  1301
    else
hgs
parents: 81
diff changeset
  1302
        {      
hgs
parents: 81
diff changeset
  1303
        // Update the view cycle index as iViewInfoArray would have changed
hgs
parents: 81
diff changeset
  1304
        iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier );       
hgs
parents: 81
diff changeset
  1305
        }
hgs
parents: 81
diff changeset
  1306
    UpdateToolbarNextViewIconL(iCurrentViewId.iViewUid);
hgs
parents: 81
diff changeset
  1307
    
hgs
parents: 81
diff changeset
  1308
    CleanupStack::PopAndDestroy(); // disabledPlugins
hgs
parents: 81
diff changeset
  1309
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1310
    } 
hgs
parents: 81
diff changeset
  1311
    
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1312
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1313
// CCalenViewManager::RemoveDisabledPluginsViewsL
hgs
parents: 81
diff changeset
  1314
// Removes any custom views provided by disabled plugins
hgs
parents: 81
diff changeset
  1315
// from the view server.
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1316
// (other items were commented in a header).
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1317
// ----------------------------------------------------------------------------
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1318
//
89
hgs
parents: 81
diff changeset
  1319
void CCalenViewManager::RemoveDisabledPluginsViewsL( RArray<TUid>& aDisabledPlugins )
hgs
parents: 81
diff changeset
  1320
    {
hgs
parents: 81
diff changeset
  1321
    TRACE_ENTRY_POINT;
55
hgs
parents: 51
diff changeset
  1322
89
hgs
parents: 81
diff changeset
  1323
    // Find what views are provided by the disabled plugins
hgs
parents: 81
diff changeset
  1324
    TInt disabledPluginCount = aDisabledPlugins.Count();
hgs
parents: 81
diff changeset
  1325
    RArray<TUid> removedViews;
hgs
parents: 81
diff changeset
  1326
    CleanupClosePushL( removedViews );
hgs
parents: 81
diff changeset
  1327
    
hgs
parents: 81
diff changeset
  1328
    TUid activeViewUid = CurrentView();
hgs
parents: 81
diff changeset
  1329
    
hgs
parents: 81
diff changeset
  1330
    for( TInt index( disabledPluginCount - 1 ); index >= 0; --index )
hgs
parents: 81
diff changeset
  1331
        {
hgs
parents: 81
diff changeset
  1332
        TUid pluginUid = aDisabledPlugins[index];
hgs
parents: 81
diff changeset
  1333
        
hgs
parents: 81
diff changeset
  1334
        // Does this plugin offer any views
hgs
parents: 81
diff changeset
  1335
        TInt position = iViewInfoArray.Find( pluginUid, 
hgs
parents: 81
diff changeset
  1336
                                             CCalenViewInfo::ViewPluginIdentifier );
hgs
parents: 81
diff changeset
  1337
        TBool alreadySet = EFalse;
hgs
parents: 81
diff changeset
  1338
        while( position != KErrNotFound )
hgs
parents: 81
diff changeset
  1339
            {
hgs
parents: 81
diff changeset
  1340
            CCalenViewInfo* view = iViewInfoArray[position];
hgs
parents: 81
diff changeset
  1341
            TUid viewUid = view->ViewUid();
hgs
parents: 81
diff changeset
  1342
            
hgs
parents: 81
diff changeset
  1343
            // Remove from the view cycle list
hgs
parents: 81
diff changeset
  1344
            iViewInfoArray.Remove( position );
hgs
parents: 81
diff changeset
  1345
            
hgs
parents: 81
diff changeset
  1346
            RArray<TInt> hiddenViews;
hgs
parents: 81
diff changeset
  1347
            iCustomisationManager->GetHiddenViewIdL(pluginUid, hiddenViews);
hgs
parents: 81
diff changeset
  1348
            
hgs
parents: 81
diff changeset
  1349
            if( viewUid == activeViewUid )
hgs
parents: 81
diff changeset
  1350
                {
hgs
parents: 81
diff changeset
  1351
                // Removing the active view is done in three parts
hgs
parents: 81
diff changeset
  1352
                // 1) It is removed from the viewInfo list
hgs
parents: 81
diff changeset
  1353
                // 2) When settings is closed, the view is switched
hgs
parents: 81
diff changeset
  1354
                // to the next view in the view cycle list.
hgs
parents: 81
diff changeset
  1355
                // 3) When the view is deactivated it can be deleted.
hgs
parents: 81
diff changeset
  1356
                
hgs
parents: 81
diff changeset
  1357
                // Store the information about the current view.
hgs
parents: 81
diff changeset
  1358
                iRemovedActiveView = view;
hgs
parents: 81
diff changeset
  1359
                
hgs
parents: 81
diff changeset
  1360
                // Update the view cycle index so that hidden view is launched while cycling next view
hgs
parents: 81
diff changeset
  1361
                if(hiddenViews.Count())
hgs
parents: 81
diff changeset
  1362
                    {
hgs
parents: 81
diff changeset
  1363
                    // Find the index of teh hidden view
hgs
parents: 81
diff changeset
  1364
                    TInt viewInfoIndex = iViewInfoArray.Find(TUid::Uid(hiddenViews[0]), CCalenViewInfo::ViewInfoIdentifier);
hgs
parents: 81
diff changeset
  1365
                    iViewCycleIndex = viewInfoIndex - 1;  // Decrementing it as CycleNextView() funciton will increment it   
hgs
parents: 81
diff changeset
  1366
                    }
hgs
parents: 81
diff changeset
  1367
                else if(!alreadySet)
hgs
parents: 81
diff changeset
  1368
                    {
hgs
parents: 81
diff changeset
  1369
                    TInt nextViewCycleIndex = iViewCycleIndex - 1; // To update the view cycle index in plugin disable case
hgs
parents: 81
diff changeset
  1370
            
hgs
parents: 81
diff changeset
  1371
                    // Update the view cycle index as iViewInfoArray would have changed
hgs
parents: 81
diff changeset
  1372
                    iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier ); 
hgs
parents: 81
diff changeset
  1373
                    
hgs
parents: 81
diff changeset
  1374
                    // If the current active view has been removed,
hgs
parents: 81
diff changeset
  1375
                    if(iViewCycleIndex == -1)
hgs
parents: 81
diff changeset
  1376
                        {
hgs
parents: 81
diff changeset
  1377
                            iViewCycleIndex = nextViewCycleIndex;
hgs
parents: 81
diff changeset
  1378
                        } 
hgs
parents: 81
diff changeset
  1379
                    alreadySet = ETrue;
hgs
parents: 81
diff changeset
  1380
                    }
hgs
parents: 81
diff changeset
  1381
                
hgs
parents: 81
diff changeset
  1382
                hiddenViews.Reset();
hgs
parents: 81
diff changeset
  1383
                // Remove the plugin from the disabled plugin list
hgs
parents: 81
diff changeset
  1384
                // to stop the plugin being deleted.
hgs
parents: 81
diff changeset
  1385
                aDisabledPlugins.Remove( index );
hgs
parents: 81
diff changeset
  1386
                }
hgs
parents: 81
diff changeset
  1387
            else
hgs
parents: 81
diff changeset
  1388
                {
hgs
parents: 81
diff changeset
  1389
                // The view isn't the current view, so we
hgs
parents: 81
diff changeset
  1390
                // can remove it directly from the view server
hgs
parents: 81
diff changeset
  1391
                iAppUi.RemoveView( viewUid );
45
hgs
parents: 23
diff changeset
  1392
89
hgs
parents: 81
diff changeset
  1393
                // Delete the view info
hgs
parents: 81
diff changeset
  1394
                delete view;
hgs
parents: 81
diff changeset
  1395
                if(!alreadySet)
hgs
parents: 81
diff changeset
  1396
                    {
hgs
parents: 81
diff changeset
  1397
	                TInt nextViewCycleIndex = iViewCycleIndex - 1; // To update the view cycle index in plugin disable case
hgs
parents: 81
diff changeset
  1398
                        
hgs
parents: 81
diff changeset
  1399
	                // Update the view cycle index as iViewInfoArray would have changed
hgs
parents: 81
diff changeset
  1400
	                iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier ); 
hgs
parents: 81
diff changeset
  1401
                
hgs
parents: 81
diff changeset
  1402
	                // If the current active view has been removed,
hgs
parents: 81
diff changeset
  1403
	                if(iViewCycleIndex == -1)
hgs
parents: 81
diff changeset
  1404
	                    {
hgs
parents: 81
diff changeset
  1405
	                        iViewCycleIndex = nextViewCycleIndex;
hgs
parents: 81
diff changeset
  1406
	                    }
hgs
parents: 81
diff changeset
  1407
	                alreadySet = ETrue;
hgs
parents: 81
diff changeset
  1408
                    }
hgs
parents: 81
diff changeset
  1409
               
hgs
parents: 81
diff changeset
  1410
                }
hgs
parents: 81
diff changeset
  1411
                
hgs
parents: 81
diff changeset
  1412
            position = iViewInfoArray.Find( pluginUid, 
hgs
parents: 81
diff changeset
  1413
                                        CCalenViewInfo::ViewPluginIdentifier );
hgs
parents: 81
diff changeset
  1414
            }
hgs
parents: 81
diff changeset
  1415
        }
hgs
parents: 81
diff changeset
  1416
        
hgs
parents: 81
diff changeset
  1417
    // Unload the disabled plugins
hgs
parents: 81
diff changeset
  1418
    iCustomisationManager->UnloadPluginsL( aDisabledPlugins );
hgs
parents: 81
diff changeset
  1419
        
hgs
parents: 81
diff changeset
  1420
    CleanupStack::PopAndDestroy(); // removedViews
hgs
parents: 81
diff changeset
  1421
    
hgs
parents: 81
diff changeset
  1422
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1423
    }
hgs
parents: 81
diff changeset
  1424
    
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1425
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1426
// CCalenViewManager::ToolbarOrNull
hgs
parents: 81
diff changeset
  1427
// Provides access to the calendar toolbar if one is available
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1428
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1429
MCalenToolbar* CCalenViewManager::ToolbarOrNull()
hgs
parents: 81
diff changeset
  1430
    {
hgs
parents: 81
diff changeset
  1431
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1432
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1433
    if (iToolbar)
hgs
parents: 81
diff changeset
  1434
        {
hgs
parents: 81
diff changeset
  1435
        if (iToolbar->IsICalenToolBar())
hgs
parents: 81
diff changeset
  1436
            {
hgs
parents: 81
diff changeset
  1437
            return iToolbar;
hgs
parents: 81
diff changeset
  1438
            }
hgs
parents: 81
diff changeset
  1439
        }
hgs
parents: 81
diff changeset
  1440
    return NULL;
hgs
parents: 81
diff changeset
  1441
    }        
51
hgs
parents: 45
diff changeset
  1442
    
89
hgs
parents: 81
diff changeset
  1443
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1444
// CCalenViewManager::ViewsActivated
hgs
parents: 81
diff changeset
  1445
// Returns if the first view activation on start-up has taken place
hgs
parents: 81
diff changeset
  1446
// ----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1447
TBool CCalenViewManager::ViewsActivated() const
hgs
parents: 81
diff changeset
  1448
    {
hgs
parents: 81
diff changeset
  1449
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1450
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1451
    return iViewsActivated;
hgs
parents: 81
diff changeset
  1452
    }
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1453
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1454
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1455
// CCalenViewManager::UpdateToolbarNextViewIconL
hgs
parents: 81
diff changeset
  1456
// Updates the nextview icon on the toolbar when default view is not month view
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1457
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1458
void CCalenViewManager::UpdateToolbarNextViewIconL(TUid aViewUid)
hgs
parents: 81
diff changeset
  1459
	{
hgs
parents: 81
diff changeset
  1460
	// Set the view cycle index based on the newly activated view,
hgs
parents: 81
diff changeset
  1461
    // if the view is in the cycle array.
hgs
parents: 81
diff changeset
  1462
    TInt index = iViewInfoArray.Find( aViewUid, CCalenViewInfo::ViewInfoIdentifier );
hgs
parents: 81
diff changeset
  1463
    if( index != KErrNotFound )
hgs
parents: 81
diff changeset
  1464
        {
hgs
parents: 81
diff changeset
  1465
        iViewCycleIndex = index;
hgs
parents: 81
diff changeset
  1466
        if( iToolbar )
hgs
parents: 81
diff changeset
  1467
            {
hgs
parents: 81
diff changeset
  1468
            TInt nextVwIndex = iViewCycleIndex;
hgs
parents: 81
diff changeset
  1469
            do{
hgs
parents: 81
diff changeset
  1470
               nextVwIndex = ( nextVwIndex + 1 )%(iViewInfoArray.Count());
hgs
parents: 81
diff changeset
  1471
              }
hgs
parents: 81
diff changeset
  1472
            while( iViewInfoArray[nextVwIndex]->CyclePosition() == CCalenView::ENoCyclePosition );
hgs
parents: 81
diff changeset
  1473
            
hgs
parents: 81
diff changeset
  1474
            CCalenView* nextview = static_cast<CCalenView*>( 
hgs
parents: 81
diff changeset
  1475
                                        iAppUi.View( iViewInfoArray[nextVwIndex]->ViewUid() ) );
hgs
parents: 81
diff changeset
  1476
            iToolbar->SetNextViewIcon( nextview->ViewIconL() );
hgs
parents: 81
diff changeset
  1477
            }
hgs
parents: 81
diff changeset
  1478
        }
55
hgs
parents: 51
diff changeset
  1479
	}
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1480
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1481
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1482
// CCalenViewManager::HandleFasterAppExitCommandL
hgs
parents: 81
diff changeset
  1483
// Handles ECalenFasterAppExit command
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1484
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1485
void CCalenViewManager::HandleFasterAppExitCommandL()
hgs
parents: 81
diff changeset
  1486
    {
hgs
parents: 81
diff changeset
  1487
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1488
    
hgs
parents: 81
diff changeset
  1489
    if(iToolbar)
hgs
parents: 81
diff changeset
  1490
        {
hgs
parents: 81
diff changeset
  1491
        iToolbar->SetToolbarExtensionFocus(EFalse);
hgs
parents: 81
diff changeset
  1492
        }
hgs
parents: 81
diff changeset
  1493
    
hgs
parents: 81
diff changeset
  1494
    // For Handling : When the default view is changed keeping that view open, 
hgs
parents: 81
diff changeset
  1495
    // from day view changing the default view from month view to day view, 
hgs
parents: 81
diff changeset
  1496
    // we need to reset the previous view id.
hgs
parents: 81
diff changeset
  1497
    if(iPreviousToDayView.iViewUid!=KNullUid)
hgs
parents: 81
diff changeset
  1498
        {
hgs
parents: 81
diff changeset
  1499
        iPreviousToDayView.iViewUid = KNullUid;
hgs
parents: 81
diff changeset
  1500
        }
hgs
parents: 81
diff changeset
  1501
    
hgs
parents: 81
diff changeset
  1502
    // For handling specific case::Calendar exited from FSW 
hgs
parents: 81
diff changeset
  1503
    // iAvoidRepopulation is set when app backgrounded.
hgs
parents: 81
diff changeset
  1504
    // Reset the flag for activating the view in background
hgs
parents: 81
diff changeset
  1505
    if(iAvoidRepopulation)
hgs
parents: 81
diff changeset
  1506
        {
hgs
parents: 81
diff changeset
  1507
        iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
  1508
        }
hgs
parents: 81
diff changeset
  1509
    
hgs
parents: 81
diff changeset
  1510
    // In case of fasterapp exit, first activate the dummy view before deleting the plugin views
hgs
parents: 81
diff changeset
  1511
    // Get the default view before we remove plugins
hgs
parents: 81
diff changeset
  1512
    iPreviousViewId.iViewUid = KNullUid;
hgs
parents: 81
diff changeset
  1513
    
hgs
parents: 81
diff changeset
  1514
    iController.SetExitOnDialogFlag( EFalse ); // for making iisexitondialogclose EFalse.
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1515
89
hgs
parents: 81
diff changeset
  1516
    TUid defView = iSetting->DefaultView();
hgs
parents: 81
diff changeset
  1517
   
hgs
parents: 81
diff changeset
  1518
    // unload all plugins
hgs
parents: 81
diff changeset
  1519
    iCustomisationManager->DisableAllPluginsL();
hgs
parents: 81
diff changeset
  1520
    ActivateViewOnFakeExitL(defView);
hgs
parents: 81
diff changeset
  1521
    // Though the current view is active view, there is no need to issue a callback as we are exiting the whole application.
hgs
parents: 81
diff changeset
  1522
    if( iRemovedActiveView )
hgs
parents: 81
diff changeset
  1523
        {
hgs
parents: 81
diff changeset
  1524
        
hgs
parents: 81
diff changeset
  1525
        if( !iViewRemovalCallback )
hgs
parents: 81
diff changeset
  1526
            {
hgs
parents: 81
diff changeset
  1527
            TCallBack callback( RemoveDeActivatedView, this );
hgs
parents: 81
diff changeset
  1528
            iViewRemovalCallback = new( ELeave ) CAsyncCallBack( callback,
hgs
parents: 81
diff changeset
  1529
                                                    CActive::EPriorityStandard );
hgs
parents: 81
diff changeset
  1530
            }
hgs
parents: 81
diff changeset
  1531
        iViewRemovalCallback->CallBack();
hgs
parents: 81
diff changeset
  1532
        }
hgs
parents: 81
diff changeset
  1533
hgs
parents: 81
diff changeset
  1534
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1535
    }
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1536
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1537
// CCalenViewManager::HandleSettingsChangeNotificationL
hgs
parents: 81
diff changeset
  1538
// Handles ECalenNotifySettingsChanged notification
18
c198609911f9 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1539
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1540
void CCalenViewManager::HandleSettingsChangeNotificationL()
hgs
parents: 81
diff changeset
  1541
    {
hgs
parents: 81
diff changeset
  1542
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1543
    
hgs
parents: 81
diff changeset
  1544
    if( iController.IsFasterAppFlagEnabled() )
hgs
parents: 81
diff changeset
  1545
        {
hgs
parents: 81
diff changeset
  1546
        TUid newViewUid = iSetting->DefaultView();
hgs
parents: 81
diff changeset
  1547
        if(IsNativeView(newViewUid))
hgs
parents: 81
diff changeset
  1548
            {
hgs
parents: 81
diff changeset
  1549
            TUid oldViewUid = CurrentView();
hgs
parents: 81
diff changeset
  1550
            if( newViewUid.iUid != oldViewUid.iUid )
hgs
parents: 81
diff changeset
  1551
                {
hgs
parents: 81
diff changeset
  1552
                RequestActivationL( newViewUid );
hgs
parents: 81
diff changeset
  1553
                }
hgs
parents: 81
diff changeset
  1554
            }
hgs
parents: 81
diff changeset
  1555
        
hgs
parents: 81
diff changeset
  1556
        // If the plugins are activated using general settings.
hgs
parents: 81
diff changeset
  1557
        // unload all plugins.Only load the plugins when application
hgs
parents: 81
diff changeset
  1558
        // comes to foreground
hgs
parents: 81
diff changeset
  1559
        const RArray<TUid>& plugins = CustomisationManager().ActivePlugins();
hgs
parents: 81
diff changeset
  1560
        if(plugins.Count())
hgs
parents: 81
diff changeset
  1561
            {
hgs
parents: 81
diff changeset
  1562
            // unload all plugins
hgs
parents: 81
diff changeset
  1563
            iCustomisationManager->DisableAllPluginsL();
hgs
parents: 81
diff changeset
  1564
            }
hgs
parents: 81
diff changeset
  1565
        }
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1566
89
hgs
parents: 81
diff changeset
  1567
    if( iRemovedActiveView )
hgs
parents: 81
diff changeset
  1568
        {
hgs
parents: 81
diff changeset
  1569
        // If the active view has been disabled, the next view in 
hgs
parents: 81
diff changeset
  1570
        // the view cycle list is activated and the current view
hgs
parents: 81
diff changeset
  1571
        // is removed asyncronously.
hgs
parents: 81
diff changeset
  1572
        CycleNextViewL();
45
hgs
parents: 23
diff changeset
  1573
89
hgs
parents: 81
diff changeset
  1574
        if( !iViewRemovalCallback )
hgs
parents: 81
diff changeset
  1575
            {
hgs
parents: 81
diff changeset
  1576
            TCallBack callback( RemoveDeActivatedView, this );
hgs
parents: 81
diff changeset
  1577
            iViewRemovalCallback = new( ELeave ) CAsyncCallBack( callback,
hgs
parents: 81
diff changeset
  1578
                                                    CActive::EPriorityStandard );
hgs
parents: 81
diff changeset
  1579
            }
hgs
parents: 81
diff changeset
  1580
    
hgs
parents: 81
diff changeset
  1581
        iViewRemovalCallback->CallBack();
hgs
parents: 81
diff changeset
  1582
        }
hgs
parents: 81
diff changeset
  1583
    else if(iCustomisationManager->HiddenView(iCurrentViewId.iViewUid))
hgs
parents: 81
diff changeset
  1584
         {
hgs
parents: 81
diff changeset
  1585
         // Get the uid of the plugin view that is hiding the current view
hgs
parents: 81
diff changeset
  1586
         TUid viewUid = iCustomisationManager->GetReplacePluginViewIdL(iCurrentViewId.iViewUid);
hgs
parents: 81
diff changeset
  1587
             
hgs
parents: 81
diff changeset
  1588
         // update the view cycle index before activating the plugin view
hgs
parents: 81
diff changeset
  1589
         iViewCycleIndex = iViewInfoArray.Find( viewUid, 
hgs
parents: 81
diff changeset
  1590
                                    CCalenViewInfo::ViewInfoIdentifier );
hgs
parents: 81
diff changeset
  1591
         RequestActivationL(viewUid);
hgs
parents: 81
diff changeset
  1592
         }
hgs
parents: 81
diff changeset
  1593
   else
hgs
parents: 81
diff changeset
  1594
        {
hgs
parents: 81
diff changeset
  1595
        StartActiveStepL();
hgs
parents: 81
diff changeset
  1596
        }
hgs
parents: 81
diff changeset
  1597
    
hgs
parents: 81
diff changeset
  1598
    TRACE_EXIT_POINT;
45
hgs
parents: 23
diff changeset
  1599
    }
hgs
parents: 23
diff changeset
  1600
hgs
parents: 23
diff changeset
  1601
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1602
// CCalenViewManager::HandleEntryDeleteNotificationL
hgs
parents: 81
diff changeset
  1603
// Handles ECalenNotifyEntryDeleted and ECalenNotifyInstanceDeleted
hgs
parents: 81
diff changeset
  1604
// notifications
45
hgs
parents: 23
diff changeset
  1605
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1606
void CCalenViewManager::HandleEntryDeleteNotificationL()
hgs
parents: 81
diff changeset
  1607
    {
hgs
parents: 81
diff changeset
  1608
    TRACE_ENTRY_POINT;
51
hgs
parents: 45
diff changeset
  1609
    
89
hgs
parents: 81
diff changeset
  1610
    if(iCurrentViewId.iViewUid == KUidCalenEventView)   
hgs
parents: 81
diff changeset
  1611
        {
hgs
parents: 81
diff changeset
  1612
        // Activate the previous view when an event is deleted from
hgs
parents: 81
diff changeset
  1613
        // the event view 
hgs
parents: 81
diff changeset
  1614
        if(iPreviousViewId.iViewUid != KNullUid)
hgs
parents: 81
diff changeset
  1615
            {
hgs
parents: 81
diff changeset
  1616
            if(iPreviousToDayView.iViewUid != KNullUid)
hgs
parents: 81
diff changeset
  1617
                {
hgs
parents: 81
diff changeset
  1618
                RequestActivationL(iPreviousViewId.iViewUid, KUidCalenShowBackCba);
hgs
parents: 81
diff changeset
  1619
                }
hgs
parents: 81
diff changeset
  1620
            else
hgs
parents: 81
diff changeset
  1621
                {
hgs
parents: 81
diff changeset
  1622
                RequestActivationL(iPreviousViewId.iViewUid);
hgs
parents: 81
diff changeset
  1623
                }
hgs
parents: 81
diff changeset
  1624
            }
hgs
parents: 81
diff changeset
  1625
        }
hgs
parents: 81
diff changeset
  1626
    else
hgs
parents: 81
diff changeset
  1627
        {
hgs
parents: 81
diff changeset
  1628
        // refresh the current view
hgs
parents: 81
diff changeset
  1629
        StartActiveStepL();             
hgs
parents: 81
diff changeset
  1630
        }
hgs
parents: 81
diff changeset
  1631
    
hgs
parents: 81
diff changeset
  1632
    TRACE_EXIT_POINT;
64
1881ad52dc45 201033_03
hgs
parents: 63
diff changeset
  1633
    }
45
hgs
parents: 23
diff changeset
  1634
hgs
parents: 23
diff changeset
  1635
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1636
// CCalenViewManager::HandleEntryClosedNotificationL
hgs
parents: 81
diff changeset
  1637
// Handles ECalenNotifyEntryClosed notification
45
hgs
parents: 23
diff changeset
  1638
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1639
void CCalenViewManager::HandleEntryClosedNotificationL()
hgs
parents: 81
diff changeset
  1640
    {
hgs
parents: 81
diff changeset
  1641
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1642
	
hgs
parents: 81
diff changeset
  1643
	// reset tha flag iAvoidRepopulation to refresh the view.
hgs
parents: 81
diff changeset
  1644
	iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
  1645
    
hgs
parents: 81
diff changeset
  1646
    // if previous view is native view activate that view
hgs
parents: 81
diff changeset
  1647
    // otherwise commandlauncher will handle  
hgs
parents: 81
diff changeset
  1648
    if(iPreviousViewId.iViewUid != KNullUid)
hgs
parents: 81
diff changeset
  1649
        {
hgs
parents: 81
diff changeset
  1650
        // if iPreviousToDayView is active activate the day view with "Back" cba.
hgs
parents: 81
diff changeset
  1651
        if(iPreviousToDayView.iViewUid!=KNullUid)
hgs
parents: 81
diff changeset
  1652
            {
hgs
parents: 81
diff changeset
  1653
            RequestActivationL(iPreviousViewId.iViewUid, KUidCalenShowBackCba);
hgs
parents: 81
diff changeset
  1654
            }
hgs
parents: 81
diff changeset
  1655
        else
hgs
parents: 81
diff changeset
  1656
            {
hgs
parents: 81
diff changeset
  1657
            if( !iController.GetExitOnDialogFlag() )
hgs
parents: 81
diff changeset
  1658
                {
hgs
parents: 81
diff changeset
  1659
                RequestActivationL(iPreviousViewId.iViewUid);
hgs
parents: 81
diff changeset
  1660
                }
hgs
parents: 81
diff changeset
  1661
            }
hgs
parents: 81
diff changeset
  1662
        }
hgs
parents: 81
diff changeset
  1663
hgs
parents: 81
diff changeset
  1664
	// reset tha flag iAvoidRepopulation to avoid the repopulation.
hgs
parents: 81
diff changeset
  1665
	iAvoidRepopulation = ETrue;
hgs
parents: 81
diff changeset
  1666
    
hgs
parents: 81
diff changeset
  1667
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1668
    }
45
hgs
parents: 23
diff changeset
  1669
hgs
parents: 23
diff changeset
  1670
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1671
// CCalenViewManager::HandleSystemTimeChangeNotificationL
hgs
parents: 81
diff changeset
  1672
// Handles ECalenNotifySystemTimeChanged notification
55
hgs
parents: 51
diff changeset
  1673
// ----------------------------------------------------------------------------
89
hgs
parents: 81
diff changeset
  1674
void CCalenViewManager::HandleSystemTimeChangeNotificationL()
hgs
parents: 81
diff changeset
  1675
    {
hgs
parents: 81
diff changeset
  1676
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1677
    
hgs
parents: 81
diff changeset
  1678
        //Set the context whenever system time is changed
hgs
parents: 81
diff changeset
  1679
        TUid newViewUid = iSetting->DefaultView();
hgs
parents: 81
diff changeset
  1680
        MCalenContext& context = iController.Services().Context();
hgs
parents: 81
diff changeset
  1681
        TCalTime focusTime = context.DefaultCalTimeForViewsL();
hgs
parents: 81
diff changeset
  1682
        context.SetFocusDateAndTimeL( focusTime,
hgs
parents: 81
diff changeset
  1683
                                      TVwsViewId( KUidCalendar, newViewUid ));
hgs
parents: 81
diff changeset
  1684
    if( iController.IsFasterAppFlagEnabled() )
hgs
parents: 81
diff changeset
  1685
        {
hgs
parents: 81
diff changeset
  1686
        // reset tha flag iAvoidRepopulation to refresh the view whenever
hgs
parents: 81
diff changeset
  1687
        // system time is changed
hgs
parents: 81
diff changeset
  1688
        iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
  1689
        
hgs
parents: 81
diff changeset
  1690
        if(IsNativeView(newViewUid))
hgs
parents: 81
diff changeset
  1691
            {
hgs
parents: 81
diff changeset
  1692
            // activate the default view in background
hgs
parents: 81
diff changeset
  1693
            RequestActivationL( newViewUid );
hgs
parents: 81
diff changeset
  1694
            }
hgs
parents: 81
diff changeset
  1695
        
hgs
parents: 81
diff changeset
  1696
        // set the flag iAvoidRepopulation to avoid repopulation
hgs
parents: 81
diff changeset
  1697
        iAvoidRepopulation = ETrue;
hgs
parents: 81
diff changeset
  1698
        }
hgs
parents: 81
diff changeset
  1699
    else
hgs
parents: 81
diff changeset
  1700
        {
hgs
parents: 81
diff changeset
  1701
        // refresh the current view
hgs
parents: 81
diff changeset
  1702
        StartActiveStepL();
hgs
parents: 81
diff changeset
  1703
        }
hgs
parents: 81
diff changeset
  1704
    
hgs
parents: 81
diff changeset
  1705
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1706
    }
hgs
parents: 81
diff changeset
  1707
hgs
parents: 81
diff changeset
  1708
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1709
// CCalenViewManager::IconsL
hgs
parents: 81
diff changeset
  1710
// Create a CCalenIcons object if neccessary and return a reference
hgs
parents: 81
diff changeset
  1711
// (other items were commented in a header).
hgs
parents: 81
diff changeset
  1712
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1713
CCalenIcons& CCalenViewManager::IconsL()
hgs
parents: 81
diff changeset
  1714
    {
hgs
parents: 81
diff changeset
  1715
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1716
hgs
parents: 81
diff changeset
  1717
    if (!iIcons)
hgs
parents: 81
diff changeset
  1718
        {
hgs
parents: 81
diff changeset
  1719
        // Icons
hgs
parents: 81
diff changeset
  1720
        iIcons = CCalenIcons::NewL();
hgs
parents: 81
diff changeset
  1721
        }
55
hgs
parents: 51
diff changeset
  1722
89
hgs
parents: 81
diff changeset
  1723
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1724
    return *iIcons;
hgs
parents: 81
diff changeset
  1725
    }
hgs
parents: 81
diff changeset
  1726
hgs
parents: 81
diff changeset
  1727
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1728
// CCalenViewManager::GetNextViewIconL
hgs
parents: 81
diff changeset
  1729
// Gets next view icon 
hgs
parents: 81
diff changeset
  1730
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1731
CGulIcon* CCalenViewManager::GetNextViewIconL()
hgs
parents: 81
diff changeset
  1732
    {
hgs
parents: 81
diff changeset
  1733
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1734
    
hgs
parents: 81
diff changeset
  1735
    // Set the view cycle index based on the newly activated view,
hgs
parents: 81
diff changeset
  1736
    // if the view is in the cycle array.
hgs
parents: 81
diff changeset
  1737
    TInt index = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier );
hgs
parents: 81
diff changeset
  1738
    if( index != KErrNotFound )
hgs
parents: 81
diff changeset
  1739
        {
hgs
parents: 81
diff changeset
  1740
        iViewCycleIndex = index;
hgs
parents: 81
diff changeset
  1741
        TInt nextVwIndex = iViewCycleIndex;
hgs
parents: 81
diff changeset
  1742
        do
hgs
parents: 81
diff changeset
  1743
            {
hgs
parents: 81
diff changeset
  1744
            nextVwIndex = ( nextVwIndex + 1 )%(iViewInfoArray.Count());
hgs
parents: 81
diff changeset
  1745
            }while( iViewInfoArray[nextVwIndex]->CyclePosition() == CCalenView::ENoCyclePosition );
hgs
parents: 81
diff changeset
  1746
        
hgs
parents: 81
diff changeset
  1747
        // Get the next view icon
hgs
parents: 81
diff changeset
  1748
        CCalenView* nextview = static_cast<CCalenView*>( iAppUi.View( iViewInfoArray[nextVwIndex]->ViewUid() ) );
hgs
parents: 81
diff changeset
  1749
        return( nextview->ViewIconL() );
55
hgs
parents: 51
diff changeset
  1750
        }
89
hgs
parents: 81
diff changeset
  1751
             
hgs
parents: 81
diff changeset
  1752
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1753
    return NULL;
hgs
parents: 81
diff changeset
  1754
    }
hgs
parents: 81
diff changeset
  1755
hgs
parents: 81
diff changeset
  1756
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1757
// CCalenViewManager::SetRepopulation
hgs
parents: 81
diff changeset
  1758
// Resets the flag iAvoidRepopulation to activate the view.
hgs
parents: 81
diff changeset
  1759
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1760
void CCalenViewManager::SetRepopulation(TBool aRePopulate)
hgs
parents: 81
diff changeset
  1761
    {
hgs
parents: 81
diff changeset
  1762
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1763
    // to prevent the display of blank view, 
hgs
parents: 81
diff changeset
  1764
    // set the iAvoidRepopulation to EFalse, 
hgs
parents: 81
diff changeset
  1765
    // so that view is populated properly
hgs
parents: 81
diff changeset
  1766
    
hgs
parents: 81
diff changeset
  1767
    iAvoidRepopulation = aRePopulate;
hgs
parents: 81
diff changeset
  1768
    
hgs
parents: 81
diff changeset
  1769
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1770
    }
hgs
parents: 81
diff changeset
  1771
hgs
parents: 81
diff changeset
  1772
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1773
// CCalenViewManager::CalenToolbar
hgs
parents: 81
diff changeset
  1774
// Returns calendar toolbar
hgs
parents: 81
diff changeset
  1775
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1776
CCalenToolbarImpl* CCalenViewManager::CalenToolbar()
hgs
parents: 81
diff changeset
  1777
    {
hgs
parents: 81
diff changeset
  1778
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1779
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1780
    return iToolbar;
55
hgs
parents: 51
diff changeset
  1781
    }
hgs
parents: 51
diff changeset
  1782
89
hgs
parents: 81
diff changeset
  1783
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1784
// CCalenViewManager::ReloadAllPluginsL
hgs
parents: 81
diff changeset
  1785
// Reload all plugins
hgs
parents: 81
diff changeset
  1786
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1787
void CCalenViewManager::ReloadAllPluginsL()
hgs
parents: 81
diff changeset
  1788
    {
hgs
parents: 81
diff changeset
  1789
    TRACE_ENTRY_POINT;
51
hgs
parents: 45
diff changeset
  1790
    
89
hgs
parents: 81
diff changeset
  1791
    // load all plugins
hgs
parents: 81
diff changeset
  1792
    iCustomisationManager->DoPluginLoadingL();
hgs
parents: 81
diff changeset
  1793
    UpdatePluginListL();
45
hgs
parents: 23
diff changeset
  1794
    
89
hgs
parents: 81
diff changeset
  1795
    // only activate plugin view if it is default view
hgs
parents: 81
diff changeset
  1796
    TUid defaultViewUid = iSetting->DefaultView();
hgs
parents: 81
diff changeset
  1797
    if(!IsNativeView(defaultViewUid))
hgs
parents: 81
diff changeset
  1798
        {
hgs
parents: 81
diff changeset
  1799
        iAvoidRepopulation = EFalse;
hgs
parents: 81
diff changeset
  1800
                
hgs
parents: 81
diff changeset
  1801
        // Find the default view in the view cycle list
hgs
parents: 81
diff changeset
  1802
        TInt position = iViewInfoArray.Find(
hgs
parents: 81
diff changeset
  1803
                defaultViewUid, CCalenViewInfo::ViewInfoIdentifier );
hgs
parents: 81
diff changeset
  1804
        if( position != KErrNotFound )
hgs
parents: 81
diff changeset
  1805
            {
hgs
parents: 81
diff changeset
  1806
            TVwsViewId targetViewId( KUidCalendar, defaultViewUid);
hgs
parents: 81
diff changeset
  1807
            RequestActivationL(targetViewId);
hgs
parents: 81
diff changeset
  1808
            iViewCycleIndex = position;
hgs
parents: 81
diff changeset
  1809
            }
hgs
parents: 81
diff changeset
  1810
        else
hgs
parents: 81
diff changeset
  1811
            {
hgs
parents: 81
diff changeset
  1812
            // if plugin providing default view is already uninstalled
hgs
parents: 81
diff changeset
  1813
            // activate month view as default view
hgs
parents: 81
diff changeset
  1814
            CRepository* repository = CRepository::NewL( KCRUidCalendar );
hgs
parents: 81
diff changeset
  1815
            CleanupStack::PushL(repository);
hgs
parents: 81
diff changeset
  1816
            TInt tmp( static_cast<TInt>( KUidCalenMonthView.iUid ) );
hgs
parents: 81
diff changeset
  1817
            TInt position = iViewInfoArray.Find( KUidCalenMonthView, CCalenViewInfo::ViewInfoIdentifier );
hgs
parents: 81
diff changeset
  1818
            User::LeaveIfError( repository->Set( KCalendarDefaultStartView, tmp ) );
hgs
parents: 81
diff changeset
  1819
            iAppUi.SetDefaultViewL( *iAppUi.View( KUidCalenMonthView ) );
hgs
parents: 81
diff changeset
  1820
            TVwsViewId targetViewId( KUidCalendar, KUidCalenMonthView);
hgs
parents: 81
diff changeset
  1821
            RequestActivationL(targetViewId);
hgs
parents: 81
diff changeset
  1822
            iViewCycleIndex = position;
hgs
parents: 81
diff changeset
  1823
            CleanupStack::PopAndDestroy(repository);  
hgs
parents: 81
diff changeset
  1824
            }
hgs
parents: 81
diff changeset
  1825
        }
hgs
parents: 81
diff changeset
  1826
    
hgs
parents: 81
diff changeset
  1827
    TRACE_EXIT_POINT;
45
hgs
parents: 23
diff changeset
  1828
    }
0
f979ecb2b13e Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1829
89
hgs
parents: 81
diff changeset
  1830
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1831
// CCalenViewManager::GetPreviousViewUid
hgs
parents: 81
diff changeset
  1832
// Rest of the details are commented in header.
hgs
parents: 81
diff changeset
  1833
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1834
TUid CCalenViewManager::GetPreviousViewUid()
hgs
parents: 81
diff changeset
  1835
    {
hgs
parents: 81
diff changeset
  1836
    return iPreviousViewId.iViewUid;
hgs
parents: 81
diff changeset
  1837
    }
63
hgs
parents: 57
diff changeset
  1838
89
hgs
parents: 81
diff changeset
  1839
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1840
// CCalenViewManager::SetPreviousViewUid
hgs
parents: 81
diff changeset
  1841
// Rest of the details are commented in header.
hgs
parents: 81
diff changeset
  1842
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1843
void CCalenViewManager::SetPreviousViewUid(TUid aPreviousUid)
hgs
parents: 81
diff changeset
  1844
    {
hgs
parents: 81
diff changeset
  1845
    iPreviousViewId.iViewUid = aPreviousUid; 
63
hgs
parents: 57
diff changeset
  1846
    }
89
hgs
parents: 81
diff changeset
  1847
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1848
// CCalenViewManager::IsNativeView
hgs
parents: 81
diff changeset
  1849
// Check for native view
hgs
parents: 81
diff changeset
  1850
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1851
TBool CCalenViewManager::IsNativeView(TUid aViewUid)
hgs
parents: 81
diff changeset
  1852
    {
hgs
parents: 81
diff changeset
  1853
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1854
hgs
parents: 81
diff changeset
  1855
    if( (aViewUid == KUidCalenMonthView)||
hgs
parents: 81
diff changeset
  1856
        (aViewUid == KUidCalenWeekView) ||
hgs
parents: 81
diff changeset
  1857
        (aViewUid == KUidCalenDayView) ||
hgs
parents: 81
diff changeset
  1858
        (aViewUid == KUidCalenTodoView) )
hgs
parents: 81
diff changeset
  1859
        {
hgs
parents: 81
diff changeset
  1860
        TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1861
        return ETrue;
hgs
parents: 81
diff changeset
  1862
        }
hgs
parents: 81
diff changeset
  1863
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1864
    return EFalse;
hgs
parents: 81
diff changeset
  1865
    }
63
hgs
parents: 57
diff changeset
  1866
89
hgs
parents: 81
diff changeset
  1867
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1868
// CCalenViewManager::ActivateViewOnFakeExitL
hgs
parents: 81
diff changeset
  1869
// Check for native view
hgs
parents: 81
diff changeset
  1870
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1871
void CCalenViewManager::ActivateViewOnFakeExitL(TUid aDefView)
hgs
parents: 81
diff changeset
  1872
    {
hgs
parents: 81
diff changeset
  1873
    TRACE_ENTRY_POINT;
hgs
parents: 81
diff changeset
  1874
    iFakeExit = ETrue;
hgs
parents: 81
diff changeset
  1875
    if(IsNativeView(aDefView))
hgs
parents: 81
diff changeset
  1876
        {
hgs
parents: 81
diff changeset
  1877
        // activate the view in background
hgs
parents: 81
diff changeset
  1878
        RequestActivationL( aDefView, KCalenHideInBackGround, KNullDesC8() );
hgs
parents: 81
diff changeset
  1879
        }
hgs
parents: 81
diff changeset
  1880
    else
hgs
parents: 81
diff changeset
  1881
        {
hgs
parents: 81
diff changeset
  1882
        RequestActivationL( KUidCalenDummyView, KCalenHideInBackGround, KNullDesC8() );
hgs
parents: 81
diff changeset
  1883
        }
hgs
parents: 81
diff changeset
  1884
    
hgs
parents: 81
diff changeset
  1885
    // set the flag to avoid repopulation when application is
hgs
parents: 81
diff changeset
  1886
    // opened after faster exit
hgs
parents: 81
diff changeset
  1887
    iAvoidRepopulation = ETrue;
hgs
parents: 81
diff changeset
  1888
    
hgs
parents: 81
diff changeset
  1889
    // set the context 
hgs
parents: 81
diff changeset
  1890
    MCalenContext& context = iController.Services().Context();
hgs
parents: 81
diff changeset
  1891
    TCalTime focusTime = context.DefaultCalTimeForViewsL();
hgs
parents: 81
diff changeset
  1892
    context.SetFocusDateAndTimeL( focusTime,
hgs
parents: 81
diff changeset
  1893
                                  TVwsViewId( KUidCalendar, aDefView) );
hgs
parents: 81
diff changeset
  1894
    
hgs
parents: 81
diff changeset
  1895
    TRACE_EXIT_POINT;
hgs
parents: 81
diff changeset
  1896
    }
63
hgs
parents: 57
diff changeset
  1897
89
hgs
parents: 81
diff changeset
  1898
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1899
// CCalenViewManager::ActivateLocalViewL
hgs
parents: 81
diff changeset
  1900
// Activate the local view if application already in back ground
hgs
parents: 81
diff changeset
  1901
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1902
void CCalenViewManager::ActivateLocalViewL(TUid aDefView)
hgs
parents: 81
diff changeset
  1903
    {
hgs
parents: 81
diff changeset
  1904
    iAppUi.ActivateLocalViewL( aDefView );      
hgs
parents: 81
diff changeset
  1905
    }
63
hgs
parents: 57
diff changeset
  1906
89
hgs
parents: 81
diff changeset
  1907
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1908
// CCalenViewManager::ChangeDayL
hgs
parents: 81
diff changeset
  1909
// Change day when preview pane swipped
hgs
parents: 81
diff changeset
  1910
// -----------------------------------------------------------------------------
hgs
parents: 81
diff changeset
  1911
void CCalenViewManager::ChangeDayL( TBool aNextDay )
hgs
parents: 81
diff changeset
  1912
    {
hgs
parents: 81
diff changeset
  1913
    TInt aInterval(1);
hgs
parents: 81
diff changeset
  1914
    MCalenContext& context = iController.Services().Context();
hgs
parents: 81
diff changeset
  1915
    TCalTime focusedTime = context.FocusDateAndTimeL();
hgs
parents: 81
diff changeset
  1916
    TTime newDay(0);
hgs
parents: 81
diff changeset
  1917
    if ( aNextDay )
hgs
parents: 81
diff changeset
  1918
        {
hgs
parents: 81
diff changeset
  1919
        newDay = focusedTime.TimeLocalL() + TTimeIntervalDays( aInterval );
hgs
parents: 81
diff changeset
  1920
        }
hgs
parents: 81
diff changeset
  1921
    else
hgs
parents: 81
diff changeset
  1922
        {
hgs
parents: 81
diff changeset
  1923
        newDay = focusedTime.TimeLocalL() - TTimeIntervalDays( aInterval );
hgs
parents: 81
diff changeset
  1924
        }     
hgs
parents: 81
diff changeset
  1925
    focusedTime.SetTimeLocalL( newDay );
hgs
parents: 81
diff changeset
  1926
    context.SetFocusDateAndTimeL( focusedTime,
hgs
parents: 81
diff changeset
  1927
            iCurrentViewId );                   
hgs
parents: 81
diff changeset
  1928
    }
63
hgs
parents: 57
diff changeset
  1929
89
hgs
parents: 81
diff changeset
  1930
// End of file