vpnengine/eventmediator/src/eventmediator.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 14 Sep 2010 23:16:15 +0300
branchRCL_3
changeset 44 735de8341ce4
parent 0 33413c0669b9
child 49 5960d2d03390
permissions -rw-r--r--
Revision: 201033 Kit: 201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
33413c0669b9 Revision: 200949
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".
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:   This module contains eventmediator and the services of it.
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
/**  
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
 * @file eventmediator.cpp
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
 *
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
 * This module contains eventmediator and the services of it.
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
 *
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
 */
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include "eventmediator.h"
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    27
#include "eventmediatorsession.h"
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    28
#include "eventmediatorclientservercommon.h"
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include "eventlogger.h"
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include "sit.h"
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "log_em.h"
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    33
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#define FIRST_ARGUMENT 0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#define SECOND_ARGUMENT 1
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#define THIRD_ARGUMENT 2
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#define FOURTH_ARGUMENT 3
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    39
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
// ============================= CEventMediatorServer =============================
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
const TUint CEventMediatorServer::iRangeCount = 2;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
const TInt CEventMediatorServer::iRanges[iRangeCount] = 
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
    {
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    46
    KEventMediatorListen,
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    47
    KEventMediatorClearEventLog+1
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
    };
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
const TUint8 CEventMediatorServer::iElementIndex[iRangeCount] = 
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
    0,
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
    CPolicyServer::ENotSupported
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
    };
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
const CPolicyServer::TPolicyElement CEventMediatorServer::iElements[] =
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
    {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl), CPolicyServer::EFailClient},
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
    };
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
const CPolicyServer::TPolicy CEventMediatorServer::iPolicy =
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
    0,              // All connect attempts are checked
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
    iRangeCount,    // Count of ranges
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    iRanges,        // 0...9, 9...
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
    iElementIndex,  // Only range 1000-1008 are checked
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    iElements       // The list of policy elements
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
    };
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
CEventMediatorServer::CEventMediatorServer(void)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
    : CPolicyServer(EPriorityNormal,iPolicy), iStoredEvents(1)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
CEventMediatorServer* CEventMediatorServer::NewL()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
    LOG(Log::Printf(_L("CEventMediatorServer::NewL - begin\n")));
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    79
    
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    80
    CEventMediatorServer* self = CEventMediatorServer::NewLC();
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    81
    CleanupStack::Pop(self); // server
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    LOG(Log::Printf(_L("CEventMediatorServer::NewL - end\n")));
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    83
    
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    84
    return self;
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
CEventMediatorServer* CEventMediatorServer::NewLC()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    LOG(Log::Printf(_L("CEventMediatorServer::NewLC - begin\n")));
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    90
    
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    91
    CEventMediatorServer* self = new (ELeave) CEventMediatorServer();
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    92
    CleanupStack::PushL(self); 
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    93
    self->ConstructL();
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    94
    
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
    LOG(Log::Printf(_L("CEventMediatorServer::NewLC - end\n")));
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    96
    return self;
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    99
void CEventMediatorServer::ConstructL()
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    RFs fs;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
    User::LeaveIfError(fs.Connect());
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
    CleanupClosePushL(fs);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
    fs.CreatePrivatePath(EDriveC);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    TPath privateDir;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    User::LeaveIfError(fs.PrivatePath(privateDir));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    iEventLogFileName.Copy(privateDir);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    iEventLogFileName.Append(KEventLogFile);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    CleanupStack::PopAndDestroy(); // fs
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
    
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   114
    iLogger = CEventLogger::NewL(this);
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    iSit = new (ELeave) CSit(this);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
    StartL(KEventMediatorServer);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
