|
1 // Copyright (c) 2004-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 // Message sender header file |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file MsgSender.h |
|
20 */ |
|
21 |
|
22 #ifndef MSGSENDER_H |
|
23 #define MSGSENDER_H |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <./libc/limits.h> |
|
27 #include "ExpireTimer.h" |
|
28 #include "DHCP_Std.h" |
|
29 |
|
30 class TInetAddr; |
|
31 class RSocket; |
|
32 |
|
33 const TInt KMicrosecondsInSecs = 1000000; |
|
34 |
|
35 class MMSListener |
|
36 /** |
|
37 * Just a notification interface |
|
38 * |
|
39 * @internalTechnology |
|
40 */ |
|
41 { |
|
42 public: |
|
43 virtual TInt MSReportError(TInt aError) = 0; |
|
44 }; |
|
45 |
|
46 class CMessageSender : public CActive, public MExpireTimer |
|
47 { |
|
48 public: |
|
49 CMessageSender(MMSListener* aMMSListener, RSocket& aSocket, TTime *aTaskStartedAtCopy, const TUint aFamily); |
|
50 virtual ~CMessageSender(); |
|
51 |
|
52 //if aRetransmitAfterMcSecs == 0 than just one transmition happens |
|
53 void SendL(TInetAddr& aAddr, const TDesC8& aMsg, TTimeIntervalMicroSeconds aRetransmitAfterSecs, TInt aRetryCount); |
|
54 void Cancel(); |
|
55 |
|
56 //MExpireTimer virtuals |
|
57 virtual void TimerExpired(); |
|
58 void SetTaskStartedTime(TTime aTaskStartedAtCopy); |
|
59 const TUint GetFamilyType(); |
|
60 |
|
61 protected: |
|
62 virtual void DoCancel(); |
|
63 virtual void RunL(); |
|
64 virtual TInt RunError(TInt aError); |
|
65 |
|
66 protected: |
|
67 virtual TBool SendingContinues() const; |
|
68 virtual TBool CalculateDelay(); |
|
69 |
|
70 void StartTimerL(); |
|
71 |
|
72 protected: |
|
73 HBufC8* iMsg; |
|
74 CExpireTimer* iExpireTimer; |
|
75 TInetAddr iAddr; |
|
76 RSocket& iSocket; |
|
77 TTimeIntervalMicroSeconds32 iMicroSecs; |
|
78 MMSListener* iMMSListener; |
|
79 TInt iRetryCount; //counts how many times the message's been successfully sent |
|
80 TInt iRetryDuration; |
|
81 TInt iMaxRetryCount; //counts the max times the message has to be sent |
|
82 TTime iTaskStartedAtCopy; |
|
83 const TUint iFamily; |
|
84 }; |
|
85 |
|
86 inline CMessageSender::CMessageSender(MMSListener* aMMSListener,RSocket& aSocket, TTime *aTaskStartedAtCopy, const TUint aFamily) : |
|
87 CActive(EPriorityStandard), iSocket(aSocket),iMMSListener(aMMSListener),iTaskStartedAtCopy(*aTaskStartedAtCopy),iFamily(aFamily) |
|
88 { |
|
89 } |
|
90 |
|
91 inline void CMessageSender::SetTaskStartedTime(TTime aTaskStartedAtCopy) |
|
92 { |
|
93 iTaskStartedAtCopy = aTaskStartedAtCopy; |
|
94 } |
|
95 |
|
96 inline const TUint CMessageSender::GetFamilyType() |
|
97 { |
|
98 return iFamily; |
|
99 } |
|
100 |
|
101 #endif |