tstaskmonitor/backstepping/src/tsbackstepping.cpp
author hgs
Fri, 11 Jun 2010 16:13:51 +0300
changeset 98 d2f833ab7940
parent 96 5d243a69bdda
permissions -rw-r--r--
201023
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
96
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include <w32std.h>// key event
hgs
parents:
diff changeset
    19
#include <apgwgnam.h>// for CApaWindowGroupName
hgs
parents:
diff changeset
    20
#include <apgtask.h>
hgs
parents:
diff changeset
    21
#include <coedef.h>
hgs
parents:
diff changeset
    22
#include <f32file.h>
hgs
parents:
diff changeset
    23
#include <flogger.h>
hgs
parents:
diff changeset
    24
#include <e32property.h>
hgs
parents:
diff changeset
    25
#include <startupdomainpskeys.h>
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
#include "tsbackstepping.h"
hgs
parents:
diff changeset
    28
hgs
parents:
diff changeset
    29
const TUid KHSUid = {0x20022f35};
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
hgs
parents:
diff changeset
    32
/** 
hgs
parents:
diff changeset
    33
 *  CTsBackstepping::NewL
hgs
parents:
diff changeset
    34
 *  two phase constructor
hgs
parents:
diff changeset
    35
 */
98
hgs
parents: 96
diff changeset
    36
EXPORT_C CTsBackstepping* CTsBackstepping::NewL(MTsWindowGroupsMonitor &monitor)
96
hgs
parents:
diff changeset
    37
  {
hgs
parents:
diff changeset
    38
  RDebug::Print(_L("CTsBackstepping::NewL"));
98
hgs
parents: 96
diff changeset
    39
  CTsBackstepping* self = CTsBackstepping::NewLC(monitor);
96
hgs
parents:
diff changeset
    40
  CleanupStack::Pop(self);
hgs
parents:
diff changeset
    41
  return self;
hgs
parents:
diff changeset
    42
  }
hgs
parents:
diff changeset
    43
hgs
parents:
diff changeset
    44
/** 
hgs
parents:
diff changeset
    45
 *  CTsBackstepping::NewLC
hgs
parents:
diff changeset
    46
 *  two phase constructor
hgs
parents:
diff changeset
    47
 */
98
hgs
parents: 96
diff changeset
    48
EXPORT_C CTsBackstepping* CTsBackstepping::NewLC(MTsWindowGroupsMonitor &monitor)
96
hgs
parents:
diff changeset
    49
{ 
98
hgs
parents: 96
diff changeset
    50
  CTsBackstepping* self = new (ELeave) CTsBackstepping(monitor);
96
hgs
parents:
diff changeset
    51
  CleanupStack::PushL(self);
hgs
parents:
diff changeset
    52
  self->ConstructL();
hgs
parents:
diff changeset
    53
  return self;
hgs
parents:
diff changeset
    54
}
hgs
parents:
diff changeset
    55
hgs
parents:
diff changeset
    56
/** 
hgs
parents:
diff changeset
    57
 * CTsBackstepping::CTsBackstepping
hgs
parents:
diff changeset
    58
 * constructor
hgs
parents:
diff changeset
    59
 */
98
hgs
parents: 96
diff changeset
    60
CTsBackstepping::CTsBackstepping(MTsWindowGroupsMonitor &monitor)
hgs
parents: 96
diff changeset
    61
:
hgs
parents: 96
diff changeset
    62
CTsWindowGroupsObserver(monitor)
96
hgs
parents:
diff changeset
    63
{
hgs
parents:
diff changeset
    64
}
hgs
parents:
diff changeset
    65
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
/** 
hgs
parents:
diff changeset
    68
 *  CTsBackstepping::~CTsBackstepping
hgs
parents:
diff changeset
    69
 *  deconstructor
hgs
parents:
diff changeset
    70
 */
hgs
parents:
diff changeset
    71
EXPORT_C CTsBackstepping::~CTsBackstepping()
hgs
parents:
diff changeset
    72
{
hgs
parents:
diff changeset
    73
}
hgs
parents:
diff changeset
    74
hgs
parents:
diff changeset
    75
/** 
hgs
parents:
diff changeset
    76
 *  CTsBackstepping::ConstructL
hgs
parents:
diff changeset
    77
 *  two phase constructor
hgs
parents:
diff changeset
    78
 */
hgs
parents:
diff changeset
    79
void CTsBackstepping::ConstructL ()
hgs
parents:
diff changeset
    80
{
hgs
parents:
diff changeset
    81
    RDebug::Print(_L("CTsBackstepping::ConstructL"));
98
hgs
parents: 96
diff changeset
    82
    BaseConstructL();
96
hgs
parents:
diff changeset
    83
}
hgs
parents:
diff changeset
    84
hgs
parents:
diff changeset
    85
/** 
98
hgs
parents: 96
diff changeset
    86
 * CTsBackstepping::AnalyseWindowStackL
hgs
parents: 96
diff changeset
    87
 * Analyzes window stack and move homescreen to proper position
96
hgs
parents:
diff changeset
    88
 */
