buildverification/autosmoketest/Timew/ConsoleAlarmAlertServer/Source/ConsoleAlarmAlertServerMain.cpp
branchGCC_SURGE
changeset 17 03d9ade4748d
parent 14 5d7fec11a5ce
parent 15 5b5908ec640f
equal deleted inserted replaced
14:5d7fec11a5ce 17:03d9ade4748d
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "consolealarmalertservermain.h"
       
    17 
       
    18 // System includes
       
    19 
       
    20 // User includes
       
    21 #include "asaltdefs.h"
       
    22 //
       
    23 #include "consolealarmalertserver.h"
       
    24 
       
    25 // Type definitions
       
    26 
       
    27 // Constants
       
    28 
       
    29 // Enumerations
       
    30 
       
    31 // Classes referenced
       
    32 
       
    33 
       
    34 //
       
    35 // ----> ConsoleAlarmAlertServer (source)
       
    36 //
       
    37 
       
    38 //*************************************************************************************
       
    39 EXPORT_C void ConsoleAlarmAlertServer::StartConsoleAlarmAlertServerL(TAny* instructionSet)
       
    40 	{
       
    41 	_LIT(KAlarmAlertServerThreadName, "ConsoleAlarmAlertServerThread");
       
    42 	//
       
    43 	const TInt KStackSize		= 0x0002000;	//  8KB
       
    44 	const TInt KInitHeapSize	= 0x0001000;	//  4KB
       
    45 	const TInt KHeapSize		= 0x1000000;	// 16MB
       
    46 	//
       
    47 	// Is the alarm alert server already running? If so, don't
       
    48 	// start a new one...
       
    49 	TFullName name;
       
    50 	TFindServer finder(KAlarmAlertServerName);
       
    51 	if	(finder.Next(name) == KErrNone)
       
    52 		return;
       
    53 	
       
    54 	RThread serverThread;
       
    55 	const TInt error = serverThread.Create(KAlarmAlertServerThreadName,
       
    56 										   &StartServerThreadFunction,
       
    57 										   KStackSize,
       
    58 										   KInitHeapSize,
       
    59 										   KHeapSize,
       
    60 										   instructionSet
       
    61 										  );
       
    62 	User::LeaveIfError(error);
       
    63 	//
       
    64 	serverThread.SetPriority(EPriorityMore);
       
    65 	serverThread.Resume();
       
    66 	//
       
    67 	User::After(2000000); // 2 seconds
       
    68 	}
       
    69 
       
    70 
       
    71 //
       
    72 //
       
    73 //
       
    74 
       
    75 
       
    76 //*************************************************************************************
       
    77 TInt ConsoleAlarmAlertServer::StartServerThreadFunction(TAny* instructionSet)
       
    78 	{
       
    79 	__UHEAP_MARK;
       
    80 	//
       
    81 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    82 	if	(!cleanup)
       
    83 		User::Invariant();
       
    84 	//
       
    85 	TRAPD(err, StartServerL(instructionSet));
       
    86 	delete cleanup;
       
    87 	//
       
    88 	__UHEAP_MARKEND;
       
    89 	return err;
       
    90 	}
       
    91 
       
    92 
       
    93 //*************************************************************************************
       
    94 void ConsoleAlarmAlertServer::StartServerL(TAny* instructionSet)
       
    95 	{
       
    96 	CActiveScheduler* scheduler = new CActiveScheduler();
       
    97 	CleanupStack::PushL(scheduler);
       
    98 	CActiveScheduler::Install(scheduler);
       
    99 	//
       
   100 
       
   101 	CConsoleAlarmAlertServer * tmp = CConsoleAlarmAlertServer::NewLC();
       
   102 	tmp->AddResponseArray(instructionSet);
       
   103 	CActiveScheduler::Start();
       
   104 	//
       
   105 	CleanupStack::PopAndDestroy(2, scheduler);
       
   106 	}
       
   107 
       
   108 
       
   109 
       
   110 
       
   111 
       
   112 
       
   113 //
       
   114 // ----> ConsoleAlarmAlertServer (source)
       
   115 //
       
   116 
       
   117 //*************************************************************************************