49
|
1 |
/*
|
|
2 |
* Copyright (c) 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include "mccanysourcesinklogs.h"
|
|
23 |
#include "mccdatasender.h"
|
|
24 |
|
|
25 |
|
|
26 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
27 |
|
|
28 |
// -----------------------------------------------------------------------------
|
|
29 |
// CMccDataSender::CMccDataSender
|
|
30 |
// -----------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
CMccDataSender::CMccDataSender( )
|
|
33 |
: CActive( EPriorityStandard ), iReady( EFalse )
|
|
34 |
{
|
|
35 |
CActiveScheduler::Add(this);
|
|
36 |
}
|
|
37 |
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
// CMccDataSender::ConstructL
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
void CMccDataSender::ConstructL()
|
|
43 |
{
|
|
44 |
__ANYSOURCESINK_CONTROLL( "CMccDataSender::ConstructL" )
|
|
45 |
|
|
46 |
TBuf16<30> aMessageBuffer(_L("SendQueueForMCCMSRP"));
|
|
47 |
|
|
48 |
TInt aNo = AssignNameToMessageQueueL(aMessageBuffer);
|
|
49 |
aMessageBuffer.AppendNum(aNo);
|
|
50 |
|
|
51 |
|
|
52 |
TInt err = iSendMsgQueue.CreateGlobal(aMessageBuffer, 5, EOwnerProcess );
|
|
53 |
if ( err )
|
|
54 |
{
|
|
55 |
User::LeaveIfError( iSendMsgQueue.OpenGlobal(aMessageBuffer));
|
|
56 |
}
|
|
57 |
}
|
|
58 |
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
// CMccDataSender::NewL
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
CMccDataSender* CMccDataSender::NewL( )
|
|
64 |
{
|
|
65 |
__ANYSOURCESINK_CONTROLL( "CMccDataSender::NewL" )
|
|
66 |
CMccDataSender* self =
|
|
67 |
new ( ELeave ) CMccDataSender();
|
|
68 |
CleanupStack::PushL( self );
|
|
69 |
self->ConstructL();
|
|
70 |
CleanupStack::Pop( self );
|
|
71 |
return self;
|
|
72 |
}
|
|
73 |
|
|
74 |
TInt CMccDataSender::AssignNameToMessageQueueL(const TDes16 &aMessageBuffer)
|
|
75 |
{
|
|
76 |
__ANYSOURCESINK_CONTROLL( "CMccDataSender::AssignNameToMessageQueueL, Entry" )
|
|
77 |
for(TInt i =1; i<=10; i++)
|
|
78 |
{
|
|
79 |
TBuf16<30> tempMessage1 = aMessageBuffer;
|
|
80 |
tempMessage1.AppendNum(i);
|
|
81 |
TInt err1 = iSendMsgQueue1.CreateGlobal(tempMessage1, 5, EOwnerProcess );
|
|
82 |
|
|
83 |
if(err1 == KErrNone)
|
|
84 |
{
|
|
85 |
TBuf16<30> tempMessage2 = aMessageBuffer;
|
|
86 |
tempMessage2.AppendNum(i+1);
|
|
87 |
TInt err2 = iSendMsgQueue2.CreateGlobal(tempMessage2, 5, EOwnerProcess );
|
|
88 |
|
|
89 |
if(err2 == KErrNone)
|
|
90 |
{
|
|
91 |
iSendMsgQueue1.Close();
|
|
92 |
iSendMsgQueue2.Close();
|
|
93 |
__ANYSOURCESINK_CONTROLL_INT1( "CMccDataSender::AssignNameToMessageQueueL", i )
|
|
94 |
return i;
|
|
95 |
}
|
|
96 |
else
|
|
97 |
{
|
|
98 |
iSendMsgQueue1.Close();
|
|
99 |
}
|
|
100 |
}
|
|
101 |
}
|
|
102 |
return 0;
|
|
103 |
}
|
|
104 |
|
|
105 |
// -----------------------------------------------------------------------------
|
|
106 |
// CMccDataSender::Send
|
|
107 |
// -----------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
void CMccDataSender::Send( const TDesC8& aData )
|
|
110 |
{
|
|
111 |
__ANYSOURCESINK_CONTROLL( "CMccDataSender::Send" )
|
|
112 |
TQueueBuffer buffer( aData );
|
|
113 |
|
|
114 |
TInt err = iSendMsgQueue.Send( buffer );
|
|
115 |
|
|
116 |
if ( err == KErrOverflow )
|
|
117 |
{
|
|
118 |
if ( !IsActive() )
|
|
119 |
{
|
|
120 |
iBuffer.Copy( aData );
|
|
121 |
iSendMsgQueue.NotifySpaceAvailable( iStatus );
|
|
122 |
SetActive();
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
// TODO
|
|
127 |
// BUFFER OR DROP
|
|
128 |
__ANYSOURCESINK_CONTROLL( "CMccDataSender::Send, Dropping Packet" )
|
|
129 |
}
|
|
130 |
}
|
|
131 |
}
|
|
132 |
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
// CMccDataSender::~CMccDataSender
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
CMccDataSender::~CMccDataSender()
|
|
138 |
{
|
|
139 |
__ANYSOURCESINK_CONTROLL( "CMccDataSender::~CMccDataSender" )
|
|
140 |
Cancel();
|
|
141 |
iSendMsgQueue.Close();
|
|
142 |
}
|
|
143 |
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
// CMccDataSender::DoCancel
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
void CMccDataSender::DoCancel()
|
|
149 |
{
|
|
150 |
__ANYSOURCESINK_CONTROLL( "CMccDataSender::DoCancel" )
|
|
151 |
iSendMsgQueue.CancelSpaceAvailable();
|
|
152 |
}
|
|
153 |
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
// CMccDataSender::RunL
|
|
156 |
// -----------------------------------------------------------------------------
|
|
157 |
//
|
|
158 |
void CMccDataSender::RunL()
|
|
159 |
{
|
|
160 |
__ANYSOURCESINK_CONTROLL( "CMccDataSender::RunL" )
|
|
161 |
iSendMsgQueue.Send( iBuffer );
|
|
162 |
iBuffer.Zero();
|
|
163 |
}
|
|
164 |
|
|
165 |
// -----------------------------------------------------------------------------
|
|
166 |
// CMccDataSender::RunError
|
|
167 |
// -----------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
TInt CMccDataSender::RunError(TInt /*aError*/)
|
|
170 |
{
|
|
171 |
return KErrNone;
|
|
172 |
}
|