watchdog/src/cwdmonitor.cpp
author hgs
Fri, 15 Oct 2010 12:09:28 +0530
changeset 24 65456528cac2
parent 23 d4d56f5e7c55
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
671dee74050a Revision: 201011
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".
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:  This application is to monitor Harvester and Search Server
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include "CWDmonitor.h"
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include "CWDTimer.h"
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <HarvesterServerLogger.h>
16
hgs
parents: 1
diff changeset
    21
#include <centralrepository.h>
hgs
parents: 1
diff changeset
    22
#include <cpixwatchdogcommon.h>
hgs
parents: 1
diff changeset
    23
#include "centrepmonitor.h"
23
hgs
parents: 16
diff changeset
    24
#include "servermonitor.h"
1
6f2c1c46032b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    25
#include "OstTraceDefinitions.h"
6f2c1c46032b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    26
#ifdef OST_TRACE_COMPILER_IN_USE
6f2c1c46032b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    27
#include "cwdmonitorTraces.h"
6f2c1c46032b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    28
#endif
6f2c1c46032b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    29
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
// CWDMonitor::NewL
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
//
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
CWDMonitor* CWDMonitor::NewL(  )
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
    {
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
    CWDMonitor* self = CWDMonitor::NewLC( );
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
    CleanupStack::Pop();
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
    return self;
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
    }
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
// CWDMonitor::NewLC
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
//
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
CWDMonitor* CWDMonitor::NewLC( )
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
    {
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
    CWDMonitor* self = new ( ELeave ) CWDMonitor( );
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
    CleanupStack::PushL( self );
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
    self->ConstructL();
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
    return self;
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
    }
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
// CWDMonitor::~CWDMonitor()
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
//
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
CWDMonitor::~CWDMonitor()
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
    {
16
hgs
parents: 1
diff changeset
    58
    delete iHSName;
hgs
parents: 1
diff changeset
    59
    delete iSSName;
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
    delete iWDTimer;
23
hgs
parents: 16
diff changeset
    61
    delete aHSStatusMonitor;
hgs
parents: 16
diff changeset
    62
    delete aSSStatusMonitor;
hgs
parents: 16
diff changeset
    63
    delete aHSUidMonitor;
hgs
parents: 16
diff changeset
    64
    delete aSSUidMonitor;
hgs
parents: 16
diff changeset
    65
    delete aHSNameMonitor;
hgs
parents: 16
diff changeset
    66
    delete aSSNameMonitor;
hgs
parents: 16
diff changeset
    67
    delete iHarvesterMonitor;
hgs
parents: 16
diff changeset
    68
    delete iSearchMonitor;
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
    }
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
// CWDMonitor::CWDMonitor()
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
//
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
CWDMonitor::CWDMonitor( )                    
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
    {    
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
    }
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
// CWDMonitor::ConstructL()
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
//
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
void CWDMonitor::ConstructL()
16
hgs
parents: 1
diff changeset
    84
    {    
hgs
parents: 1
diff changeset
    85
    CRepository* wdrepo = CRepository::NewL( KWDrepoUidMenu );
hgs
parents: 1
diff changeset
    86
    wdrepo->Get( KHarvesterServerKey , iAllowHS );
hgs
parents: 1
diff changeset
    87
    wdrepo->Get( KSearchServerKey , iAllowSS );
hgs
parents: 1
diff changeset
    88
    
hgs
parents: 1
diff changeset
    89
    //get the UID's of the servers
hgs
parents: 1
diff changeset
    90
    TBuf<KCenrepUidLength> temp;
hgs
parents: 1
diff changeset
    91
    TInt64 value;
hgs
parents: 1
diff changeset
    92
    TLex uidvalue;
hgs
parents: 1
diff changeset
    93
    //Read Harvester server UId value
hgs
parents: 1
diff changeset
    94
    if ( KErrNone == wdrepo->Get( KHarvesterServerUIDKey, temp ) )
hgs
parents: 1
diff changeset
    95
        {
hgs
parents: 1
diff changeset
    96
        uidvalue.Assign(temp);        
hgs
parents: 1
diff changeset
    97
        if (KErrNone == uidvalue.Val( value,EHex ))
hgs
parents: 1
diff changeset
    98
            iHSUid.iUid = value;
hgs
parents: 1
diff changeset
    99
        }
hgs
parents: 1
diff changeset
   100
    //Read Search server Uid value
hgs
parents: 1
diff changeset
   101
    if ( KErrNone == wdrepo->Get( KSearchServerUIDKey, temp ))
hgs
parents: 1
diff changeset
   102
        {
hgs
parents: 1
diff changeset
   103
        uidvalue.Assign(temp);
hgs
parents: 1
diff changeset
   104
        if (KErrNone == uidvalue.Val( value,EHex ))
hgs
parents: 1
diff changeset
   105
          iSSUid.iUid = value;
hgs
parents: 1
diff changeset
   106
        }
hgs
parents: 1
diff changeset
   107
    
hgs
parents: 1
diff changeset
   108
    //Read Harvester server Name
hgs
parents: 1
diff changeset
   109
    if ( KErrNone == wdrepo->Get( KHarvesterServerNAMEKey, temp ))
hgs
parents: 1
diff changeset
   110
        {
hgs
parents: 1
diff changeset
   111
        iHSName = HBufC::NewL( temp.Length() );
hgs
parents: 1
diff changeset
   112
        TPtr hsname = iHSName->Des();
hgs
parents: 1
diff changeset
   113
        hsname.Copy( temp );
hgs
parents: 1
diff changeset
   114
        }
hgs
parents: 1
diff changeset
   115
    //Read Search server Name
hgs
parents: 1
diff changeset
   116
    if ( KErrNone == wdrepo->Get( KSearchServerNAMEKey, temp ))
hgs
parents: 1
diff changeset
   117
        {
hgs
parents: 1
diff changeset
   118
        iSSName = HBufC::NewL( temp.Length() );
hgs
parents: 1
diff changeset
   119
        TPtr ssname = iSSName->Des(); 
hgs
parents: 1
diff changeset
   120
        ssname.Copy( temp );
hgs
parents: 1
diff changeset
   121
        }
hgs
parents: 1
diff changeset
   122
    delete wdrepo;
hgs
parents: 1
diff changeset
   123
    if ( iAllowHS || iAllowSS )
hgs
parents: 1
diff changeset
   124
        iWDTimer = CWDTimer::NewL( this );
hgs
parents: 1
diff changeset
   125
    
23
hgs
parents: 16
diff changeset
   126
    aHSStatusMonitor = CentrepMonitor::NewL( this, KHarvesterServerKey);
hgs
parents: 16
diff changeset
   127
    aHSStatusMonitor->StartNotifier();
hgs
parents: 16
diff changeset
   128
    aSSStatusMonitor = CentrepMonitor::NewL( this, KSearchServerKey);
hgs
parents: 16
diff changeset
   129
    aSSStatusMonitor->StartNotifier();
hgs
parents: 16
diff changeset
   130
    aHSUidMonitor = CentrepMonitor::NewL( this, KHarvesterServerUIDKey);
hgs
parents: 16
diff changeset
   131
    aHSUidMonitor->StartNotifier();
hgs
parents: 16
diff changeset
   132
    aSSUidMonitor = CentrepMonitor::NewL( this, KSearchServerUIDKey);
hgs
parents: 16
diff changeset
   133
    aSSUidMonitor->StartNotifier();
hgs
parents: 16
diff changeset
   134
    aHSNameMonitor = CentrepMonitor::NewL( this, KHarvesterServerNAMEKey);
hgs
parents: 16
diff changeset
   135
    aHSNameMonitor->StartNotifier();
hgs
parents: 16
diff changeset
   136
    aSSNameMonitor = CentrepMonitor::NewL( this, KSearchServerNAMEKey);
hgs
parents: 16
diff changeset
   137
    aSSNameMonitor->StartNotifier();
hgs
parents: 16
diff changeset
   138
    
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
    }
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
// CWDMonitor::StartMonitor()
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
//
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
void CWDMonitor::HandleWDTimerL()
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    {
1
6f2c1c46032b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   147
    OstTrace0( TRACE_NORMAL, CWDMONITOR_HANDLEWDTIMERL, "CWDMonitor::HandleWDTimerL(): Check the servers" );
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    CPIXLOGSTRING("CWDMonitor::HandleWDTimerL(): Check the servers");
23
hgs
parents: 16
diff changeset
   149
hgs
parents: 16
diff changeset
   150
    if ( !iHarvesterMonitor )
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
        {
23
hgs
parents: 16
diff changeset
   152
        if ( iAllowHS )
hgs
parents: 16
diff changeset
   153
            iHarvesterMonitor = CServerMonitor::NewL( *iHSName , iHSUid );
hgs
parents: 16
diff changeset
   154
        iWDTimer->StartWDTimer();
hgs
parents: 16
diff changeset
   155
        return;
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
        }
23
hgs
parents: 16
diff changeset
   157
    if ( iAllowSS )
hgs
parents: 16
diff changeset
   158
        iSearchMonitor = CServerMonitor::NewL( *iSSName , iSSUid );
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    return;
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    }
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
// CWDMonitor::StartMonitor()
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
// -----------------------------------------------------------------------------
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
//
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
void CWDMonitor::StartMonitor()
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    {
1
6f2c1c46032b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   167
    OstTraceFunctionEntry0( CWDMONITOR_STARTMONITOR_ENTRY );
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
    CPIXLOGSTRING("CWDMonitor::StartMonitor(): Entered");
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    iWDTimer->StartWDTimer();
1
6f2c1c46032b Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   170
    OstTraceFunctionExit0( CWDMONITOR_STARTMONITOR_EXIT );
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
    }
