localconnectivityservice/locod/src/locodmain.cpp
author hgs
Fri, 15 Oct 2010 15:05:57 +0800
changeset 54 4dc88a4ac6f4
parent 29 3ae5cb0b4c02
permissions -rw-r--r--
201041_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     1
/*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     2
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     3
* All rights reserved.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     8
*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     9
* Initial Contributors:
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    11
*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    12
* Contributors:
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    13
*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    14
* Description:  Global functions for Local Connectivity Daemon.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    15
*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    16
*/
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    17
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    18
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    19
#include "locodaemon.h"
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    20
#include "debug.h"
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    21
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    22
_LIT( KLocodName, "LocalConnectivityDaemon" );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    23
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    24
static void StartDaemonL();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    25
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    26
// ======== LOCAL FUNCTIONS ========
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    27
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    28
// ---------------------------------------------------------------------------
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    29
// E32Main.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    30
// Entry-point for LCD.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    31
// ---------------------------------------------------------------------------
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    32
//
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    33
TInt E32Main()
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    34
    {
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    35
    TInt ret;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    36
    User::RenameThread( KLocodName );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    37
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    38
    __UHEAP_MARK;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    39
    
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    40
    // create clean-up stack
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    41
    CTrapCleanup* cleanup = CTrapCleanup::New();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    42
    TRAP( ret, StartDaemonL() );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    43
    delete cleanup; // destroy clean-up stack
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    44
    __UHEAP_MARKEND;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    45
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    46
    return ret;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    47
    }
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    48
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    49
// ----------------------------------------------------------------------------
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    50
// StartDaemonL().
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    51
// Constructs and installs the active scheduler, constructs Daemon object.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    52
// ----------------------------------------------------------------------------
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    53
//
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    54
static void StartDaemonL()
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    55
    {
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    56
    TRACE_FUNC
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    57
    
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    58
    // Construct and install the active scheduler
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    59
    CActiveScheduler *myScheduler = new ( ELeave ) CActiveScheduler();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    60
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    61
    // Push onto the cleanup stack
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    62
    CleanupStack::PushL( myScheduler );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    63
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    64
    // Install as the active scheduler
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    65
    CActiveScheduler::Install( myScheduler );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    66
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    67
    CLocoDaemon* daemon = NULL;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    68
    daemon = CLocoDaemon::NewLC();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    69
    CActiveScheduler::Start();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    70
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    71
    CleanupStack::PopAndDestroy( daemon );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    72
    CleanupStack::PopAndDestroy( myScheduler );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    73
    }
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    74