0
|
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: this file is used for wlan ODD appliction
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <EcmtGui.rsg>
|
|
19 |
|
|
20 |
#include "EcmtWlanOddSettingView.h"
|
|
21 |
#include "EcmtWlanOddSettingList.h"
|
|
22 |
#include "EcmtGui.hrh"
|
|
23 |
#include "EcmtGuiAppUi.h"
|
|
24 |
#include <aknnotewrappers.h>
|
|
25 |
#include <ES_SOCK.H>
|
|
26 |
#include <BAUTILS.H>
|
|
27 |
#include <aknmessagequerydialog.h> //for ip address message query
|
|
28 |
|
|
29 |
CWlanOddSettingView* CWlanOddSettingView::NewL()
|
|
30 |
{
|
|
31 |
CWlanOddSettingView* self = new (ELeave) CWlanOddSettingView;
|
|
32 |
CleanupStack::PushL(self);
|
|
33 |
self->ConstructL();
|
|
34 |
CleanupStack::Pop(self);
|
|
35 |
return self;
|
|
36 |
}
|
|
37 |
|
|
38 |
CWlanOddSettingView::CWlanOddSettingView()
|
|
39 |
{
|
|
40 |
}
|
|
41 |
|
|
42 |
CWlanOddSettingView::~CWlanOddSettingView()
|
|
43 |
{
|
|
44 |
if ( iContainer )
|
|
45 |
{
|
|
46 |
AppUi()->RemoveFromStack( iContainer );
|
|
47 |
delete iContainer;
|
|
48 |
}
|
|
49 |
}
|
|
50 |
|
|
51 |
|
|
52 |
TUid CWlanOddSettingView::Id() const
|
|
53 |
{
|
|
54 |
return TUid::Uid( EListboxSettingView );
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
void CWlanOddSettingView::HandleCommandL( TInt aCommand )
|
|
59 |
{
|
|
60 |
switch( aCommand )
|
|
61 |
{
|
|
62 |
case EListboxCmdChange:
|
|
63 |
iContainer->EditItemL( 0, ETrue );
|
|
64 |
break;
|
|
65 |
case EIp:
|
|
66 |
{
|
|
67 |
TBuf<20> ipAdds;
|
|
68 |
TRAPD(err,IPv4L(ipAdds));
|
|
69 |
if(KErrNone == err)
|
|
70 |
{
|
|
71 |
HBufC* buf;
|
|
72 |
buf = ipAdds.AllocL();
|
|
73 |
CleanupStack::PushL(buf);
|
|
74 |
CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*buf);
|
|
75 |
dlg->PrepareLC(R_IP_ADDRESS_DIALOG);
|
|
76 |
dlg->RunLD();
|
|
77 |
CleanupStack::PopAndDestroy(buf);
|
|
78 |
}
|
|
79 |
}
|
|
80 |
break;
|
|
81 |
case EDeleteJavaDir:
|
|
82 |
{
|
|
83 |
User::InfoPrint(_L("deleting java dir"));
|
|
84 |
DelteJavaDirL();
|
|
85 |
}
|
|
86 |
break;
|
|
87 |
case EAknSoftkeyBack:
|
|
88 |
AppUi()->ActivateLocalViewL( TUid::Uid( EEcmtLogViewId ) );
|
|
89 |
break;
|
|
90 |
default:
|
|
91 |
AppUi()->HandleCommandL(aCommand);
|
|
92 |
break;
|
|
93 |
}
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
void CWlanOddSettingView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
|
|
98 |
TUid /*aCustomMessageId*/,
|
|
99 |
const TDesC8& /*aCustomMessage*/ )
|
|
100 |
{
|
|
101 |
iContainer = CWlanSettingList::NewL();
|
|
102 |
|
|
103 |
iContainer->SetMopParent( this );
|
|
104 |
iContainer->ConstructFromResourceL( R_LISTBOX_SETTING_ITEM_LIST );
|
|
105 |
AppUi()->AddToStackL( *this, iContainer );
|
|
106 |
|
|
107 |
iContainer->MakeVisible( ETrue );
|
|
108 |
iContainer->SetRect( ClientRect() );
|
|
109 |
iContainer->ActivateL();
|
|
110 |
}
|
|
111 |
|
|
112 |
void CWlanOddSettingView::DoDeactivate()
|
|
113 |
{
|
|
114 |
if ( iContainer )
|
|
115 |
{
|
|
116 |
AppUi()->RemoveFromViewStack( *this, iContainer );
|
|
117 |
delete iContainer;
|
|
118 |
iContainer = NULL;
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
|
122 |
void CWlanOddSettingView::ConstructL()
|
|
123 |
{
|
|
124 |
BaseConstructL(R_LISTBOX_SETTINGS_VIEW);
|
|
125 |
}
|
|
126 |
|
|
127 |
void CWlanOddSettingView::DynInitMenuPaneL( TInt aResourceId,
|
|
128 |
CEikMenuPane* aMenuPane )
|
|
129 |
{
|
|
130 |
|
|
131 |
}
|
|
132 |
|
|
133 |
|
|
134 |
void CWlanOddSettingView::HandleSizeChange( TInt aType )
|
|
135 |
{
|
|
136 |
if( iContainer )
|
|
137 |
{
|
|
138 |
iContainer->HandleResourceChange( aType );
|
|
139 |
|
|
140 |
if( aType==KEikDynamicLayoutVariantSwitch )
|
|
141 |
{
|
|
142 |
TRect rect;
|
|
143 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
|
|
144 |
iContainer->SetRect(rect);
|
|
145 |
}
|
|
146 |
}
|
|
147 |
}
|
|
148 |
//this function is used to get the ip address of the device
|
|
149 |
void CWlanOddSettingView::IPv4L(TDes& aIpAdds)
|
|
150 |
{
|
|
151 |
TBuf<20> deviPAdds;
|
|
152 |
RSocketServ socketServ;
|
|
153 |
TInetAddr inetAddr;
|
|
154 |
RSocket sock;
|
|
155 |
User::LeaveIfError(socketServ.Connect());
|
|
156 |
User::LeaveIfError(sock.Open(socketServ, KAfInet, KSockStream, KProtocolInetTcp));
|
|
157 |
//Get IP information from the socket
|
|
158 |
TSoInetInterfaceInfo ifInfo;
|
|
159 |
TPckg<TSoInetInterfaceInfo> ifInfoPkg(ifInfo);
|
|
160 |
TSoInetIfQuery ifQuery;
|
|
161 |
TPckg<TSoInetIfQuery> ifQueryPkg(ifQuery);
|
|
162 |
User::LeaveIfError(sock.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl));
|
|
163 |
while(sock.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, ifInfoPkg) == KErrNone)
|
|
164 |
{
|
|
165 |
ifQuery.iName = ifInfo.iName;
|
|
166 |
TInt err = sock.GetOpt(KSoInetIfQueryByName, KSolInetIfQuery, ifQueryPkg);
|
|
167 |
if( err == KErrNone )
|
|
168 |
{
|
|
169 |
if (!ifInfo.iAddress.IsUnspecified() && !ifInfo.iAddress.IsLoopback() && !ifInfo.iAddress.IsLinkLocal())
|
|
170 |
{
|
|
171 |
inetAddr = ifInfo.iAddress;
|
|
172 |
inetAddr.ConvertToV4();
|
|
173 |
inetAddr.Output(deviPAdds);
|
|
174 |
aIpAdds.Copy(deviPAdds);
|
|
175 |
}
|
|
176 |
}
|
|
177 |
else if( err !=KErrNone )
|
|
178 |
{
|
|
179 |
sock.Close();
|
|
180 |
socketServ.Close();
|
|
181 |
}
|
|
182 |
} // while
|
|
183 |
sock.Close();
|
|
184 |
socketServ.Close();
|
|
185 |
}
|
|
186 |
|
|
187 |
void CWlanOddSettingView::DelteJavaDirL()
|
|
188 |
{
|
|
189 |
//path of java dir needs to be created for wlan odd
|
|
190 |
_LIT(KWlanJavaDir,"c:\\java\\");
|
|
191 |
RFs fs;
|
|
192 |
User::LeaveIfError(fs.Connect());
|
|
193 |
CleanupClosePushL (fs);
|
|
194 |
CFileMan* image = CFileMan::NewL (fs);
|
|
195 |
CleanupStack::PushL (image);
|
|
196 |
TBool folderExist = EFalse;
|
|
197 |
//check the path exists or not
|
|
198 |
folderExist = BaflUtils::FolderExists (fs, KWlanJavaDir);
|
|
199 |
//if exists then remove the directory and create new
|
|
200 |
if(folderExist)
|
|
201 |
{
|
|
202 |
User::LeaveIfError(image->RmDir (KWlanJavaDir));
|
|
203 |
}
|
|
204 |
CleanupStack::PopAndDestroy(2);//image or CFileMan object and fs
|
|
205 |
} |