16
hgs
parents: 1
diff changeset
   172
// -----------------------------------------------------------------------------
hgs
parents: 1
diff changeset
   173
// CWDMonitor::HandlecentrepL()
hgs
parents: 1
diff changeset
   174
// -----------------------------------------------------------------------------
hgs
parents: 1
diff changeset
   175
//
hgs
parents: 1
diff changeset
   176
void CWDMonitor::HandlecentrepL( TUint32 aKey )
hgs
parents: 1
diff changeset
   177
    {
hgs
parents: 1
diff changeset
   178
    CRepository* wdrepo = CRepository::NewL( KWDrepoUidMenu );        
hgs
parents: 1
diff changeset
   179
    if ( KHarvesterServerKey == aKey )
hgs
parents: 1
diff changeset
   180
        {
hgs
parents: 1
diff changeset
   181
        // get the harvester server status
23
hgs
parents: 16
diff changeset
   182
        wdrepo->Get( KHarvesterServerKey , iAllowHS );
hgs
parents: 16
diff changeset
   183
        
hgs
parents: 16
diff changeset
   184
        if ( iAllowHS )
hgs
parents: 16
diff changeset
   185
            {
hgs
parents: 16
diff changeset
   186
            //start the Harvester server and start monitoring            
hgs
parents: 16
diff changeset
   187
            iHarvesterMonitor = CServerMonitor::NewL( *iHSName , iHSUid );
hgs
parents: 16
diff changeset
   188
            }
hgs
parents: 16
diff changeset
   189
        else{
hgs
parents: 16
diff changeset
   190
            // Shutdown the harvester server
hgs
parents: 16
diff changeset
   191
            iHarvesterMonitor->Cancel();
hgs
parents: 16
diff changeset
   192
            iHarvesterMonitor->ShutdownServer();                        
hgs
parents: 16
diff changeset
   193
            delete iHarvesterMonitor;
hgs
parents: 16
diff changeset
   194
            iHarvesterMonitor = NULL;
hgs
parents: 16
diff changeset
   195
            }
16
hgs
parents: 1
diff changeset
   196
        }
hgs
parents: 1
diff changeset
   197
    else if ( KSearchServerKey == aKey )
hgs
parents: 1
diff changeset
   198
        {
hgs
parents: 1
diff changeset
   199
        // get the Search server status
23
hgs
parents: 16
diff changeset
   200
        wdrepo->Get( KSearchServerKey , iAllowSS );
hgs
parents: 16
diff changeset
   201
        
hgs
parents: 16
diff changeset
   202
        if ( iAllowSS )
hgs
parents: 16
diff changeset
   203
            {
hgs
parents: 16
diff changeset
   204
            //Start the Search server and start monitoring
hgs
parents: 16
diff changeset
   205
            iSearchMonitor = CServerMonitor::NewL( *iSSName , iSSUid );
hgs
parents: 16
diff changeset
   206
            }
hgs
parents: 16
diff changeset
   207
        else
hgs
parents: 16
diff changeset
   208
            {
hgs
parents: 16
diff changeset
   209
            //Shutdown the searchserver
hgs
parents: 16
diff changeset
   210
            iSearchMonitor->Cancel();
hgs
parents: 16
diff changeset
   211
            iSearchMonitor->ShutdownServer();                        
hgs
parents: 16
diff changeset
   212
            delete iSearchMonitor;
hgs
parents: 16
diff changeset
   213
            iSearchMonitor = NULL;
hgs
parents: 16
diff changeset
   214
            }
hgs
parents: 16
diff changeset
   215
        }
hgs
parents: 16
diff changeset
   216
    else if ( (KHarvesterServerUIDKey == aKey)||( KHarvesterServerNAMEKey == aKey ) )
hgs
parents: 16
diff changeset
   217
        {
hgs
parents: 16
diff changeset
   218
        // Shutdown the existing server
hgs
parents: 16
diff changeset
   219
        iHarvesterMonitor->Cancel();
hgs
parents: 16
diff changeset
   220
        iHarvesterMonitor->ShutdownServer();                        
hgs
parents: 16
diff changeset
   221
        delete iHarvesterMonitor;
hgs
parents: 16
diff changeset
   222
        iHarvesterMonitor = NULL;
hgs
parents: 16
diff changeset
   223
        //read the new values
hgs
parents: 16
diff changeset
   224
        TBuf<KCenrepUidLength> temp;
hgs
parents: 16
diff changeset
   225
        TInt64 value;
hgs
parents: 16
diff changeset
   226
        TLex uidvalue;
hgs
parents: 16
diff changeset
   227
        if ( KHarvesterServerUIDKey == aKey )
hgs
parents: 16
diff changeset
   228
            {            
hgs
parents: 16
diff changeset
   229
            //Read Harvester server UId value
hgs
parents: 16
diff changeset
   230
            if ( KErrNone == wdrepo->Get( KHarvesterServerUIDKey, temp ) )
hgs
parents: 16
diff changeset
   231
                {
hgs
parents: 16
diff changeset
   232
                uidvalue.Assign(temp);        
hgs
parents: 16
diff changeset
   233
                if (KErrNone == uidvalue.Val( value,EHex ))
hgs
parents: 16
diff changeset
   234
                    iHSUid.iUid = value;
hgs
parents: 16
diff changeset
   235
                }
hgs
parents: 16
diff changeset
   236
            }
hgs
parents: 16
diff changeset
   237
        else
hgs
parents: 16
diff changeset
   238
            {
hgs
parents: 16
diff changeset
   239
            //read harvester server name
hgs
parents: 16
diff changeset
   240
            delete iHSName;
24
hgs
parents: 23
diff changeset
   241
            iHSName = NULL;
23
hgs
parents: 16
diff changeset
   242
            if ( KErrNone == wdrepo->Get( KHarvesterServerNAMEKey, temp ))
hgs
parents: 16
diff changeset
   243
                {
hgs
parents: 16
diff changeset
   244
                iHSName = HBufC::NewL( temp.Length() );
hgs
parents: 16
diff changeset
   245
                TPtr hsname = iHSName->Des();
hgs
parents: 16
diff changeset
   246
                hsname.Copy( temp );
hgs
parents: 16
diff changeset
   247
                }
hgs
parents: 16
diff changeset
   248
            }        
hgs
parents: 16
diff changeset
   249
        // Start the server with new values
hgs
parents: 16
diff changeset
   250
        iHarvesterMonitor = CServerMonitor::NewL( *iHSName , iHSUid );
hgs
parents: 16
diff changeset
   251
        }
hgs
parents: 16
diff changeset
   252
    else if ( (KSearchServerUIDKey == aKey)||( KSearchServerNAMEKey == aKey ) )
hgs
parents: 16
diff changeset
   253
        {
hgs
parents: 16
diff changeset
   254
        // Shutdown the existing server
hgs
parents: 16
diff changeset
   255
        iSearchMonitor->Cancel();
hgs
parents: 16
diff changeset
   256
        iSearchMonitor->ShutdownServer();                        
hgs
parents: 16
diff changeset
   257
        delete iSearchMonitor;
hgs
parents: 16
diff changeset
   258
        iSearchMonitor = NULL;
hgs
parents: 16
diff changeset
   259
        //read the new values
hgs
parents: 16
diff changeset
   260
        TBuf<KCenrepUidLength> temp;
hgs
parents: 16
diff changeset
   261
        TInt64 value;
hgs
parents: 16
diff changeset
   262
        TLex uidvalue;
hgs
parents: 16
diff changeset
   263
        if ( KSearchServerUIDKey == aKey )
hgs
parents: 16
diff changeset
   264
            {
hgs
parents: 16
diff changeset
   265
            //read search server uid
hgs
parents: 16
diff changeset
   266
            if ( KErrNone == wdrepo->Get( KSearchServerUIDKey, temp ) )
hgs
parents: 16
diff changeset
   267
                {
hgs
parents: 16
diff changeset
   268
                uidvalue.Assign(temp);        
hgs
parents: 16
diff changeset
   269
                if (KErrNone == uidvalue.Val( value,EHex ))
hgs
parents: 16
diff changeset
   270
                    iSSUid.iUid = value;
hgs
parents: 16
diff changeset
   271
                }
hgs
parents: 16
diff changeset
   272
            }
hgs
parents: 16
diff changeset
   273
        else
hgs
parents: 16
diff changeset
   274
            {
hgs
parents: 16
diff changeset
   275
            //read search server name
hgs
parents: 16
diff changeset
   276
            delete iSSName;
24
hgs
parents: 23
diff changeset
   277
            iSSName = NULL;
23
hgs
parents: 16
diff changeset
   278
            if ( KErrNone == wdrepo->Get( KSearchServerNAMEKey, temp ))
hgs
parents: 16
diff changeset
   279
                {
hgs
parents: 16
diff changeset
   280
                iSSName = HBufC::NewL( temp.Length() );
hgs
parents: 16
diff changeset
   281
                TPtr ssname = iSSName->Des();
hgs
parents: 16
diff changeset
   282
                ssname.Copy( temp );
hgs
parents: 16
diff changeset
   283
                }
hgs
parents: 16
diff changeset
   284
            }        
hgs
parents: 16
diff changeset
   285
        // Start the server with new values
hgs
parents: 16
diff changeset
   286
        iSearchMonitor = CServerMonitor::NewL( *iSSName , iSSUid );
16
hgs
parents: 1
diff changeset
   287
        }
hgs
parents: 1
diff changeset
   288
    delete wdrepo;
hgs
parents: 1
diff changeset
   289
    }
0
671dee74050a Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
//End of file