|
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 |
|
19 #include "T_RSocketServData.h" |
|
20 #include <commdb.h> // CommDB |
|
21 #include <wdbifwlansettings.h> // CWLanSettings |
|
22 |
|
23 /*@{*/ |
|
24 //LIT's for commands |
|
25 _LIT(KCmdConnectSocketServ, "Connect"); |
|
26 _LIT(KCmdCloseSocketServ, "Close"); |
|
27 /*}@*/ |
|
28 |
|
29 CT_RSocketServData* CT_RSocketServData::NewL() |
|
30 { |
|
31 CT_RSocketServData * ret = new (ELeave) CT_RSocketServData(); |
|
32 CleanupStack::PushL(ret); |
|
33 ret->ConstructL(); |
|
34 CleanupStack::Pop(ret); |
|
35 return ret; |
|
36 } |
|
37 |
|
38 CT_RSocketServData::~CT_RSocketServData() |
|
39 { |
|
40 if (iSocketServ) |
|
41 { |
|
42 delete iSocketServ; |
|
43 iSocketServ = NULL; |
|
44 } |
|
45 |
|
46 } |
|
47 |
|
48 CT_RSocketServData::CT_RSocketServData() |
|
49 : |
|
50 iSocketServ(NULL) |
|
51 { |
|
52 } |
|
53 |
|
54 void CT_RSocketServData::ConstructL() |
|
55 { |
|
56 iSocketServ = new (ELeave)RSocketServ(); |
|
57 } |
|
58 |
|
59 TAny* CT_RSocketServData::GetObject() |
|
60 { |
|
61 return iSocketServ; |
|
62 } |
|
63 |
|
64 TBool CT_RSocketServData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& /*aSection*/, const TInt /*aAsyncErrorIndex*/) |
|
65 { |
|
66 TBool ret = ETrue; |
|
67 |
|
68 if(aCommand == KCmdConnectSocketServ) |
|
69 { |
|
70 DoCmdConnect(); |
|
71 } |
|
72 else if(aCommand == KCmdCloseSocketServ) |
|
73 { |
|
74 DoCmdClose(); |
|
75 } |
|
76 else |
|
77 { |
|
78 ERR_PRINTF1(_L("Unknown command")); |
|
79 ret = EFalse; |
|
80 } |
|
81 return ret; |
|
82 } |
|
83 |
|
84 /** |
|
85 * Connects to Socket Server. |
|
86 * Sets TEF error if not successful. |
|
87 */ |
|
88 void CT_RSocketServData::DoCmdConnect() |
|
89 { |
|
90 INFO_PRINTF1(_L("*START* CT_RSocketServData::DoCmdConnect")); |
|
91 TInt err(KErrNone); |
|
92 err = iSocketServ->Connect(); |
|
93 if(err == KErrNone) |
|
94 { |
|
95 INFO_PRINTF1(_L("Connected to Socket Server")); |
|
96 } |
|
97 else |
|
98 { |
|
99 ERR_PRINTF1(_L("iSocketServ->Connect() Fail")); |
|
100 ERR_PRINTF2(_L("Failed to connect to Socket server [%d]"), err); |
|
101 SetError(err); |
|
102 } |
|
103 |
|
104 |
|
105 INFO_PRINTF1(_L("*END* CT_RSocketServData::DoCmdConnect")); |
|
106 } |
|
107 |
|
108 /** |
|
109 * Closes Socket Server. |
|
110 * Sets TEF error if not successful. |
|
111 */ |
|
112 void CT_RSocketServData::DoCmdClose() |
|
113 { |
|
114 INFO_PRINTF1(_L("*START* CT_RSocketServData::DoCmdClose")); |
|
115 iSocketServ->Close(); |
|
116 INFO_PRINTF1(_L("*END* CT_RSocketServData::DoCmdClose")); |
|
117 } |
|
118 |