|
1 /* |
|
2 * Copyright (c) 2004 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: Connection UI event mapper |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <E32std.h> |
|
20 #include <PEngPresenceEngineConsts2.h> |
|
21 #include "CnUiEventMapper.h" |
|
22 |
|
23 |
|
24 |
|
25 /** |
|
26 * Conversion struture to map |
|
27 * PEC engine & Connection UI events. |
|
28 */ |
|
29 struct SEventConversionItem |
|
30 { |
|
31 TPEngNWSessionSlotEvent iPecEvent; |
|
32 TIMPSPresenceServiceEvent iAppEvent; |
|
33 }; |
|
34 |
|
35 |
|
36 /** |
|
37 * Presence event conversion table. |
|
38 * NOTE!! The Connection UI unknown event |
|
39 * (EIMPSPresenceServiceUnknownEvent) may not |
|
40 * be used here. It is ment purely for unknown |
|
41 * events coming from PEC engine side. |
|
42 */ |
|
43 |
|
44 LOCAL_D SEventConversionItem const KEventEnums[] = |
|
45 { |
|
46 |
|
47 { EPEngEventAppNWPresenceSessionClosed, EIMPSPresenceServiceOffline }, |
|
48 { EPEngEventAppNWPresenceSessionOpened, EIMPSPresenceServiceOnline }, |
|
49 { EPEngEventNWSessionSlotRemoved, EIMPSPresenceServiceSlotRemoved }, |
|
50 { EPEngEventNWSessionSlotChanged, EIMPSPresenceServiceSlotChanged }, |
|
51 { EPEngEventNWSessionClosedByServer, EIMPSPresenceServiceForceLogOut } |
|
52 |
|
53 }; |
|
54 |
|
55 |
|
56 /** |
|
57 * Count of conversion items. |
|
58 */ |
|
59 const TInt KEventEnumsCount = sizeof ( KEventEnums ) / sizeof( SEventConversionItem ); |
|
60 |
|
61 |
|
62 |
|
63 // ================= MEMBER FUNCTIONS ======================= |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CnUiEventMapper::ConvertToAppEvent() |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 TBool CnUiEventMapper::ConvertToAppEvent( TPEngNWSessionSlotEvent aPecEvent, |
|
69 TIMPSPresenceServiceEvent& aAppEvent ) |
|
70 { |
|
71 //it is possible that some PEC engine release introduces new events |
|
72 //that do not have a matching pair in application level events |
|
73 //==> those are defaulted to EIMPSPresenceServiceUnknownEvent |
|
74 |
|
75 for ( TInt ii( 0 ); ii < KEventEnumsCount; ii++ ) |
|
76 { |
|
77 if ( KEventEnums[ ii ].iPecEvent == aPecEvent ) |
|
78 { |
|
79 //matching event enum found, use it |
|
80 aAppEvent = KEventEnums[ ii ].iAppEvent; |
|
81 return ETrue; |
|
82 } |
|
83 } |
|
84 |
|
85 aAppEvent = EIMPSPresenceServiceUnknownEvent; |
|
86 |
|
87 return EFalse; |
|
88 } |
|
89 |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CnUiEventMapper::ConvertToPecEvent() |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 TBool CnUiEventMapper::ConvertToPecEvent( TIMPSPresenceServiceEvent aAppEvent, |
|
96 TPEngNWSessionSlotEvent& aPecEvent ) |
|
97 { |
|
98 |
|
99 for ( TInt ii( 0 ); ii < KEventEnumsCount; ii++ ) |
|
100 { |
|
101 if ( KEventEnums[ ii ].iAppEvent == aAppEvent ) |
|
102 { |
|
103 //matching enum found, use it |
|
104 aPecEvent = KEventEnums[ ii ].iPecEvent; |
|
105 return ETrue; |
|
106 } |
|
107 } |
|
108 |
|
109 return EFalse; |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CnUiEventMapper::AddAllKnownPecEventsL() |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CnUiEventMapper::AddAllKnownPecEventsL( RArray< TPEngNWSessionSlotEvent >& aPecEvents ) |
|
118 { |
|
119 |
|
120 for ( TInt ii( 0 ); ii < KEventEnumsCount; ii++ ) |
|
121 { |
|
122 User::LeaveIfError( aPecEvents.Append( KEventEnums[ ii ].iPecEvent ) ); |
|
123 } |
|
124 |
|
125 } |
|
126 |
|
127 |
|
128 // End of File |
|
129 |