|
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 #include "pushconncompletedtimercontainer.h" |
|
19 #include "pushconstant.h" |
|
20 #include "logger.h" |
|
21 |
|
22 using namespace java::push; |
|
23 using namespace java::captain; |
|
24 using namespace java::comms; |
|
25 |
|
26 /** |
|
27 * |
|
28 */ |
|
29 PushConnCompletedTimer::PushConnCompletedTimer(int aTimerId,const std::wstring& aUri, |
|
30 const java::comms::CommsMessage& aCommsMsg) |
|
31 : mTimerId(aTimerId),mUri(aUri),mCommsMsg(aCommsMsg) |
|
32 { |
|
33 } |
|
34 |
|
35 /** |
|
36 * |
|
37 */ |
|
38 PushConnCompletedTimer::~PushConnCompletedTimer() |
|
39 { |
|
40 } |
|
41 |
|
42 /** |
|
43 * |
|
44 */ |
|
45 PushConnCompletedTimer::PushConnCompletedTimer(const PushConnCompletedTimer& aData) |
|
46 { |
|
47 *this = aData; |
|
48 } |
|
49 |
|
50 /** |
|
51 * |
|
52 */ |
|
53 PushConnCompletedTimer& PushConnCompletedTimer::operator=(const PushConnCompletedTimer& x) |
|
54 { |
|
55 mTimerId = x.mTimerId; |
|
56 mUri = x.mUri; |
|
57 mCommsMsg = x.mCommsMsg; |
|
58 return *this; |
|
59 } |
|
60 |
|
61 /** |
|
62 * |
|
63 */ |
|
64 PushConnCompletedTimerContainer::PushConnCompletedTimerContainer(TimerServerInterface& aTimerServer, |
|
65 PushConnCompletedTimerListener& aListener) |
|
66 : mTimerServer(aTimerServer),mListener(aListener) |
|
67 { |
|
68 JELOG2(EJavaPush); |
|
69 } |
|
70 |
|
71 /** |
|
72 * |
|
73 */ |
|
74 PushConnCompletedTimerContainer::~PushConnCompletedTimerContainer() |
|
75 { |
|
76 JELOG2(EJavaPush); |
|
77 |
|
78 //It is enough to clear content of timer list container without cancelling pending |
|
79 //timers because this object is deleted only when JavaCaptain process is closed. |
|
80 mTimerList.clear(); |
|
81 } |
|
82 |
|
83 /** |
|
84 * |
|
85 */ |
|
86 void PushConnCompletedTimerContainer::setTimer(const std::wstring& aUri,const CommsMessage& aMsg) |
|
87 { |
|
88 JELOG2(EJavaPush); |
|
89 |
|
90 int timerId = mTimerServer.timerCreateSeconds(TIMEOUT_VALUE_FOR_UNREG_RESPONSE,this); |
|
91 if (0 == timerId) |
|
92 { |
|
93 ELOG(EJavaPush,"ERROR!!! PushConnCompletedTimerContainer::setTimer() creation of the timer failed"); |
|
94 return; |
|
95 } |
|
96 PushConnCompletedTimer dataObj(timerId,aUri,aMsg); |
|
97 mTimerList.push_back(dataObj); |
|
98 } |
|
99 |
|
100 /** |
|
101 * |
|
102 */ |
|
103 void PushConnCompletedTimerContainer::cancelTimer(const std::wstring& aUri) |
|
104 { |
|
105 JELOG2(EJavaPush); |
|
106 |
|
107 for (TimerListIter_t iter = mTimerList.begin(); iter != mTimerList.end(); ++iter) |
|
108 { |
|
109 if (iter->mUri == aUri) |
|
110 { |
|
111 mTimerServer.timerCancel(iter->mTimerId); |
|
112 mListener.connCompletedTimerExpired(iter->mCommsMsg); |
|
113 mTimerList.erase(iter); |
|
114 break; |
|
115 } |
|
116 }//end for |
|
117 } |
|
118 |
|
119 /** |
|
120 * |
|
121 */ |
|
122 void PushConnCompletedTimerContainer::timerTimeout(const int& aTimerId) |
|
123 { |
|
124 JELOG2(EJavaPush); |
|
125 |
|
126 ELOG(EJavaPush, |
|
127 "ERROR!!! PushConnCompletedTimerContainer::timerTimeout Timeout occurs"); |
|
128 |
|
129 for (TimerListIter_t iter = mTimerList.begin(); iter != mTimerList.end(); ++iter) |
|
130 { |
|
131 if (iter->mTimerId == aTimerId) |
|
132 { |
|
133 mListener.connCompletedTimerExpired(iter->mCommsMsg); |
|
134 mTimerList.erase(iter); |
|
135 break; |
|
136 } |
|
137 }//end for |
|
138 } |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |