|
1 /* |
|
2 * Copyright (c) 2005-2009 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 #include "T_SocketServData.h" |
|
19 |
|
20 /*@{*/ |
|
21 //Parameters |
|
22 _LIT(KMessageSlots, "messageslots"); |
|
23 |
|
24 //Commands |
|
25 _LIT(KCmdRSocketServ, "RSocketServ"); |
|
26 _LIT(KCmdConnect, "Connect"); |
|
27 _LIT(KCmdClose, "Close"); |
|
28 /*@}*/ |
|
29 |
|
30 ////////////////////////////////////////////////////////////////////// |
|
31 // Construction/Destruction |
|
32 ////////////////////////////////////////////////////////////////////// |
|
33 |
|
34 CT_SocketServData* CT_SocketServData::NewL() |
|
35 { |
|
36 CT_SocketServData* ret=new (ELeave) CT_SocketServData(); |
|
37 CleanupStack::PushL(ret); |
|
38 ret->ConstructL(); |
|
39 CleanupStack::Pop(ret); |
|
40 return ret; |
|
41 } |
|
42 |
|
43 CT_SocketServData::CT_SocketServData() |
|
44 : iData(NULL) |
|
45 { |
|
46 } |
|
47 |
|
48 void CT_SocketServData::ConstructL() |
|
49 { |
|
50 } |
|
51 |
|
52 CT_SocketServData::~CT_SocketServData() |
|
53 { |
|
54 DestroyData(); |
|
55 } |
|
56 |
|
57 TAny* CT_SocketServData::GetObject() |
|
58 { |
|
59 return iData; |
|
60 } |
|
61 |
|
62 |
|
63 void CT_SocketServData::SetObjectL(TAny* aAny) |
|
64 { |
|
65 DestroyData(); |
|
66 iData = static_cast<RSocketServ*> (aAny); |
|
67 } |
|
68 |
|
69 void CT_SocketServData::DisownObjectL() |
|
70 { |
|
71 iData = NULL; |
|
72 } |
|
73 |
|
74 void CT_SocketServData::DestroyData() |
|
75 { |
|
76 delete iData; |
|
77 iData=NULL; |
|
78 } |
|
79 |
|
80 inline TCleanupOperation CT_SocketServData::CleanupOperation() |
|
81 { |
|
82 return CleanupOperation; |
|
83 } |
|
84 |
|
85 void CT_SocketServData::CleanupOperation(TAny* aAny) |
|
86 { |
|
87 //may be unnecessary |
|
88 RSocketServ* arg=static_cast<RSocketServ*>(aAny); |
|
89 delete arg; |
|
90 } |
|
91 |
|
92 TBool CT_SocketServData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
93 { |
|
94 TBool ret = ETrue; |
|
95 |
|
96 if ( aCommand==KCmdRSocketServ ) |
|
97 { |
|
98 DoCmdRSocketServ(); |
|
99 } |
|
100 else if ( aCommand==KCmdConnect ) |
|
101 { |
|
102 DoCmdConnect(aSection); |
|
103 } |
|
104 else if ( aCommand==KCmdClose ) |
|
105 { |
|
106 DoCmdClose(); |
|
107 } |
|
108 else |
|
109 { |
|
110 ret=EFalse; |
|
111 } |
|
112 |
|
113 return ret; |
|
114 } |
|
115 |
|
116 |
|
117 /** |
|
118 Test RSocketServ() |
|
119 */ |
|
120 void CT_SocketServData::DoCmdRSocketServ() |
|
121 { |
|
122 INFO_PRINTF1(_L("RSocketServ Constructor Call")); |
|
123 DestroyData(); |
|
124 |
|
125 iData = new (ELeave) RSocketServ(); |
|
126 } |
|
127 |
|
128 |
|
129 /** |
|
130 Test Connect() |
|
131 */ |
|
132 void CT_SocketServData::DoCmdConnect(const TDesC& aSection) |
|
133 { |
|
134 INFO_PRINTF1(_L("RSocketServ Connect Call")); |
|
135 |
|
136 TInt messageSlots = 0; |
|
137 TInt err = 0; |
|
138 if(GetIntFromConfig(aSection, KMessageSlots(), messageSlots) ) |
|
139 { |
|
140 err = iData->Connect(messageSlots); |
|
141 } |
|
142 else |
|
143 { |
|
144 err = iData->Connect(); |
|
145 } |
|
146 |
|
147 if(err != KErrNone) |
|
148 { |
|
149 ERR_PRINTF2(_L("RSocketServ Connect failed with error %d"), err); |
|
150 SetError(err); |
|
151 } |
|
152 } |
|
153 |
|
154 |
|
155 /** |
|
156 Test Close() |
|
157 */ |
|
158 void CT_SocketServData::DoCmdClose() |
|
159 { |
|
160 INFO_PRINTF1(_L("RSocketServ Close Call")); |
|
161 |
|
162 iData->Close(); |
|
163 } |