1 /* |
|
2 * Copyright (c) 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 #ifndef LOGSEVENT_H |
|
19 #define LOGSEVENT_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <logsexport.h> |
|
23 #include <QDateTime> |
|
24 #include <qmobilityglobal.h> |
|
25 |
|
26 // FORWARD DECLARATION |
|
27 class LogsEventData; |
|
28 class LogsEventStrings; |
|
29 class CLogEvent; |
|
30 |
|
31 QTM_BEGIN_NAMESPACE |
|
32 class QContactName; |
|
33 class QContactManager; |
|
34 QTM_END_NAMESPACE |
|
35 |
|
36 QTM_USE_NAMESPACE |
|
37 |
|
38 // CLASS DECLARATION |
|
39 |
|
40 /** |
|
41 * Logs event information. |
|
42 */ |
|
43 class LogsEvent |
|
44 { |
|
45 public: |
|
46 |
|
47 // direction of the event |
|
48 enum LogsDirection |
|
49 { |
|
50 DirUndefined = -1, // undefined |
|
51 DirIn = 0, // incoming |
|
52 DirOut = 1, // outgoing |
|
53 DirMissed = 2 // missed |
|
54 }; |
|
55 |
|
56 // type of the event |
|
57 enum LogsEventType |
|
58 { |
|
59 TypeUndefined = -1, |
|
60 TypeVoiceCall, |
|
61 TypeVideoCall, |
|
62 TypeVoIPCall |
|
63 }; |
|
64 |
|
65 enum LogsEventState |
|
66 { |
|
67 EventAdded, |
|
68 EventUpdated, |
|
69 EventNotUpdated |
|
70 }; |
|
71 |
|
72 public: |
|
73 |
|
74 /** |
|
75 * Constructor. |
|
76 */ |
|
77 LogsEvent(); |
|
78 |
|
79 public: // Exported API |
|
80 |
|
81 /** |
|
82 * Copy constructor. |
|
83 */ |
|
84 LOGSENGINE_EXPORT LogsEvent( const LogsEvent& event ); |
|
85 |
|
86 /** |
|
87 * Destructor. |
|
88 */ |
|
89 LOGSENGINE_EXPORT virtual ~LogsEvent(); |
|
90 |
|
91 /** |
|
92 * Get time when event occurred. |
|
93 * @return date time |
|
94 */ |
|
95 LOGSENGINE_EXPORT QDateTime time() const; |
|
96 |
|
97 /** |
|
98 * Get unique id of the event |
|
99 * @return id |
|
100 */ |
|
101 LOGSENGINE_EXPORT int logId() const; |
|
102 |
|
103 /** |
|
104 * Get phone number associated with the event. |
|
105 * @return number |
|
106 */ |
|
107 LOGSENGINE_EXPORT const QString& number() const; |
|
108 |
|
109 /** |
|
110 * Get remote party information. |
|
111 * @return remote party name |
|
112 */ |
|
113 LOGSENGINE_EXPORT const QString& remoteParty() const; |
|
114 |
|
115 /** |
|
116 * Get direction of the event |
|
117 * @return direction |
|
118 */ |
|
119 LOGSENGINE_EXPORT LogsDirection direction() const; |
|
120 |
|
121 /** |
|
122 * Get event type |
|
123 * @return event type |
|
124 */ |
|
125 LOGSENGINE_EXPORT LogsEventType eventType() const; |
|
126 |
|
127 /** |
|
128 * Get number of duplicated events (e.g. 5 missing calls from x) |
|
129 * @return number of duplicates |
|
130 */ |
|
131 LOGSENGINE_EXPORT int duplicates() const; |
|
132 |
|
133 /** |
|
134 * Check whether event was generated when using alternative line service |
|
135 * @return true if ALS was used |
|
136 */ |
|
137 LOGSENGINE_EXPORT bool ALS() const; |
|
138 |
|
139 /** |
|
140 * Get ringing duration |
|
141 * return rinding duration is seconds |
|
142 */ |
|
143 LOGSENGINE_EXPORT int ringDuration() const; |
|
144 |
|
145 /** |
|
146 * Get duration of event |
|
147 * @return duration in seconds |
|
148 */ |
|
149 LOGSENGINE_EXPORT int duration() const; |
|
150 |
|
151 /** |
|
152 * Number for calling to remote party of the event |
|
153 * @return number |
|
154 */ |
|
155 LOGSENGINE_EXPORT QString getNumberForCalling(); |
|
156 |
|
157 /** |
|
158 * Get contact id of associated contact |
|
159 * @return contact id, zero if no associated contact exist. |
|
160 */ |
|
161 LOGSENGINE_EXPORT unsigned int contactLocalId() const; |
|
162 |
|
163 /** |
|
164 * Check whether event has been read already |
|
165 * @return true if event has been marked as read |
|
166 */ |
|
167 LOGSENGINE_EXPORT bool isRead() const; |
|
168 |
|
169 public: |
|
170 |
|
171 /** |
|
172 * Initialized the event with contents of given source event. |
|
173 * Event state and view status are updated automatically at |
|
174 * this phase. |
|
175 * @param source, source event |
|
176 * @param strings, list of strings used for comparison |
|
177 */ |
|
178 void initializeEventL( const CLogEvent& source, |
|
179 const LogsEventStrings& strings ); |
|
180 |
|
181 /** |
|
182 * Check event's view status which tells whether the event is |
|
183 * still valid or not. If event is not anymore in view, it |
|
184 * is not probably needed anymore. |
|
185 */ |
|
186 bool isInView() const; |
|
187 |
|
188 /** |
|
189 * Get state of the event. Event state is updated |
|
190 * always at initialization phase. See initializeEventL. |
|
191 */ |
|
192 LogsEventState eventState() const; |
|
193 |
|
194 bool setIsRead(bool isRead); |
|
195 |
|
196 int eventUid() const; |
|
197 |
|
198 LogsEventData* logsEventData() const; |
|
199 |
|
200 bool CNAP() const { return false; }; |
|
201 |
|
202 /** |
|
203 * Sets current index of the event. |
|
204 */ |
|
205 void setIndex(int index); |
|
206 |
|
207 /** |
|
208 * Returns last set index for the event. |
|
209 */ |
|
210 int index() const; |
|
211 |
|
212 /** |
|
213 * Set view status of the event. |
|
214 */ |
|
215 void setIsInView(bool isInView); |
|
216 |
|
217 /** |
|
218 * Set number of duplicates for this events (e.g. 2 missed calls) |
|
219 */ |
|
220 void setDuplicates( int duplicates ); |
|
221 |
|
222 /** |
|
223 * Set remote party name for the event. |
|
224 */ |
|
225 void setRemoteParty( const QString& remoteParty ); |
|
226 |
|
227 /** |
|
228 * Check if event is valid. |
|
229 * @return true if valid, otherwise false |
|
230 */ |
|
231 bool validate(); |
|
232 |
|
233 /** |
|
234 * Return direction as string |
|
235 */ |
|
236 QString directionAsString() const; |
|
237 |
|
238 /** |
|
239 * Return event type as string |
|
240 */ |
|
241 QString typeAsString() const; |
|
242 |
|
243 /** |
|
244 * Search matching contact from contacts and update |
|
245 * event with possible match. |
|
246 * @param manager |
|
247 * @return name of matched contact, zero length string if no match found. |
|
248 */ |
|
249 QString updateRemotePartyFromContacts(QContactManager& manager); |
|
250 |
|
251 /** |
|
252 * Prepares the event for contact matching. |
|
253 */ |
|
254 void prepareForContactMatching(); |
|
255 |
|
256 /** |
|
257 * Event has been marked as seen but database might not yet contain the change |
|
258 */ |
|
259 void markedAsSeenLocally(bool markedAsSeen); |
|
260 |
|
261 /** |
|
262 * Check whether event is locally seen. |
|
263 */ |
|
264 bool isSeenLocally() const; |
|
265 |
|
266 |
|
267 private: |
|
268 |
|
269 bool setTime( const QDateTime& time ); |
|
270 |
|
271 void setLogId( const int logId ); |
|
272 |
|
273 bool setNumber( const QString& number ); |
|
274 |
|
275 bool setDirection( LogsDirection aDirection ); |
|
276 |
|
277 void setEventUid( int uid ); |
|
278 |
|
279 void setEventType( LogsEventType aEventType ); |
|
280 |
|
281 void setLogsEventData( LogsEventData* logsEventData ); |
|
282 |
|
283 void setALS( bool aALS ); |
|
284 |
|
285 void setRingDuration( int ringDuration ); |
|
286 |
|
287 bool isEmergencyNumber( const QString& number ); |
|
288 |
|
289 void setDuration( int duration ); |
|
290 |
|
291 void setContactLocalId( unsigned int id ); |
|
292 |
|
293 QString stripPhoneNumber(const QString& num); |
|
294 |
|
295 QString parseContactName(const QContactName& name); |
|
296 |
|
297 |
|
298 private: // data |
|
299 |
|
300 int mLogId; |
|
301 LogsDirection mDirection; |
|
302 LogsEventType mEventType; |
|
303 int mUid; |
|
304 LogsEventData* mLogsEventData; |
|
305 QString mRemoteParty; |
|
306 QString mNumber; |
|
307 int mDuplicates; |
|
308 QDateTime mTime; |
|
309 int mRingDuration; |
|
310 bool mIsRead; |
|
311 bool mIsALS; |
|
312 int mDuration; |
|
313 |
|
314 int mIndex; |
|
315 bool mIsInView; |
|
316 LogsEventState mEventState; |
|
317 bool mIsLocallySeen; |
|
318 |
|
319 private: |
|
320 |
|
321 friend class LogsEventParser; |
|
322 friend class LogsReaderStateFillDetails; |
|
323 |
|
324 private: // Testing related friend definitions |
|
325 |
|
326 #ifdef LOGSDBCONNECTOR_SIMULATION |
|
327 friend class LogsDbConnector; |
|
328 #endif |
|
329 friend class UT_LogsFilter; |
|
330 friend class UT_LogsModel; |
|
331 friend class UT_LogsEvent; |
|
332 friend class UT_LogsDbConnector; |
|
333 friend class UT_LogsCall; |
|
334 friend class UT_LogsContact; |
|
335 friend class UT_LogsEventParser; |
|
336 friend class UT_LogsEventDataParser; |
|
337 friend class UT_LogsReaderStates; |
|
338 friend class UT_LogsDetailsModel; |
|
339 friend class UT_LogsMessage; |
|
340 friend class UT_LogsCustomFilter; |
|
341 friend class UT_LogsMatchesModel; |
|
342 }; |
|
343 |
|
344 #endif // LOGSEVENT_H |
|
345 |
|
346 |
|
347 |
|
348 // End of File |
|