|
1 /* |
|
2 * Copyright (c) 2007 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: Data transfer interfaces. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef M_IRDATATRANSFEROBSERVER_H |
|
20 #define M_IRDATATRANSFEROBSERVER_H |
|
21 |
|
22 #include <e32def.h> |
|
23 |
|
24 class RHTTPSession; |
|
25 class MIRDataTransferObserver; |
|
26 |
|
27 |
|
28 /** |
|
29 * Data transfer tracker interface. |
|
30 * |
|
31 * Provides means to attach itself to an existing network session to track the data amounts |
|
32 * transferred through it, and also an API through which raw data amounts can be manually |
|
33 * inputted (this is mainy the case when raw sockets are used directly). |
|
34 * |
|
35 * For getting notifications from the application's data transfer amounts on the core side, |
|
36 * this class supports an observer interface through which data transfer events are notified. |
|
37 */ |
|
38 NONSHARABLE_CLASS( MIRDataTransferTracker ) |
|
39 { |
|
40 public: |
|
41 |
|
42 /** |
|
43 * Supported data transfer categories. |
|
44 */ |
|
45 enum TIRTransferCategory |
|
46 { |
|
47 |
|
48 /** |
|
49 * The category for the data is unknown. |
|
50 */ |
|
51 EIRTransferCategoryUnknown, |
|
52 |
|
53 /** |
|
54 * The category for the data is SDS. |
|
55 */ |
|
56 EIRTransferCategoryIsds, |
|
57 |
|
58 /** |
|
59 * The category for the data is content show. |
|
60 */ |
|
61 EIRTransferCategoryAudio |
|
62 |
|
63 }; |
|
64 |
|
65 /** |
|
66 * Simple struct to keep hold of all the different data amounts transferred. |
|
67 * |
|
68 * The actual total amount of bytes of transferred data through the connection |
|
69 * is the amount of total bytes sent added to the amount of total bytes received. |
|
70 */ |
|
71 NONSHARABLE_STRUCT( TIRDataTransferPckg ) |
|
72 { |
|
73 |
|
74 /** |
|
75 * The total amount of bytes sent originating from all traffic. |
|
76 * This is simply the sum of all the categorized data sent amounts. |
|
77 */ |
|
78 TInt iBytesSentTotal; |
|
79 |
|
80 /** |
|
81 * The total amount of bytes received originating from all traffic. |
|
82 * This is simply the sum of all the categorized data received amounts. |
|
83 */ |
|
84 TInt iBytesReceivedTotal; |
|
85 |
|
86 /** |
|
87 * The total amount of bytes sent originating from unknown traffic. |
|
88 */ |
|
89 TInt iBytesSentUnknown; |
|
90 |
|
91 /** |
|
92 * The total amount of bytes received originating from unknown traffic. |
|
93 */ |
|
94 TInt iBytesReceivedUnknown; |
|
95 |
|
96 /** |
|
97 * The total amount of bytes sent originating from station directory traffic. |
|
98 */ |
|
99 TInt iBytesSentIsds; |
|
100 |
|
101 /** |
|
102 * The total amount of bytes received originating from station directory traffic. |
|
103 */ |
|
104 TInt iBytesReceivedIsds; |
|
105 |
|
106 /** |
|
107 * The total amount of bytes sent originating from content show traffic. |
|
108 */ |
|
109 TInt iBytesSentAudio; |
|
110 |
|
111 /** |
|
112 * The total amount of bytes received originating from content show traffic. |
|
113 */ |
|
114 TInt iBytesReceivedAudio; |
|
115 |
|
116 }; |
|
117 |
|
118 public: |
|
119 |
|
120 /** |
|
121 * Sets the observer that is notified of data transfer events. |
|
122 * |
|
123 * @param aObserver The observer to set, or NULL if none. |
|
124 */ |
|
125 virtual void SetObserver( MIRDataTransferObserver* aObserver ) = 0; |
|
126 |
|
127 /** |
|
128 * Returns the current data transfer amounts. |
|
129 * |
|
130 * This always reflects the current situation, and thereby does not |
|
131 * take the threshold mechanism into account. |
|
132 * |
|
133 * @return The current data transfer amounts. |
|
134 */ |
|
135 virtual const TIRDataTransferPckg& TransferredData() const = 0; |
|
136 |
|
137 /** |
|
138 * Binds the tracker to an existing and opened HTTP session. |
|
139 * |
|
140 * @param aSession Session to bind the tracker to. |
|
141 * @param aCategory Transfer category to record the data under. |
|
142 */ |
|
143 virtual void BindL( RHTTPSession aSession, TIRTransferCategory aCategory ) = 0; |
|
144 |
|
145 /** |
|
146 * Notifies of raw bytes transferred through the connection. |
|
147 * |
|
148 * Raw sockets cannot be observer automatically, so if they are used, then manual |
|
149 * notification is required on the user's part. |
|
150 * |
|
151 * @param aBytesSent Bytes sent through the raw socket. |
|
152 * @param aBytesReceived Bytes received through the raw socket. |
|
153 * @param aCategory Transfer category to record the data under. |
|
154 */ |
|
155 virtual void RawDataTransferredL( TInt aBytesSent, |
|
156 TInt aBytesReceived, TIRTransferCategory aCategory ) = 0; |
|
157 |
|
158 }; |
|
159 |
|
160 /** |
|
161 * Interface which all data transfer events are passed through. |
|
162 */ |
|
163 class MIRDataTransferObserver |
|
164 { |
|
165 |
|
166 public: |
|
167 |
|
168 /** |
|
169 * Invoked when a data transfer event occurs. |
|
170 * |
|
171 * The amount of data supplied as the parameter is the absolute amount of data transferred during |
|
172 * the life time of the connection. The threshold after which the call back is invoked is internal, |
|
173 * resulting in that it may not always be instantly called unless a predefined amount of data has |
|
174 * already been transferred since the last call back was made. |
|
175 * |
|
176 * @param aData Data amounts that have been transferred through the connection. |
|
177 */ |
|
178 virtual void HandleDataTransferEventL( |
|
179 const MIRDataTransferTracker::TIRDataTransferPckg& aData ) = 0; |
|
180 }; |
|
181 |
|
182 #endif // M_IRDATATRANSFEROBSERVER_H |