|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "logger.h" |
|
20 #include "btrfcommpushserverconnection.h" |
|
21 #include "btobexserverconnectionfactory.h" |
|
22 |
|
23 using namespace java::util; |
|
24 using namespace java::push; |
|
25 using namespace java::bluetooth; |
|
26 |
|
27 #if defined(__SYMBIAN32__) && defined(__WINSCW__) |
|
28 #include <pls.h> |
|
29 #else |
|
30 static BTOBEXServerConnectionFactory* sObexSrvConnFac = 0; |
|
31 #endif |
|
32 |
|
33 #ifdef __SYMBIAN32__ |
|
34 ServerConnectionFactory& getServerConnectionFactory() |
|
35 { |
|
36 #else |
|
37 extern "C" ServerConnectionFactory& getServerConnectionFactory() |
|
38 { |
|
39 #endif |
|
40 JELOG2(EJavaBluetooth); |
|
41 |
|
42 //CONTEXT_REMOVAL |
|
43 #if defined(__SYMBIAN32__) && defined(__WINSCW__) |
|
44 TUid uid = TUid::Uid(0xE0000055); |
|
45 BTOBEXServerConnectionFactory* retObj = |
|
46 Pls<BTOBEXServerConnectionFactory>(uid); |
|
47 return *retObj; |
|
48 #else |
|
49 if (sObexSrvConnFac == 0) |
|
50 { |
|
51 sObexSrvConnFac = new BTOBEXServerConnectionFactory(); |
|
52 } |
|
53 return *sObexSrvConnFac; |
|
54 #endif |
|
55 } |
|
56 |
|
57 |
|
58 OS_EXPORT |
|
59 BTOBEXServerConnectionFactory& BTOBEXServerConnectionFactory::getFactory() |
|
60 { |
|
61 JELOG2(EJavaBluetooth); |
|
62 ServerConnectionFactory& scf = ::getServerConnectionFactory(); |
|
63 return reinterpret_cast<BTOBEXServerConnectionFactory&>(scf); |
|
64 } |
|
65 |
|
66 /** |
|
67 * |
|
68 */ |
|
69 OS_EXPORT BTOBEXServerConnectionFactory::BTOBEXServerConnectionFactory() |
|
70 { |
|
71 JELOG2(EJavaBluetooth); |
|
72 } |
|
73 |
|
74 /** |
|
75 * |
|
76 */ |
|
77 OS_EXPORT BTOBEXServerConnectionFactory::~BTOBEXServerConnectionFactory() |
|
78 { |
|
79 JELOG2(EJavaBluetooth); |
|
80 } |
|
81 |
|
82 /** |
|
83 * |
|
84 */ |
|
85 OS_EXPORT ServerConnection* BTOBEXServerConnectionFactory::createSrvConnObj( |
|
86 const std::wstring& aUri, const std::wstring& aFilter) |
|
87 { |
|
88 JELOG2(EJavaBluetooth); |
|
89 |
|
90 // If launched by push, URI and Filter are already valid. |
|
91 return new RFCOMMPushServerConnection(aUri, aFilter,this); |
|
92 } |
|
93 |
|
94 OS_EXPORT ServerConnection* BTOBEXServerConnectionFactory::create( |
|
95 const std::wstring& aUri) |
|
96 { |
|
97 JELOG2(EJavaBluetooth); |
|
98 RFCOMMPushServerConnection * server = NULL; |
|
99 SrvConnContainerIter_t iter = mServerConnections.find(aUri); |
|
100 if (iter == mServerConnections.end()) |
|
101 { |
|
102 std::auto_ptr<ServerConnection> newSrvConn(createSrvConnObj(aUri, L"")); |
|
103 SrvConnContainerData newDataObj(newSrvConn.release(),0,false,SrvConnContainerData::NORMAL); |
|
104 mServerConnections.insert(std::pair<std::wstring,SrvConnContainerData>(aUri,newDataObj)); |
|
105 server = (RFCOMMPushServerConnection*)newDataObj.getConn(); |
|
106 server->setCreatedByPush(); |
|
107 } |
|
108 else if (SrvConnContainerData::PUSH_LISTEN_BY_MIDLET == iter->second.connType() |
|
109 || SrvConnContainerData::NORMAL == iter->second.connType()) |
|
110 { |
|
111 server = new RFCOMMPushServerConnection(aUri, L"",this); |
|
112 } |
|
113 else |
|
114 { |
|
115 iter->second.setConnType(SrvConnContainerData::PUSH_LISTEN_BY_MIDLET); |
|
116 server = (RFCOMMPushServerConnection*)(*iter).second.getConn(); |
|
117 server->setCreatedByPush(); |
|
118 } |
|
119 return server; |
|
120 } |
|
121 |
|
122 OS_EXPORT bool BTOBEXServerConnectionFactory::isMultipleSrvConnAllowed() |
|
123 { |
|
124 return false; |
|
125 } |
|
126 |