|
1 /** @file |
|
2 * Copyright (c) 2008-2008 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: Implements algoritms for nonmodereted events |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "upnpnonmoderatedeventqueuemanager.h" |
|
20 #include "upnpgenamessagefactory.h" |
|
21 #include "upnphttpnonmoderatedeventtransaction.h" |
|
22 #include "upnpcommonupnplits.h" |
|
23 #include "upnpcommonstructs.h" |
|
24 |
|
25 |
|
26 #define KLogFile _L("UPnPStack.txt") |
|
27 #include "upnpcustomlog.h" |
|
28 |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CUpnpNonModeratedEventQueueManager::CUpnpNonModeratedEventQueueManager |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CUpnpNonModeratedEventQueueManager::CUpnpNonModeratedEventQueueManager( |
|
35 CUpnpServiceImplementation& aServiceImpl, |
|
36 CUpnpEventController& aEventController, |
|
37 CUpnpSubscriberLibrary* aSubscriberLibrary |
|
38 ) |
|
39 :CUpnpEventQueueManagerBase( aServiceImpl, aEventController , aSubscriberLibrary ) |
|
40 { |
|
41 // No implementation required |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CUpnpNonModeratedEventQueueManager::~CUpnpNonModeratedEventQueueManager |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CUpnpNonModeratedEventQueueManager::~CUpnpNonModeratedEventQueueManager() |
|
49 { |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CUpnpNonModeratedEventQueueManager::NewLC |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CUpnpNonModeratedEventQueueManager* CUpnpNonModeratedEventQueueManager::NewLC( |
|
57 CUpnpServiceImplementation& aServiceImpl, |
|
58 CUpnpEventController& aEventController, |
|
59 CUpnpSubscriberLibrary* aSubscriberLibrary |
|
60 ) |
|
61 { |
|
62 CUpnpNonModeratedEventQueueManager* self = |
|
63 new (ELeave) CUpnpNonModeratedEventQueueManager( aServiceImpl, |
|
64 aEventController, |
|
65 aSubscriberLibrary ); |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CUpnpNonModeratedEventQueueManager::NewL |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CUpnpNonModeratedEventQueueManager* CUpnpNonModeratedEventQueueManager::NewL( |
|
76 CUpnpServiceImplementation& aServiceImpl, |
|
77 CUpnpEventController& aEventController, |
|
78 CUpnpSubscriberLibrary* aSubscriberLibrary |
|
79 ) |
|
80 { |
|
81 CUpnpNonModeratedEventQueueManager* self= CUpnpNonModeratedEventQueueManager::NewLC( |
|
82 aServiceImpl, |
|
83 aEventController, |
|
84 aSubscriberLibrary ); |
|
85 CleanupStack::Pop( self ); |
|
86 return self; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CUpnpNonModeratedEventQueueManager::ConstructL |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CUpnpNonModeratedEventQueueManager::ConstructL() |
|
94 { |
|
95 BaseConstructL(); |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CUpnpNonModeratedEventQueueManager::SendEvent |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CUpnpNonModeratedEventQueueManager::SendEvent() |
|
103 { |
|
104 TRAPD( err, SendEventL() ); |
|
105 if( err ) |
|
106 { |
|
107 SendingCompleted(); |
|
108 } |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CUpnpNonModeratedEventQueueManager::SendEventL |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CUpnpNonModeratedEventQueueManager::SendEventL() |
|
116 { |
|
117 if ( ! iSubscriberLibrary->SubscriberLibrary().Count() ) |
|
118 { |
|
119 return; |
|
120 } |
|
121 |
|
122 if ( iIsSending ) |
|
123 { |
|
124 iNewValuesWaitingToBeSend = ETrue; |
|
125 return; |
|
126 } |
|
127 |
|
128 iIsSending = ETrue; |
|
129 |
|
130 iCurrentSubscriberIndex = 0; |
|
131 for ( TInt i = 0; i < iServiceImpl.EventedStateVariables().Count(); i++ ) |
|
132 { |
|
133 if ( iServiceImpl.EventedStateVariables()[i]->MaxEventRate() > 0 ) |
|
134 { |
|
135 iServiceImpl.EventedStateVariables()[i]->EventTick(); |
|
136 } |
|
137 } |
|
138 |
|
139 delete iBody; |
|
140 iBody =NULL; |
|
141 |
|
142 iBody = CreateEventL( iServiceImpl.StateVariableList() ); |
|
143 |
|
144 PrepareTransactionAndStartSendingL( KFirstSubscriberInQueue ); |
|
145 } |
|
146 |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CUpnpNonModeratedEventQueueManager::CreateTranscationL |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 CUpnpHttpTransaction* CUpnpNonModeratedEventQueueManager::CreateTransactionL( CUpnpHttpMessage* aMessage ) |
|
153 { |
|
154 return CUpnpHttpNonModeratedEventTransaction::NewL( aMessage, *this ); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CUpnpNonModeratedEventQueueManager::FillEventBodyL |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 TInt CUpnpNonModeratedEventQueueManager::FillEventBodyL( TDes8& aEvent, |
|
162 const RPointerArray<CUpnpStateVariable>& aVariableList |
|
163 ) |
|
164 { |
|
165 TInt eventableVariableCount(0); |
|
166 for ( TInt i = 0; i < aVariableList.Count(); i++ ) |
|
167 { |
|
168 if ( aVariableList[i]->Eventable().CompareF( KYes() ) == 0 |
|
169 && aVariableList[i]->ReadyForEventing() |
|
170 &&!aVariableList[i]->IsModerated() ) |
|
171 { |
|
172 AddVariableToEventBody( aEvent , aVariableList[i] ); |
|
173 |
|
174 iServiceImpl.StateVariableEvented( aVariableList[i]->Name() ); |
|
175 eventableVariableCount++; |
|
176 } |
|
177 } |
|
178 return eventableVariableCount; |
|
179 } |
|
180 //end of file |