|
1 // Copyright (c) 2008-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 "app_protintf_fact.h" |
|
17 #include "app_protintf_msgs.h" |
|
18 //#include <ss_fact2.h> |
|
19 #include <in_sock.h> |
|
20 #include "app_protintf_tcp.h" |
|
21 #include "app_protintf_udp.h" |
|
22 |
|
23 //using namespace ESock; |
|
24 |
|
25 CApplicationProtocolIntfFactory* CApplicationProtocolIntfFactory::NewL ( ) |
|
26 { |
|
27 CApplicationProtocolIntfFactory* self = new (ELeave) CApplicationProtocolIntfFactory( ); |
|
28 CleanupStack::PushL ( self ); |
|
29 self->ConstructL (); |
|
30 CleanupStack::Pop (); |
|
31 return self; |
|
32 } |
|
33 |
|
34 void CApplicationProtocolIntfFactory::ConstructL () |
|
35 { |
|
36 TAppProtIntfMessage::RegisterL (); // Register the message with COMMS transport |
|
37 } |
|
38 |
|
39 CApplicationProtocolIntfFactory::~CApplicationProtocolIntfFactory () |
|
40 { |
|
41 TAppProtIntfMessage::DeRegister (); |
|
42 } |
|
43 |
|
44 CApplicationProtocolIntfFactory::CApplicationProtocolIntfFactory ( ) |
|
45 { |
|
46 } |
|
47 |
|
48 // From CFactory |
|
49 CFactoryObject* CApplicationProtocolIntfFactory::DoCreateFactoryObjectL ( Factories::MFactoryQuery& aFactoryQuery ) |
|
50 { |
|
51 const TAppProtIntfQuery& query = static_cast < const TAppProtIntfQuery& > ( aFactoryQuery ); |
|
52 CFactoryObject* obj = NULL; |
|
53 // Factory is having the knowledge of how to create concrete factory objects |
|
54 switch ( query.iProtocol ) |
|
55 { |
|
56 case KProtocolInetTcp: |
|
57 obj = CApplicationProtocolIntfTcp::NewL ( query.iPort ); |
|
58 break; |
|
59 |
|
60 case KProtocolInetUdp: |
|
61 obj = CApplicationProtocolIntfUdp::NewL ( query.iPort ); |
|
62 break; |
|
63 |
|
64 default: |
|
65 User::Leave ( KErrNotSupported ); |
|
66 break; |
|
67 } |
|
68 return obj; |
|
69 } |
|
70 |