|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // csendmessagequeue.h |
|
15 // |
|
16 // |
|
17 /** |
|
18 @file |
|
19 @internalTechnology |
|
20 */ |
|
21 |
|
22 #ifndef __CSENDMESSAGEQUEUE_H__ |
|
23 #define __CSENDMESSAGEQUEUE_H__ |
|
24 |
|
25 //system include |
|
26 #include <e32base.h> |
|
27 #include <es_sock.h> |
|
28 #include <e32math.h> |
|
29 #include <mdns/cdnsmessage.h> |
|
30 #include <mdns/cdnsmessagecomposerparser.h> |
|
31 |
|
32 //user include |
|
33 |
|
34 #include "msockethandlerobserver.h" |
|
35 #include "csockethandler.h" |
|
36 #include "mmessagehandler.h" |
|
37 #include "mdnsdebug.h" |
|
38 |
|
39 class MMessageHandler; |
|
40 class CSendMessageData |
|
41 { |
|
42 public: |
|
43 static CSendMessageData* NewL(CDnsMessage* aDnsMessage, TBool aUnicast,TSockAddr aAddr, MMessageHandler& aCallback); |
|
44 const CDnsMessage& GetDnsMessage()const; |
|
45 const TSockAddr& GetSockAddress()const; |
|
46 const TBool& IsUnicast()const; |
|
47 ~CSendMessageData(); |
|
48 MMessageHandler& Callback(); |
|
49 private: |
|
50 void ConstructL(); |
|
51 CSendMessageData(CDnsMessage* aDnsMessage,TBool aUnicast,TSockAddr aAddr, MMessageHandler& aCallback); |
|
52 |
|
53 private: |
|
54 CDnsMessage* iMessage; |
|
55 TBool iUnicast; |
|
56 TSockAddr iSockAddr ; |
|
57 MMessageHandler& iCallback; |
|
58 /** |
|
59 *FLOGGER debug trace member variable. |
|
60 */ |
|
61 __FLOG_DECLARATION_MEMBER_MUTABLE; |
|
62 }; |
|
63 |
|
64 |
|
65 class CSendMessageQueue : public CTimer, public MSocketHandlerObserver |
|
66 { |
|
67 public: |
|
68 static CSendMessageQueue* NewL(RSocket& aSocket); |
|
69 ~CSendMessageQueue(); |
|
70 virtual void OnCompletionL(TDesC8& aData, const TSockAddr& aAddr, TInt aLength); |
|
71 virtual void OnError(TInt aError); |
|
72 void RunL(); |
|
73 void DoCancel(); |
|
74 void QueueDnsMessageL(const CSendMessageData& aMessageData); |
|
75 |
|
76 private: |
|
77 CSendMessageQueue(); |
|
78 void ConstructL(RSocket& aSocket); |
|
79 void NextTransmitTime(TTime aTime); |
|
80 void StartTransmit(); |
|
81 CSendMessageData* NextDnsMessageL(); |
|
82 TBool MessageReady(); |
|
83 |
|
84 private: |
|
85 CSendMessageData* iSendMessageData; |
|
86 CSocketHandler* iSendSocket; |
|
87 RPointerArray<CSendMessageData> iMessageQueue; |
|
88 TInt64 iRandomSeed; |
|
89 TTime iNextTransmit; |
|
90 TBool iIsSocketActive; |
|
91 RBuf8 iOutput; |
|
92 /** |
|
93 *FLOGGER debug trace member variable. |
|
94 */ |
|
95 __FLOG_DECLARATION_MEMBER_MUTABLE; |
|
96 }; |
|
97 |
|
98 #endif |