DirectPrint/DirectPrintServer/src/main.cpp
author Steven Cao <steven.1.cao@nokia.com>
Tue, 11 May 2010 14:10:02 +0800
changeset 15 2275db202402
parent 12 613a5ff70823
permissions -rw-r--r--
Pickup K3's code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     1
/*
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     2
* Copyright (c) 2010 Kanrikogaku Kenkyusho, Ltd.
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     3
* All rights reserved.
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     4
* This component and the accompanying materials are made available
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     6
* which accompanies this distribution, and is available
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     8
*
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
     9
* Initial Contributors:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    10
* Kanrikogaku Kenkyusho, Ltd. - Initial contribution
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    11
*
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    12
* Contributors:
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    13
*
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    14
* Description:  
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    15
*
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    16
*/
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    17
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    18
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    19
#include <e32base.h>
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    20
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    21
#include "directprintclientserver.h"
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    22
#include "directprintserver.h"
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    23
#include "directprintscheduler.h"
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    24
#include "clog.h"
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    25
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    26
// init and run the server
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    27
static void RunTheServerL()
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    28
	{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    29
#ifndef __SECURE_API__
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    30
	User::LeaveIfError( RThread().Rename( KDirectPrintServerName ) );  //Deprecated! Replace this with the line below as soon as possible
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    31
#else
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    32
	User::LeaveIfError( RThread().RenameMe( KDirectPrintServerName ) );
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    33
#endif
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    34
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    35
	CActiveScheduler* scheduler = new (ELeave) CDirectPrintScheduler;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    36
	CleanupStack::PushL( scheduler );
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    37
	CActiveScheduler::Install( scheduler );
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    38
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    39
	CDirectPrintServer::NewLC();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    40
	
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    41
	RProcess::Rendezvous( KErrNone );
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    42
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    43
	CActiveScheduler::Start();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    44
	CleanupStack::PopAndDestroy( 2 );	// CDirectPrintServer, scheduler
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    45
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    46
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    47
// Server process entry-point
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    48
TInt E32Main()
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    49
	{	
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    50
	CTrapCleanup* cleanup = CTrapCleanup::New();
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    51
	TInt r( KErrNoMemory );
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    52
	if( cleanup )
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    53
		{
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    54
		TRAP( r, RunTheServerL() );
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    55
		delete cleanup;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    56
		}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    57
	return r;
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    58
	}
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    59
2275db202402 Pickup K3's code
Steven Cao <steven.1.cao@nokia.com>
parents: 12
diff changeset
    60
//  End of File