CEventMediatorServer::~CEventMediatorServer(void)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    LOG(Log::Printf(_L("CEventMediatorServer::~CEventMediatorServer\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
    // Delete stored events
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
    TInt nEvents = this->iStoredEvents.Count();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
    for (TInt i = 0; i < nEvents; i++)  
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
        delete iStoredEvents.At(i)->iData;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
        delete iStoredEvents.At(i);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
    iStoredEvents.Delete(0, iStoredEvents.Count());
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
    // Delete log writer
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
    delete iLogger;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
    delete iSit;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
TInt CEventMediatorServer::RunError(TInt aError)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
    LOG(Log::Printf(_L("CEventMediatorServer::RunError - error = %d\n"), aError));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
    Message().Complete(aError);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
    // The leave will result in an early return from CServer::RunL(),
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
    // skipping the call to request another message. So we issue the
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
    // request here in order to keep the server running.
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    ReStart();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    // Handled the error fully
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
    return KErrNone;    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
// ----------------------------------------------------------------------------
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
// CEventMediatorServer::NewSessionL
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
// Creates a new session and returns the handle to the session.
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
// ----------------------------------------------------------------------------
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
//
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
CSession2* CEventMediatorServer::NewSessionL(
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    const TVersion& /*aVersion*/,
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    const RMessage2& aMessage) const
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    // New sessions are not accepted if the server is shutting down
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    // (it's just waiting for the last session (from SIT) to die)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
    if (iShuttingDown)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
        User::Leave(KErrServerTerminated);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   168
    
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   169
    CSession2* session = CEventMediatorSession::NewL(const_cast<CEventMediatorServer&>(*this), 
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   170
                                                     IsClientTheSitL(aMessage));
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   171
    iSessionCount++;
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
    return session;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   175
void CEventMediatorServer::SessionDeleted(TBool aIsSitSession)
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   176
    {
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   177
    TInt normalSessionCount = NormalSessionCount();
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   178
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   179
    // If this too is a normal session and is dying,
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   180
    // decrement the normal session count by one
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   181
    if (!aIsSitSession)
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   182
        {
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   183
        normalSessionCount--;        
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   184
        }
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   185
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   186
    if (normalSessionCount == 0)
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   187
        {
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   188
        // If "normal" (non-sit) sessions are no longer present,
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   189
        // we complete the task arrival observation request, thus
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   190
        // causing the SIT to terminate and close its connection
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   191
        // to this server. This should be the last connection whose
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   192
        // closing will cause this server to terminate.
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   193
        // NOTE. KErrCancel cannot be used here as the Event Mediator 
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   194
        // does not report it to the caller
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   195
        LOG(Log::Printf(_L("CEventMediatorServer::SessionDeleted - normal session count = 0\n")));
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   196
        CompleteListener(ETaskArrivedEvent, NULL, KErrAbort);
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   197
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   198
        // Set the server state to "shutting down". This will
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   199
        // cause the server to discard any new connect requests
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   200
        // with KErrServerTerminated.
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   201
        iShuttingDown = ETrue;
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   202
        }
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   203
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   204
    __ASSERT_DEBUG(iSessionCount > 0, User::Invariant());
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   205
    iSessionCount--;
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   206
    if (iSessionCount == 0) 
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   207
        {
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   208
        LOG(Log::Printf(_L("CEventMediatorServer::SessionDeleted - session count 0, stopping scheduler and thus the server\n")));
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   209
        CActiveScheduler::Stop();   
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   210
        }       
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   211
    }
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   212
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
void CEventMediatorServer::ReportEventL(const TEventType aType, TDesC8* aSpec,
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
                                        TDesC8* aData, TInt aStatus)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
    LOG(Log::Printf(_L("CEventMediatorServer::ReportEventL - event type = %d\n"), aType));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
    TInt listenerCount = 0;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
    CEventMediatorSession* session;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
    iSessionIter.SetToFirst();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
    session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
    while (session != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
        // Some listeners listen this event with specification
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
        listenerCount += session->CheckEventL(aType, aSpec, aData, aStatus); 
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
        // Some without specification, all events are good for them
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
        if (aSpec != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
            listenerCount += session->CheckEventL(aType, NULL, aData, aStatus);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
        session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    if (listenerCount)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
        // Need to save the event data as it may/will be fetched later
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
        TEventContainer* container = new (ELeave) TEventContainer(listenerCount, aData);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
        CleanupStack::PushL(container);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
        iStoredEvents.AppendL(container);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
        CleanupStack::Pop();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
        }
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   241
    
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
    // Write event to log
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   243
    __ASSERT_DEBUG(iLogger != NULL, User::Invariant());
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   244
    
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   245
    if (aType == ELogEvent)
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
        LOG(Log::Printf(_L("CEventMediatorServer::ReportEventL - calling iLogger->LogEvent\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
        iLogger->LogEvent(*aData);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
    // If there are no listeners, delete data
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
    if (listenerCount == 0)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
        delete aData;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
TInt CEventMediatorServer::CopyEventDataL(const RMessage2& aMessage)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
    TBool found = EFalse;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
    TInt i = 0;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
    TInt err = KErrNone;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
    while (!found && i < iStoredEvents.Count())
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
        if (iStoredEvents.At(i)->iData == aMessage.Ptr0())
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
            found = ETrue;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
        else
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
            i++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
    if (found)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
        aMessage.WriteL(SECOND_ARGUMENT, *(iStoredEvents.At(i)->iData));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
        MarkStoredEventListened(i);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
    else
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
        err = KErrNotFound;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
    return err;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
void CEventMediatorServer::MarkStoredEventListened(TInt aIndex)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
    iStoredEvents.At(aIndex)->iListenerCount--;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
    if (iStoredEvents.At(aIndex)->iListenerCount == 0)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
        delete iStoredEvents.At(aIndex)->iData;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
        delete iStoredEvents.At(aIndex);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
        iStoredEvents.Delete(aIndex);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   297
TBool CEventMediatorServer::IsClientTheSitL(const RMessage2& aMessage) const
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
    LOG(Log::Printf(_L("CEventMediatorServer::IsClientTheSitL\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    TBool isClientTheSit = EFalse;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    RThread clientThread;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
    User::LeaveIfError(aMessage.Client(clientThread));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    if (clientThread.Id() == iSit->ThreadId())
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
        LOG(Log::Printf(_L("CEventMediatorServer::IsClientTheSitL - YES\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
        isClientTheSit = ETrue;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
    clientThread.Close();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
    return isClientTheSit;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
void CEventMediatorServer::MakeSureSitIsRunningL()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
    LOG(Log::Printf(_L("CEventMediatorServer::MakeSureSitIsRunningL\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
    // If the SIT has not yet been started
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
    // or has died, try to start it
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
    iSit->StartL();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
void CEventMediatorServer::SetTaskArrivalListenerL(CListenerContainer* aListener)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
    LOG(Log::Printf(_L("CEventMediatorServer::SetTaskArrivalListenerL\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
    if (aListener)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
        // Task arrival observation requests must
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
        // come from the SIT
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
        if (!IsClientTheSitL(aListener->Message()))
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
            User::Leave(KErrNotSupported);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
        // Only one task arrival observation request
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
        // is allowed to be present at the same time
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
        if (iTaskArrivalListener && (aListener != iTaskArrivalListener))
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
            User::Leave(KErrNotSupported);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
    iTaskArrivalListener = aListener;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
void CEventMediatorServer::ClearTaskArrivalListener()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
    LOG(Log::Printf(_L("CEventMediatorServer::ClearTaskArrivalListener\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
    iTaskArrivalListener = NULL;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
CListenerContainer* CEventMediatorServer::TaskArrivalListener()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
    return iTaskArrivalListener;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
void CEventMediatorServer::TaskRequestArrivedL(CListenerContainer* aTaskRequest)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
    LOG(Log::Printf(_L("CEventMediatorServer::TaskRequestArrivedL\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
    CompleteTaskArrivalObservationRequestL(aTaskRequest->Type(), aTaskRequest->Specification());
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
void CEventMediatorServer::TaskArrivalObservationRequestArrivedL()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
    LOG(Log::Printf(_L("CEventMediatorServer::TaskArrivalObservationRequestArrivedL\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
    // Go through all pending event listening requests to see if any
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    // one of those should be passed to the SIT (i.e. if the task
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
    // arrival observation request should be completed immediately)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
    CListenerContainer* taskRequest = FindWaitingTaskRequest();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
    if (taskRequest)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
        CompleteTaskArrivalObservationRequestL(taskRequest->Type(), taskRequest->Specification());
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
void CEventMediatorServer::TaskRequestEventSpecFetchingRequestArrivedL(CListenerContainer* aFetchingRequest)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
    LOG(Log::Printf(_L("CEventMediatorServer::TaskRequestEventSpecFetchingRequestArrivedL\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
    TFetchTaskInfoEventSpec taskRequestInfo;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
    TPckg<TFetchTaskInfoEventSpec> taskRequestInfoDes(taskRequestInfo);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
    taskRequestInfoDes.Copy(*(aFetchingRequest->Specification()));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
    // Find the task request whose event specification
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
    // we should return to the SIT TH
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
    CListenerContainer* taskRequest = FindListener(taskRequestInfo.iEventType, taskRequestInfo.iEventSpecId);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
    if (taskRequest && !taskRequest->BeingFulfilled())
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
        CompleteTaskRequestEventSpecFetchingRequestL(KErrNone, aFetchingRequest->Specification(),
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
                                                     taskRequest->Specification());
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
        taskRequest->MarkAsBeingFulfilled();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
    else
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
        CompleteTaskRequestEventSpecFetchingRequestL(KErrNotFound, aFetchingRequest->Specification(), NULL);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
void CEventMediatorServer::TaskCancellationObservationRequestArrivedL(CListenerContainer* aRequest)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
    LOG(Log::Printf(_L("CEventMediatorServer::TaskCancellationObservationRequestArrivedL\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
    // Try to find a task request event type that corresponds to the received
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
    // event type. This will only succeed if the received event type is
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
    // one that is used to listen to the cancellation of a task request.
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
    TEventType taskRequestEventType = CSit::FindTaskRequestEventType(aRequest->Type());
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
    // If a corresponding task request type was found...
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
    if (taskRequestEventType != EUnfoundEvent)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
        // Try to find the listener container of the task request
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
        CListenerContainer* taskRequest = FindListener(taskRequestEventType, aRequest->Specification());
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
        // The listener container for the task request was not found
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
        // (i.e. the task request has been cancelled or the
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
        // corresponding client session has been closed), so we
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
        // complete the cancellation observation request right away
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
        if (taskRequest == NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
            ReportEventL(aRequest->Type(), aRequest->Specification(), NULL);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
void CEventMediatorServer::CompleteTaskArrivalObservationRequestL(TEventType aEventType, TDesC8* aSpec)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
    LOG(Log::Printf(_L("CEventMediatorServer::CompleteTaskArrivalObservationRequestL\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
    if (iTaskArrivalListener)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
        // In SIT events, the event specification
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
        // begins with the event specification ID
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
        TEventSpec* sitEventSpec = (TEventSpec*)(aSpec->Ptr());
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
        
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
        TTaskArrivedEventData eventData;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
        eventData.iEventType = aEventType;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
        eventData.iEventSpecId = sitEventSpec->iId;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
        TPckg<TTaskArrivedEventData> eventDataDes(eventData);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
        
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
        HBufC8* eventDataCopy = eventDataDes.AllocL();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
        CleanupStack::PushL(eventDataCopy);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
        ReportEventL(ETaskArrivedEvent, NULL, eventDataCopy);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
        
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
        CleanupStack::Pop(); // eventDataCopy, freed elsewhere
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
void CEventMediatorServer::CompleteTaskRequestEventSpecFetchingRequestL(TInt aStatus, TDesC8* aEventSpec,
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
                                                                        TDesC8* aTaskRequestEventSpec)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    LOG(Log::Printf(_L("CEventMediatorServer::CompleteTaskRequestEventSpecFetchingRequestL\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
    // The event specification of the task request
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    // is returned to the SIT TH as event data
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
    if (aTaskRequestEventSpec)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
        HBufC8* eventData = aTaskRequestEventSpec->AllocL();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
        CleanupStack::PushL(eventData);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
        ReportEventL(EFetchTaskInfoEvent, aEventSpec, eventData, aStatus);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
        CleanupStack::Pop(); // eventData, freed elsewhere
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
    else
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
        ReportEventL(EFetchTaskInfoEvent, aEventSpec, NULL, aStatus);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
CListenerContainer* CEventMediatorServer::FindWaitingTaskRequest()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
    CEventMediatorSession* session;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
    iSessionIter.SetToFirst();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
    session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
    CListenerContainer* listener = NULL;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
    while (session != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
        listener = session->FindWaitingTaskRequest();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
        if (listener != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
            break;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
        session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
    return listener;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
CListenerContainer* CEventMediatorServer::FindListener(TEventType aEventType,    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
                                                       TInt aEventSpecId)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
    CEventMediatorSession* session;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
    iSessionIter.SetToFirst();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
    CListenerContainer* listener = NULL;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
    while (session != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
        listener = session->FindListener(aEventType, aEventSpecId);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
        if (listener != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
            break;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
        session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    return listener;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
CListenerContainer* CEventMediatorServer::FindListener(TEventType aEventType,    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
                                                       const TDesC8* aEventSpec)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
    CEventMediatorSession* session;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    iSessionIter.SetToFirst();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
    session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
    CListenerContainer* listener = NULL;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
    while (session != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
        listener = session->FindListener(aEventType, aEventSpec);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
        if (listener != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
            break;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
        session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
    return listener;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
void CEventMediatorServer::CompleteListener(TEventType aEventType, const TDesC8* aEventSpec, TInt aStatus)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
    CEventMediatorSession* session;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
    iSessionIter.SetToFirst();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
    session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
    while (session != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
        session->CompleteListener(aEventType, aEventSpec, aStatus);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
        session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
TInt CEventMediatorServer::NormalSessionCount()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
    TInt normalSessionCount = 0;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
    CEventMediatorSession* session;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
    iSessionIter.SetToFirst();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
    session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
    while (session != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
        if (!(session->IsASitSession()))
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
            normalSessionCount++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
        session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
    return normalSessionCount;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
TInt CEventMediatorServer::NewEventSpecId()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
    return ++iNextEventSpecId;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
TPtrC CEventMediatorServer::EventLogFileName(void)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
    TPtrC name(iEventLogFileName);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
    return name;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
void CEventMediatorServer::SitDied()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
    LOG(Log::Printf(_L("CEventMediatorServer::SitDied\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
    CompleteTaskRequests(KErrDied);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
void CEventMediatorServer::CompleteTaskRequests(TInt aStatus)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
    LOG(Log::Printf(_L("CEventMediatorServer::CompleteTaskRequests\n")));    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
    CEventMediatorSession* session;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
    iSessionIter.SetToFirst();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
    session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
    while (session != NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
        session->CompleteTaskRequests(aStatus);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
        session = (CEventMediatorSession*) iSessionIter++;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
// ============================= CEventMediatorServer =============================    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
CListenerContainer::CListenerContainer(const RMessage2& aMessage, TDesC8* aSpec,
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   603
                                       CEventMediatorServer& aServer)
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   604
    : iSpec(aSpec), iMessage(aMessage), iServer(aServer)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
    iEventType = Type();
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   608
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
void CListenerContainer::AnalyzeRequestL()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
    LOG(Log::Printf(_L("CListenerContainer::AnalyzeRequestL\n")));
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
    if (CSit::EventRequiresSit(iEventType))
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
        LOG(Log::Printf(_L("CListenerContainer::AnalyzeRequestL - event type = %d, requires SIT\n"), iEventType));
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   615
        iServer.MakeSureSitIsRunningL();
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   616
        iServer.TaskRequestArrivedL(this);
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
    // If this event listening request is the one
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
    // made by the SIT task arrival observer...
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
    if (iEventType == ETaskArrivedEvent)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
        {
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   623
        iServer.SetTaskArrivalListenerL(this);
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   624
        iServer.TaskArrivalObservationRequestArrivedL();
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
    // If this event listening request is one
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
    // made by a SIT TH to fetch a task...
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
    if (iEventType == EFetchTaskInfoEvent)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
        {
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   631
        iServer.TaskRequestEventSpecFetchingRequestArrivedL(this);
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
    // If the event listening request is one
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
    // made by a SIT TH to listen to the cancellation
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
    // of the task request it is handling
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
    if (CSit::IsTaskCancellationObservationRequest(iEventType))
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
        {
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   639
        iServer.TaskCancellationObservationRequestArrivedL(this);
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
CListenerContainer::~CListenerContainer()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
    delete iSpec;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   647
    if (iServer.TaskArrivalListener() == this)
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
        {
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   649
        iServer.ClearTaskArrivalListener();
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   652
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   653
TBool CListenerContainer::HandlesEvent(TEventType aEventType, const TDesC8* aEventSpec)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
    if (iEventType == aEventType)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   657
        // Specs are same if both are NULL
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   658
        if (iSpec == NULL && aEventSpec == NULL)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
            return ETrue;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
        // or data in buffers are identical
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
        else if (iSpec != NULL && aEventSpec != NULL && (*iSpec) == (*aEventSpec))
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
            return ETrue;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
    return EFalse;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
void CListenerContainer::Complete(TInt status)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
    // If there's a SIT fulfilling this event listening
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
    // request (i.e. if this is a task request) and this
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
    // task request is being cancelled...
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
    if (status == KErrCancel)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
        // See if we can find a task request cancellation observation
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
        // event type that corresponds to this event type
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
        TEventType cancelEventType = CSit::FindCancelEventType(iEventType);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
        
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
        if (cancelEventType != EUnfoundEvent)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
            {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
            // Complete the task request cancellation
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
            // observation, if found
44
735de8341ce4 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   686
            iServer.CompleteListener(cancelEventType, iSpec, KErrNone);
0
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
            }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   688
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
    
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
    iMessage.Complete(status);
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
TBool CListenerContainer::WaitingForFulfilling()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   695
    if (CSit::EventRequiresSit(iEventType) && !iBeingFulfilledBySit)
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
        return ETrue;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
    else
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
        {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   701
        return EFalse;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
        }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
void CListenerContainer::MarkAsBeingFulfilled()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   706
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
    iBeingFulfilledBySit = ETrue;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
    }
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   709
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
TBool CListenerContainer::BeingFulfilled()
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
    {
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
    return iBeingFulfilledBySit;
33413c0669b9 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
    }