|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "cntsimstoreeventlistener.h" |
|
43 #include "cntsymbiansimengine.h" |
|
44 #include <qcontactchangeset.h> |
|
45 #ifdef SYMBIANSIM_BACKEND_USE_ETEL_TESTSERVER |
|
46 #include <etelmm_etel_test_server.h> |
|
47 #else |
|
48 #include <etelmm.h> |
|
49 #endif |
|
50 #include <QDebug> |
|
51 |
|
52 QTM_USE_NAMESPACE |
|
53 |
|
54 CntSimStoreEventListener::CntSimStoreEventListener(CntSymbianSimEngine &engine, RMobilePhoneBookStore& store) |
|
55 :CActive(CActive::EPriorityUserInput), |
|
56 m_engine(engine), |
|
57 m_store(store) |
|
58 { |
|
59 // NOTE: |
|
60 // The AO priority must be higher than CntSimStorePrivate's priority. |
|
61 // Otherwise we might not receive all store events. This is because a new |
|
62 // store request might be issued before the listener has had the chance to |
|
63 // issue a new notify request. |
|
64 CActiveScheduler::Add(this); |
|
65 } |
|
66 |
|
67 CntSimStoreEventListener::~CntSimStoreEventListener() |
|
68 { |
|
69 Cancel(); |
|
70 } |
|
71 |
|
72 void CntSimStoreEventListener::start() |
|
73 { |
|
74 if (IsActive()) |
|
75 return; |
|
76 |
|
77 m_store.NotifyStoreEvent(iStatus, m_event, m_index); |
|
78 SetActive(); |
|
79 } |
|
80 |
|
81 void CntSimStoreEventListener::DoCancel() |
|
82 { |
|
83 if (IsActive()) |
|
84 m_store.CancelAsyncRequest(EMobilePhoneStoreNotifyStoreEvent); |
|
85 } |
|
86 |
|
87 void CntSimStoreEventListener::RunL() |
|
88 { |
|
89 if (iStatus.Int()) { |
|
90 qWarning() << "Failed to listen store events!" << iStatus.Int(); |
|
91 return; |
|
92 } |
|
93 |
|
94 // The store may report several events at the same time. |
|
95 |
|
96 QContactChangeSet changeSet; |
|
97 |
|
98 if (m_event & RMobilePhoneStore::KStoreFull) { |
|
99 //qDebug() << "SIM store event: full"; |
|
100 } |
|
101 if (m_event & RMobilePhoneStore::KStoreHasSpace) { |
|
102 //qDebug() << "SIM store event: has space"; |
|
103 } |
|
104 if (m_event & RMobilePhoneStore::KStoreEmpty ) { |
|
105 //qDebug() << "SIM store event: empty" << m_index; |
|
106 changeSet.insertRemovedContact(m_index); |
|
107 } |
|
108 if (m_event & RMobilePhoneStore::KStoreEntryAdded) { |
|
109 //qDebug() << "SIM store event: added" << m_index; |
|
110 changeSet.insertAddedContact(m_index); |
|
111 } |
|
112 if (m_event & RMobilePhoneStore::KStoreEntryDeleted) { |
|
113 //qDebug() << "SIM store event: deleted" << m_index; |
|
114 changeSet.insertRemovedContact(m_index); |
|
115 } |
|
116 if (m_event & RMobilePhoneStore::KStoreEntryChanged) { |
|
117 //qDebug() << "SIM store event: changed" << m_index; |
|
118 changeSet.insertChangedContact(m_index); |
|
119 } |
|
120 if (m_event & RMobilePhoneStore::KStoreDoRefresh) { |
|
121 //qDebug() << "SIM store event: do refresh"; |
|
122 changeSet.setDataChanged(true); |
|
123 } |
|
124 |
|
125 changeSet.emitSignals(&m_engine); |
|
126 |
|
127 start(); |
|
128 } |