98
hgs
parents: 96
diff changeset
    89
void CTsBackstepping::HandleWindowGroupChanged(MTsResourceManager &resource, const TArray<RWsSession::TWindowGroupChainInfo> &windowGroups)
96
hgs
parents:
diff changeset
    90
{
98
hgs
parents: 96
diff changeset
    91
    TRAP_IGNORE(HandleWindowGroupChangedL(resource, windowGroups));
96
hgs
parents:
diff changeset
    92
}
hgs
parents:
diff changeset
    93
hgs
parents:
diff changeset
    94
/** 
hgs
parents:
diff changeset
    95
 * CTsBackstepping::AnalyseWindowStackL
hgs
parents:
diff changeset
    96
 * Analyzes window stack and move homescreen to proper position
hgs
parents:
diff changeset
    97
 */
98
hgs
parents: 96
diff changeset
    98
void CTsBackstepping::HandleWindowGroupChangedL(MTsResourceManager &resource,
hgs
parents: 96
diff changeset
    99
                                                const TArray<RWsSession::TWindowGroupChainInfo> &windowGroups)
96
hgs
parents:
diff changeset
   100
{  
hgs
parents:
diff changeset
   101
    RDebug::Print(_L("CTsBackstepping::GetWindowCaption"));
hgs
parents:
diff changeset
   102
    
98
hgs
parents: 96
diff changeset
   103
    CApaWindowGroupName *windowGroupName = CApaWindowGroupName::NewLC(resource.WsSession());
96
hgs
parents:
diff changeset
   104
    
hgs
parents:
diff changeset
   105
    TInt count(windowGroups.Count());
hgs
parents:
diff changeset
   106
    TInt pos(0);
hgs
parents:
diff changeset
   107
    TInt whereToJump(1);
hgs
parents:
diff changeset
   108
    for (TInt i=0; i<count; i++) {//iterate through list and give debug info
98
hgs
parents: 96
diff changeset
   109
        windowGroupName->ConstructFromWgIdL(windowGroups[i].iId);
96
hgs
parents:
diff changeset
   110
        if (windowGroupName->AppUid() != TUid::Null()) {
hgs
parents:
diff changeset
   111
            // find the window group id and check that it has no parent
98
hgs
parents: 96
diff changeset
   112
            if ( windowGroups[i].iParentId <= 0 ) {
hgs
parents: 96
diff changeset
   113
                RDebug::Print( _L("CTsBackstepping::GetWindowCaption wgid:%d is standalone view"), windowGroups[i].iId);
96
hgs
parents:
diff changeset
   114
                //check if it is homescreen 
hgs
parents:
diff changeset
   115
                if (windowGroupName->AppUid() == KHSUid) {
hgs
parents:
diff changeset
   116
                    RDebug::Print(_L("CTsBackstepping::GetWindowCaption Homescreen position = %d ; list:%d/%d"), pos, i, count);
hgs
parents:
diff changeset
   117
                    if (pos <= 1) {// HS is in foreground or second in line - do nothing 
hgs
parents:
diff changeset
   118
                        RDebug::Print(_L("CTsBackstepping::nothing to be done - it will stop checking here"));
hgs
parents:
diff changeset
   119
                    } else {//we should move homescreen to be second (ommit embeded views) from top
hgs
parents:
diff changeset
   120
                        RDebug::Print(_L("CTsBackstepping::moving homescreen to be second from top"));
hgs
parents:
diff changeset
   121
                        RDebug::Print(_L("CTsBackstepping::whereToJump = %d"), whereToJump);
98
hgs
parents: 96
diff changeset
   122
                        resource.WsSession().SetWindowGroupOrdinalPosition(windowGroups[i].iId, whereToJump);
96
hgs
parents:
diff changeset
   123
                    }
hgs
parents:
diff changeset
   124
                    // and break
hgs
parents:
diff changeset
   125
                    break;
hgs
parents:
diff changeset
   126
                }
hgs
parents:
diff changeset
   127
                pos++;
hgs
parents:
diff changeset
   128
            } else {
hgs
parents:
diff changeset
   129
                // only embeded items for first standalone launch should be counted
hgs
parents:
diff changeset
   130
                if (!pos) {
hgs
parents:
diff changeset
   131
                    ++whereToJump;
hgs
parents:
diff changeset
   132
                }
98
hgs
parents: 96
diff changeset
   133
                RDebug::Print(_L("CTsBackstepping::GetWindowCaption wgid:%d is embedded view"), windowGroups[i].iId);
96
hgs
parents:
diff changeset
   134
            }
hgs
parents:
diff changeset
   135
        }
hgs
parents:
diff changeset
   136
    }
hgs
parents:
diff changeset
   137
    CleanupStack::PopAndDestroy(windowGroupName);
hgs
parents:
diff changeset
   138
}
hgs
parents:
diff changeset
   139
hgs
parents:
diff changeset
   140
// end of file