|
1 // Copyright (c) 2005-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 // |
|
15 |
|
16 #include <obex/transport/obexwriterbase.h> |
|
17 #include <obex/internal/obexpacket.h> |
|
18 #include <obex/transport/mobextransportnotify.h> |
|
19 #include "logger.h" |
|
20 #include "obextransportfaults.h" |
|
21 |
|
22 #ifdef __FLOG_ACTIVE |
|
23 _LIT8(KLogComponent, "OBEXCT"); |
|
24 #endif |
|
25 |
|
26 #ifdef _DEBUG |
|
27 _LIT(KPanicCat, "ObexWriterBase"); |
|
28 #endif |
|
29 |
|
30 /** |
|
31 Constructor |
|
32 */ |
|
33 EXPORT_C CObexWriterBase::CObexWriterBase(TPriority aPriority, |
|
34 MObexTransportNotify& aOwner, |
|
35 TObexConnectionInfo& aInfo) |
|
36 : CObexActiveRW (aPriority, aOwner, aInfo) |
|
37 { |
|
38 LOG_LINE |
|
39 LOG_FUNC |
|
40 } |
|
41 |
|
42 /** |
|
43 Destructor |
|
44 */ |
|
45 EXPORT_C CObexWriterBase::~CObexWriterBase() |
|
46 { |
|
47 LOG_LINE |
|
48 LOG_FUNC |
|
49 } |
|
50 |
|
51 /** |
|
52 This function is a placeholder for future use. If the iFuture1 variable is |
|
53 used it will need this function for any allocation required. |
|
54 |
|
55 To prevent binary compatiblity breaks if the iFuture1 variable is used, this |
|
56 function must be called from the NewL of derived classes. |
|
57 */ |
|
58 EXPORT_C void CObexWriterBase::BaseConstructL() |
|
59 { |
|
60 LOG_LINE |
|
61 LOG_FUNC |
|
62 } |
|
63 |
|
64 /** |
|
65 Start transfer. Calls into CObexActiveRW, which eventaully queues a write |
|
66 |
|
67 @param aPacket The Obex packet to write |
|
68 */ |
|
69 EXPORT_C void CObexWriterBase::StartTransfer (CObexPacket& aPacket) |
|
70 { |
|
71 LOG_LINE |
|
72 LOG_FUNC |
|
73 |
|
74 iPacketSize = aPacket.PacketSize(); |
|
75 NewRequest(aPacket); |
|
76 |
|
77 if(iPacket->IsFinal() && |
|
78 (iPacket->PacketProcessNotificationEvents() & EObexFinalPacketStarted)) |
|
79 { |
|
80 iOwner.SignalPacketProcessEvent(EObexFinalPacketStarted); |
|
81 } |
|
82 } |
|
83 |
|
84 /** |
|
85 Returns true if the transfer has completed |
|
86 |
|
87 @return TBool return true if the transfer if complete otherwise return false |
|
88 */ |
|
89 EXPORT_C TBool CObexWriterBase::CompleteTransfer () |
|
90 { |
|
91 LOG_LINE |
|
92 LOG_FUNC |
|
93 |
|
94 return (iCount >= iPacketSize); |
|
95 } |
|
96 |
|
97 /** Performs any actions necessary on completion of a write. |
|
98 */ |
|
99 EXPORT_C void CObexWriterBase::OnCompleteTransfer() |
|
100 { |
|
101 iOwner.SignalPacketProcessEvent(EObexWriteCompleted); |
|
102 |
|
103 if(iPacket->IsFinal() && |
|
104 (iPacket->PacketProcessNotificationEvents() & EObexFinalPacketFinished)) |
|
105 { |
|
106 iOwner.SignalPacketProcessEvent(EObexFinalPacketFinished); |
|
107 } |
|
108 |
|
109 // Signal this after dereferences of iPacket because it might result in |
|
110 // our destruction. |
|
111 iOwner.SignalPacketProcessEvent(EObexWriteCompletedFinal); |
|
112 } |
|
113 |
|
114 /** |
|
115 Return number of bytes remaining to be sent |
|
116 @return TInt number of bytes remaining to be sent |
|
117 */ |
|
118 EXPORT_C TInt CObexWriterBase::Remaining () |
|
119 { |
|
120 LOG_LINE |
|
121 LOG_FUNC |
|
122 |
|
123 __ASSERT_DEBUG (iPacketSize >= KObexPacketHeaderSize, PANIC(KPanicCat, EInvalidPacketSize)); |
|
124 return (iPacketSize - iCount); |
|
125 } |
|
126 |
|
127 /** |
|
128 This function is part of the extension pattern and is implemented by all |
|
129 derived instantiable classes that need to extend its interface. |
|
130 |
|
131 By default this returns null. Any derived class that is required to extend its |
|
132 interface and that of this base class returns its new interface in the form of |
|
133 an M class, that it extends, if and only if the corresponding TUid, aUid, is |
|
134 received. Otherwise the function calls the base class implementation, |
|
135 returning NULL. |
|
136 |
|
137 @return TAny* The M Class representing the extension to the interface |
|
138 otherwise NULL |
|
139 @param aUid The uid associated with the M Class that is being implemented |
|
140 */ |
|
141 EXPORT_C TAny* CObexWriterBase::GetInterface(TUid /*aUid*/) |
|
142 { |
|
143 return NULL; |
|
144 } |