42 #include "cntabstractsimrequest.h" |
42 #include "cntabstractsimrequest.h" |
43 #include "cntsymbiansimengine.h" |
43 #include "cntsymbiansimengine.h" |
44 #include "cntsimstore.h" |
44 #include "cntsimstore.h" |
45 #include <QTimer> |
45 #include <QTimer> |
46 |
46 |
47 CntAbstractSimRequest::CntAbstractSimRequest(CntSymbianSimEngine *engine) |
47 CntAbstractSimRequest::CntAbstractSimRequest(CntSymbianSimEngine *engine, QContactAbstractRequest *req) |
48 :QObject(engine), |
48 :QObject(engine), |
49 m_timer(0) |
49 m_request(req), |
|
50 m_timer(0), |
|
51 m_retryCount(0) |
50 { |
52 { |
51 |
53 |
|
54 } |
|
55 |
|
56 bool CntAbstractSimRequest::start() |
|
57 { |
|
58 if (m_request->isActive()) |
|
59 return false; |
|
60 |
|
61 m_retryCount = 0; |
|
62 |
|
63 singleShotTimer(KRequestDelay, this, SLOT(run())); |
|
64 QContactManagerEngine::updateRequestState(m_request, QContactAbstractRequest::ActiveState); |
|
65 return true; |
|
66 } |
|
67 |
|
68 bool CntAbstractSimRequest::cancel() |
|
69 { |
|
70 if (m_request->isActive()) { |
|
71 cancelTimer(); |
|
72 simStore()->cancel(); |
|
73 QContactManagerEngine::updateRequestState(m_request, QContactAbstractRequest::CanceledState); |
|
74 return true; |
|
75 } |
|
76 return false; |
|
77 } |
|
78 |
|
79 bool CntAbstractSimRequest::waitAndRetry() |
|
80 { |
|
81 if (m_retryCount < KMaxRetryCount) |
|
82 { |
|
83 singleShotTimer(KRequestDelay, this, SLOT(run())); |
|
84 m_retryCount++; |
|
85 return true; |
|
86 } |
|
87 return false; |
52 } |
88 } |
53 |
89 |
54 void CntAbstractSimRequest::singleShotTimer(int msec, QObject *receiver, const char *member) |
90 void CntAbstractSimRequest::singleShotTimer(int msec, QObject *receiver, const char *member) |
55 { |
91 { |
56 // We could use QTimer::singleShot but there is no way to cancel it... |
92 // We could use QTimer::singleShot but there is no way to cancel it... |