24
|
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 |
#ifndef T_RSOCKET_DATA_H
|
|
20 |
#define T_RSOCKET_DATA_H
|
|
21 |
|
|
22 |
// User Includes
|
|
23 |
#include "DataWrapperBase.h"
|
|
24 |
#include "BreathSaver.h"
|
|
25 |
// EPOC includes
|
|
26 |
#include <datawrapper.h>
|
|
27 |
#include <w32std.h>
|
|
28 |
#include <e32std.h>
|
|
29 |
|
|
30 |
#include <es_sock.h> // TSockAddr address
|
|
31 |
#include <in_sock.h> // TCP/IP Protocol and address family
|
|
32 |
|
|
33 |
|
|
34 |
// For ETel API.
|
|
35 |
#include <etelmm.h>
|
|
36 |
|
|
37 |
|
|
38 |
class CT_RSocketData: public CDataWrapperBase
|
|
39 |
{
|
|
40 |
public:
|
|
41 |
/**
|
|
42 |
* Two phase constructor
|
|
43 |
*/
|
|
44 |
static CT_RSocketData* NewL();
|
|
45 |
|
|
46 |
virtual TAny* GetObject();
|
|
47 |
virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
|
|
48 |
|
|
49 |
~CT_RSocketData();
|
|
50 |
|
|
51 |
public:
|
|
52 |
void RunL(CActive* aActive, TInt aIndex);
|
|
53 |
|
|
54 |
protected:
|
|
55 |
/**
|
|
56 |
* Protected constructor. First phase construction
|
|
57 |
*/
|
|
58 |
CT_RSocketData();
|
|
59 |
|
|
60 |
void ConstructL();
|
|
61 |
|
|
62 |
private:
|
|
63 |
void InitialiseL();
|
|
64 |
void CloseSocketServer();
|
|
65 |
|
|
66 |
void DoCmdOpenL(const TTEFSectionName& aSection);
|
|
67 |
void DoCmdInfoL(const TTEFSectionName& aSection);
|
|
68 |
void DoCmdConnectL(const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
|
|
69 |
void DoCmdShutDown(const TInt aAsyncErrorIndex);
|
|
70 |
void DoCmdClose();
|
|
71 |
void DoCmdRecvOneOrMore(const TTEFSectionName& aSection);
|
|
72 |
void DoCmdWrite(const TInt aAsyncErrorIndex);
|
|
73 |
void DoCmdSendBytesToSocket(const TTEFSectionName& aSection);
|
|
74 |
void DoCmdWriteRequest(const TTEFSectionName& aSection, const TInt aAsyncErrorIndex);
|
|
75 |
void DoCmdUtilityStartFile(const TTEFSectionName& aSection);
|
|
76 |
void DoCmdUtilityStartDealer(const TTEFSectionName& aSection);
|
|
77 |
void DoCmdUtilityEndFile(const TTEFSectionName& aSection);
|
|
78 |
void DoCmdUtilityCalculateDownloadStats(const TTEFSectionName& aSection);
|
|
79 |
void DoCmdUtilityCheckHSDPAL(const TTEFSectionName& aSection);
|
|
80 |
void DoCmdResponseFromServer(const TTEFSectionName& aSection);
|
|
81 |
|
|
82 |
//Helpers
|
|
83 |
TBool CheckHSDPAIndicator();
|
|
84 |
TBool CheckHSDPASupportL(RMobilePhone &aMobilePhone);
|
|
85 |
TBool CheckHSDPAUsageL(RMobilePhone &aMobilePhone);
|
|
86 |
|
|
87 |
//Upload
|
|
88 |
void DoCmdUtilityBuildRequest(const TTEFSectionName& aSection);
|
|
89 |
void DoCmdUtilityEndRequest();
|
|
90 |
///End Upload
|
|
91 |
TInt SendBytesToSocket(TInt aBytes, TInt aDuration);
|
|
92 |
TReal ThroughputInKiloBits( TTimeIntervalMicroSeconds aDuration, TInt aBytes );
|
|
93 |
TReal ThroughputInMegaBits( TTimeIntervalMicroSeconds aDuration, TInt aBytes );
|
|
94 |
TInt SetThroughput( const TReal aThroughput );
|
|
95 |
|
|
96 |
private:
|
|
97 |
/**
|
|
98 |
* RSocket
|
|
99 |
*/
|
|
100 |
RSocket* iSocket;
|
|
101 |
/**
|
|
102 |
* CActive callback for asynchronous functions
|
|
103 |
*/
|
|
104 |
CActiveCallback* iActiveCallback;
|
|
105 |
/**
|
|
106 |
* Name entry stores name record for IPC.
|
|
107 |
*/
|
|
108 |
TNameEntry iNameEntry;
|
|
109 |
/**
|
|
110 |
* Timestamps
|
|
111 |
*/
|
|
112 |
TTime iEnd;
|
|
113 |
TTime iStart;
|
|
114 |
/**
|
|
115 |
* Total bytes received
|
|
116 |
*/
|
|
117 |
TInt iTotalReceived;
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Helper class that is used to save data.
|
|
121 |
*/
|
|
122 |
CBreathSaver* iBreathSaver;
|
|
123 |
|
|
124 |
/**
|
|
125 |
* TBuf used to send http requests
|
|
126 |
*/
|
|
127 |
TBuf8<456> iRequest;
|
|
128 |
|
|
129 |
TUid iPropertyCategory;
|
|
130 |
TUint iPropertyKey;
|
|
131 |
TInt iMaxPropertyLength;
|
|
132 |
|
|
133 |
};
|
|
134 |
|
|
135 |
#endif //T_RSOCKET_DATA_H
|
|
136 |
|