|
1 /* |
|
2 * Copyright (c) 2002-2007 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: Phonebook 2 Nameslist UI control UI extension. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPbk2EcePresenceEngine_H |
|
20 #define CPbk2EcePresenceEngine_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <MPbk2ContactUiControlExtension.h> |
|
25 |
|
26 #include "CPbk2IconArray.h" |
|
27 #include "TPbk2IconId.h" |
|
28 #include "CPbk2NlxPresenceIconInfo.h" |
|
29 #include "CPbk2NlxPresenceSubscriptionInfo.h" |
|
30 #include "MPbk2EcePresenceEngineObserver.h" |
|
31 |
|
32 #include <mcontactpresenceobs.h> |
|
33 #include <mcontactpresenceinfo.h> |
|
34 // FORWARD DECLARATIONS |
|
35 class CVPbkContactManager; |
|
36 class MVPbkContactLink; |
|
37 class MContactPresence; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * Phonebook 2 ECE Presence Engine. |
|
43 * |
|
44 */ |
|
45 NONSHARABLE_CLASS(CPbk2EcePresenceEngine) : |
|
46 public CBase, |
|
47 public MContactPresenceObs |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 |
|
51 /** |
|
52 * Creates a new instance of this class. |
|
53 * |
|
54 * @param aContactManager Virtual Phonebook contact manager. |
|
55 * @param aObserver Observer to this engine. |
|
56 * @param aIconSize Required icon size |
|
57 * @return A new instance of this class. |
|
58 */ |
|
59 static CPbk2EcePresenceEngine* NewL( |
|
60 CVPbkContactManager& aContactManager, |
|
61 MPbk2EcePresenceEngineObserver& aObserver, |
|
62 TSize aIconSize ); |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 ~CPbk2EcePresenceEngine(); |
|
68 |
|
69 private: // Construction & destruction |
|
70 CPbk2EcePresenceEngine( |
|
71 CVPbkContactManager& aContactManager, |
|
72 MPbk2EcePresenceEngineObserver& aObserver, |
|
73 TSize aIconSize ); |
|
74 void ConstructL(); |
|
75 |
|
76 public: // new methods |
|
77 |
|
78 /** |
|
79 * Subscribe for presence information of a certain contact. |
|
80 * |
|
81 * @param aLink A contact link. |
|
82 */ |
|
83 void SubscribeContactPresenceL( const MVPbkContactLink& aLink ); |
|
84 |
|
85 /** |
|
86 * Gets the ID of the current presence icon of a contact. |
|
87 * The TBool return value tells whether the icon ID and icon is available. |
|
88 * If the ID is successfully obtained, then CreateIconCopyLC() can be called. |
|
89 * |
|
90 * @param aLink A contact link. |
|
91 * |
|
92 * @return ETrue if the icon ID was available, and vice versa. |
|
93 */ |
|
94 TBool GetIconIdForContact( const MVPbkContactLink& aLink, TPbk2IconId& aIconId ); |
|
95 |
|
96 /** |
|
97 * Creates an icon instance. Call only after a succesfull call to GetIconIdForContactL(). |
|
98 * |
|
99 * @exception Panics if called when icon is not available. See GetIconIdForContactL(). |
|
100 */ |
|
101 CGulIcon* CreateIconCopyLC( const TPbk2IconId& aIconId ); |
|
102 |
|
103 |
|
104 private: // from MContactPresenceObs |
|
105 void ReceiveIconInfoL( |
|
106 const TDesC8& aPackedLink, |
|
107 const TDesC8& aBrandId, |
|
108 const TDesC8& aElementId ); |
|
109 void ReceiveIconFileL( |
|
110 const TDesC8& aBrandId, |
|
111 const TDesC8& aElementId, |
|
112 CFbsBitmap* aBrandedBitmap, |
|
113 CFbsBitmap* aMask ); |
|
114 void ReceiveIconInfosL( |
|
115 const TDesC8& aPackedLink, |
|
116 RPointerArray <MContactPresenceInfo>& aInfoArray, |
|
117 TInt aOpId ); |
|
118 void PresenceSubscribeError( |
|
119 const TDesC8& aContactLink, |
|
120 TInt aStatus ); |
|
121 void ErrorOccured( |
|
122 TInt aOpId, |
|
123 TInt aStatus ); |
|
124 |
|
125 |
|
126 private: // New methods |
|
127 |
|
128 void InformObserverOfContactChanges( |
|
129 const TDesC8& aBrandId, |
|
130 const TDesC8& aElementId ); |
|
131 |
|
132 CPbk2NlxPresenceSubscriptionInfo* FindSubscription( const MVPbkContactLink& aContactLink ); |
|
133 CPbk2NlxPresenceIconInfo* FindIconInfo( const TDesC8& aBrandId, const TDesC8& aElementId ); |
|
134 CPbk2NlxPresenceIconInfo* FindIconInfo( const TPbk2IconId& aIconId ); |
|
135 void CleanUpOldSubscriptionsL(); |
|
136 void CleanUpExtraIcons(); |
|
137 |
|
138 static CFbsBitmap* CloneBitmapL( const CFbsBitmap& aOriginalBitmap ); |
|
139 |
|
140 static TInt SubscriptionMonitorL(TAny* aPtr); |
|
141 TInt SubscriptionMonitorL(); |
|
142 static TSize CalculateListIconSize(); |
|
143 private: // Data |
|
144 /// Ref: Virtual Phonebook contact manager |
|
145 CVPbkContactManager& iContactManager; |
|
146 |
|
147 MContactPresence* iPresenceClient; |
|
148 RPointerArray<CPbk2NlxPresenceSubscriptionInfo> iSubscriptions; // owns the objects |
|
149 RPointerArray<CPbk2NlxPresenceIconInfo> iIconInfoArray; // owns the objects |
|
150 TInt iNextIconId; |
|
151 MPbk2EcePresenceEngineObserver& iObserver; |
|
152 CIdle* iSubscriptionMonitor; |
|
153 TSize iIconSize; |
|
154 }; |
|
155 |
|
156 #endif // CPbk2EcePresenceEngine_H |
|
157 |
|
158 // End of File |