61 // Destructor |
61 // Destructor |
62 // --------------------------------------------------------------------------- |
62 // --------------------------------------------------------------------------- |
63 // |
63 // |
64 CBTNotificationManager::~CBTNotificationManager() |
64 CBTNotificationManager::~CBTNotificationManager() |
65 { |
65 { |
|
66 BOstraceFunctionEntry0( DUMMY_DEVLIST ); |
66 iNotificationQ.ResetAndDestroy(); |
67 iNotificationQ.ResetAndDestroy(); |
67 iNotificationQ.Close(); |
68 iNotificationQ.Close(); |
|
69 BOstraceFunctionExit0( DUMMY_DEVLIST ); |
68 } |
70 } |
69 |
71 |
70 |
72 |
71 // --------------------------------------------------------------------------- |
73 // --------------------------------------------------------------------------- |
72 // Get a new notification |
74 // Get a new notification |
73 // --------------------------------------------------------------------------- |
75 // --------------------------------------------------------------------------- |
74 // |
76 // |
75 CBluetoothNotification* CBTNotificationManager::GetNotification() |
77 CBluetoothNotification* CBTNotificationManager::GetNotification() |
76 { |
78 { |
|
79 BOstraceFunctionEntry0( DUMMY_DEVLIST ); |
77 CBluetoothNotification* notification = NULL; |
80 CBluetoothNotification* notification = NULL; |
78 TRAP_IGNORE( notification = CBluetoothNotification::NewL( this ) ); |
81 TRAP_IGNORE( notification = CBluetoothNotification::NewL( this ) ); |
79 if( notification ) |
82 if( notification ) |
80 { |
83 { |
81 if( iNotificationQ.Append( notification ) ) |
84 if( iNotificationQ.Append( notification ) ) |
84 // Otherwise we cannot keep track of it anymore. |
87 // Otherwise we cannot keep track of it anymore. |
85 delete notification; |
88 delete notification; |
86 notification = NULL; |
89 notification = NULL; |
87 } |
90 } |
88 } |
91 } |
|
92 BOstraceFunctionExit0( DUMMY_DEVLIST ); |
89 return notification; |
93 return notification; |
90 } |
94 } |
91 |
95 |
92 |
96 |
93 // --------------------------------------------------------------------------- |
97 // --------------------------------------------------------------------------- |
94 // Release the notification |
98 // Release the notification |
95 // --------------------------------------------------------------------------- |
99 // --------------------------------------------------------------------------- |
96 // |
100 // |
97 void CBTNotificationManager::ReleaseNotification( CBluetoothNotification* aNotification ) |
101 void CBTNotificationManager::ReleaseNotification( CBluetoothNotification* aNotification ) |
98 { |
102 { |
|
103 BOstraceFunctionEntry0( DUMMY_DEVLIST ); |
99 __ASSERT_ALWAYS( aNotification, PanicServer( EBTNotifPanicBadArgument ) ); |
104 __ASSERT_ALWAYS( aNotification, PanicServer( EBTNotifPanicBadArgument ) ); |
100 TInt pos = iNotificationQ.Find( aNotification ); |
105 TInt pos = iNotificationQ.Find( aNotification ); |
101 __ASSERT_ALWAYS( pos > KErrNotFound, PanicServer( EBTNotifPanicMissing ) ); |
106 __ASSERT_ALWAYS( pos > KErrNotFound, PanicServer( EBTNotifPanicMissing ) ); |
|
107 delete iNotificationQ[pos]; |
102 iNotificationQ.Remove( pos ); |
108 iNotificationQ.Remove( pos ); |
103 // Just delete the notification. |
109 iNotificationQ.Compress(); |
104 delete aNotification; |
110 BOstraceFunctionExit0( DUMMY_DEVLIST ); |
105 if(!iNotificationQ.Count() ) |
|
106 { |
|
107 // the queue is empty, reset it. |
|
108 iNotificationQ.Compress(); |
|
109 } |
|
110 } |
111 } |
111 |
112 |
112 |
113 |
113 // --------------------------------------------------------------------------- |
114 // --------------------------------------------------------------------------- |
114 // Queue the notification with given priority |
115 // Queue the notification with given priority |
116 // |
117 // |
117 void CBTNotificationManager::QueueNotificationL( |
118 void CBTNotificationManager::QueueNotificationL( |
118 CBluetoothNotification* aNotification, |
119 CBluetoothNotification* aNotification, |
119 TNotificationPriority aPriority ) |
120 TNotificationPriority aPriority ) |
120 { |
121 { |
|
122 BOstraceFunctionEntry0( DUMMY_DEVLIST ); |
121 (void) aPriority; |
123 (void) aPriority; |
122 TInt pos = iNotificationQ.Find( aNotification ); |
124 TInt pos = iNotificationQ.Find( aNotification ); |
123 __ASSERT_ALWAYS( pos > KErrNotFound, PanicServer( EBTNotifPanicMissing ) ); |
125 __ASSERT_ALWAYS( pos > KErrNotFound, PanicServer( EBTNotifPanicMissing ) ); |
124 if( /*aPriority == EPriorityHigh &&*/ pos != 0 ) |
126 // Always move the newly added notification on top |
|
127 if(pos != 0 ) |
125 { |
128 { |
126 CBluetoothNotification* notification = NULL; |
129 CBluetoothNotification* notification = NULL; |
127 notification = iNotificationQ[pos]; |
130 notification = iNotificationQ[pos]; |
128 iNotificationQ.Remove( pos ); |
131 iNotificationQ.Remove( pos ); |
129 iNotificationQ.InsertL(notification,0); |
132 iNotificationQ.InsertL(notification,0); |
130 } |
133 } |
131 ProcessNotificationQueueL(); |
134 ProcessNotificationQueueL(); |
|
135 BOstraceFunctionExit0( DUMMY_DEVLIST ); |
132 } |
136 } |
133 |
137 |
134 // --------------------------------------------------------------------------- |
138 // --------------------------------------------------------------------------- |
135 // Process the notification queue and launch the next notification. |
139 // Process the notification queue and launch the next notification. |
136 // --------------------------------------------------------------------------- |
140 // --------------------------------------------------------------------------- |
137 // |
141 // |
138 void CBTNotificationManager::ProcessNotificationQueueL() |
142 void CBTNotificationManager::ProcessNotificationQueueL() |
139 { |
143 { |
|
144 BOstraceFunctionEntry0( DUMMY_DEVLIST ); |
140 if( iNotificationQ.Count() ) |
145 if( iNotificationQ.Count() ) |
141 { |
146 { |
142 iNotificationQ[0]->ShowL(); |
147 iNotificationQ[0]->ShowL(); |
143 } |
148 } |
144 else |
149 else |
145 { |
150 { |
146 // No outstanding notifications |
151 // No outstanding notifications |
147 iNotificationQ.Compress(); // the queue is empty, reset it. |
152 iNotificationQ.Compress(); // the queue is empty, reset it. |
148 } |
153 } |
|
154 BOstraceFunctionExit0( DUMMY_DEVLIST ); |
149 } |
155 } |
150 |
156 |