|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #include "cagentdlgproc.h" |
|
22 |
|
23 |
|
24 void CAgentDialogProcessor::Enque(CAgentBase* aItem) |
|
25 { |
|
26 iQueue.AddLast(aItem); |
|
27 iQueueLength++; |
|
28 } |
|
29 |
|
30 |
|
31 TBool CAgentDialogProcessor::IsQueued(CAgentBase* aItem) |
|
32 { |
|
33 TSglQueIter<CAgentBase*> iter(iQueue); |
|
34 CAgentBase** item; |
|
35 while ( (item = iter++) != NULL ) |
|
36 { |
|
37 if (*item == aItem) |
|
38 { |
|
39 return ETrue; |
|
40 } |
|
41 } |
|
42 |
|
43 return EFalse; |
|
44 } |
|
45 |
|
46 |
|
47 CAgentBase* CAgentDialogProcessor::Deque() |
|
48 { |
|
49 CAgentBase* headOfQueue = NULL; |
|
50 if (!IsEmpty()) |
|
51 { |
|
52 headOfQueue = *iQueue.First(); |
|
53 iQueue.Remove(headOfQueue); |
|
54 iQueueLength--; |
|
55 } |
|
56 |
|
57 return headOfQueue; |
|
58 } |
|
59 |
|
60 |
|
61 CAgentDialogProcessor::CAgentDialogProcessor() |
|
62 { |
|
63 } |
|
64 |
|
65 |
|
66 void CAgentDialogProcessor::PromptForReconnect(CAgentBase& aAgent) |
|
67 { |
|
68 if (iCurrentRequest) |
|
69 { |
|
70 if (iCurrentRequest == &aAgent || IsQueued(&aAgent)) |
|
71 { |
|
72 return; |
|
73 } |
|
74 |
|
75 Enque(&aAgent); |
|
76 } |
|
77 else |
|
78 { |
|
79 iCurrentRequest = &aAgent; |
|
80 aAgent.DialogProcessor()->Reconnect(*this); |
|
81 } |
|
82 } |
|
83 |
|
84 |
|
85 void CAgentDialogProcessor::CancelPromptForReconnect(CAgentBase& aAgent) |
|
86 { |
|
87 if (iCurrentRequest == &aAgent) |
|
88 { |
|
89 iCurrentRequest = NULL; |
|
90 aAgent.DialogProcessor()->CancelEverything(); |
|
91 } |
|
92 else |
|
93 { |
|
94 CAgentBase* a = &aAgent; |
|
95 if (IsQueued(a)) |
|
96 { |
|
97 iQueue.Remove(a); |
|
98 } |
|
99 } |
|
100 } |
|
101 |
|
102 void CAgentDialogProcessor::MDPOReconnectComplete(TInt aError) |
|
103 { |
|
104 CAgentBase* completedRequest = iCurrentRequest; |
|
105 iCurrentRequest = Deque(); |
|
106 if (iCurrentRequest) |
|
107 { |
|
108 // Another prompt to display |
|
109 iCurrentRequest->DialogProcessor()->Reconnect(*this); |
|
110 } |
|
111 if (completedRequest) |
|
112 { |
|
113 completedRequest->ReconnectComplete(aError); |
|
114 } |
|
115 } |
|
116 |
|
117 |