1 /* |
|
2 * Copyright (c) 2005-2009 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: File Transfer Controller implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <obexutilsmessagehandler.h> |
|
21 #include <btmsgtypeuid.h> // BT Message Uid |
|
22 |
|
23 #include "sconinboxhandler.h" |
|
24 #include "debug.h" |
|
25 #include "sconconsts.h" |
|
26 |
|
27 |
|
28 // ============================= MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CSConInboxHandler::NewL() |
|
32 // Two-phase constructor |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CSConInboxHandler* CSConInboxHandler::NewL() |
|
36 { |
|
37 TRACE_FUNC_ENTRY; |
|
38 CSConInboxHandler* self = new (ELeave) CSConInboxHandler(); |
|
39 |
|
40 TRACE_FUNC_EXIT; |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CSConInboxHandler::~CSConInboxHandler() |
|
46 // Default destructor |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CSConInboxHandler::~CSConInboxHandler() |
|
50 { |
|
51 TRACE_FUNC; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CSConInboxHandler::CreateInboxAttachmentL( CObexBufObject*& aObject, |
|
56 // CBufFlat*& aBuffer ) |
|
57 // Creates an attachment to device's Inbox |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 TInt CSConInboxHandler::CreateInboxAttachmentL( CObexBufObject*& aObject, |
|
61 CBufFlat*& aBuffer ) |
|
62 { |
|
63 TRACE_FUNC_ENTRY; |
|
64 TInt ret( KErrNone ); |
|
65 iDrive = GetMessageCenterDriveL(); |
|
66 |
|
67 delete aObject; |
|
68 aObject = CObexBufObject::NewL( NULL ); |
|
69 |
|
70 iFile = RFile(); |
|
71 |
|
72 TRAP( ret, TObexUtilsMessageHandler::CreateInboxAttachmentL( aObject, |
|
73 KUidMsgTypeBt, iMsvIdParent, iFile ) ); |
|
74 |
|
75 if( aBuffer ) |
|
76 { |
|
77 aBuffer->Reset(); |
|
78 delete aBuffer; |
|
79 } |
|
80 |
|
81 aBuffer = CBufFlat::NewL( KSConBufferSize ); |
|
82 aBuffer->ResizeL( KSConBufferSize ); |
|
83 |
|
84 TObexRFileBackedBuffer bufferdetails( *aBuffer, iFile, |
|
85 CObexBufObject::EDoubleBuffering ); |
|
86 aObject->SetDataBufL( bufferdetails ); |
|
87 LOGGER_WRITE_1( "CSConInboxHandler::CreateInboxAttachmentL() : returned %d", ret ); |
|
88 return ret; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CSConInboxHandler::SaveObjToInboxL( CObexBufObject*& aObject ) |
|
93 // Saves the object to the Inbox |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 TInt CSConInboxHandler::SaveObjToInboxL( CObexBufObject*& aObject ) |
|
97 { |
|
98 TRACE_FUNC_ENTRY; |
|
99 TInt ret( KErrNone ); |
|
100 |
|
101 if( iDrive == EDriveE ) |
|
102 { |
|
103 ret = TObexUtilsMessageHandler::GetMmcFileSystemStatus(); |
|
104 LOGGER_WRITE_1( "GetMmcFileSystemStatus returned %d", ret ); |
|
105 } |
|
106 else |
|
107 { |
|
108 ret = TObexUtilsMessageHandler::GetFileSystemStatus(); |
|
109 LOGGER_WRITE_1( "GetFileSystemStatus returned %d", ret ); |
|
110 } |
|
111 |
|
112 if( ret == KErrNone ) |
|
113 { |
|
114 TInt tempDrive = GetMessageCenterDriveL(); |
|
115 |
|
116 if( tempDrive == iDrive ) |
|
117 { |
|
118 LOGGER_WRITE_1( "before SaveObjToInboxL in SaveObjToInboxL %d", ret ); |
|
119 TRAP( ret, TObexUtilsMessageHandler::SaveObjToInboxL( aObject, |
|
120 iFile, iMsvIdParent ) ); |
|
121 LOGGER_WRITE_1( "after SaveObjToInboxL in SaveObjToInboxL %d", ret ); |
|
122 } |
|
123 else |
|
124 { |
|
125 ret = KErrGeneral; |
|
126 } |
|
127 |
|
128 if( ret != KErrNone ) |
|
129 { |
|
130 LOGGER_WRITE_1( "before RemoveInboxEntriesL in SaveObjToInboxL %d", ret ); |
|
131 TObexUtilsMessageHandler::RemoveInboxEntriesL( aObject, |
|
132 iMsvIdParent ); |
|
133 LOGGER_WRITE_1( "after RemoveInboxEntriesL in SaveObjToInboxL %d", ret ); |
|
134 } |
|
135 } |
|
136 |
|
137 LOGGER_WRITE_1( "CSConInboxHandler::SaveObjToInboxL( CObexBufObject* aObject ) : returned %d", ret ); |
|
138 return ret; |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CSConInboxHandler::AbortInboxOperation( CObexBufObject*& aObject ) |
|
143 // Aborts the storing operation |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 TInt CSConInboxHandler::AbortInboxOperation( CObexBufObject*& aObject ) |
|
147 { |
|
148 TRACE_FUNC_ENTRY; |
|
149 TInt ret( KErrNone ); |
|
150 TRAP( ret, TObexUtilsMessageHandler::RemoveInboxEntriesL( aObject, |
|
151 iMsvIdParent ) ); |
|
152 LOGGER_WRITE_1( "CSConInboxHandler::AbortInboxOperation() returned %d", ret ); |
|
153 return ret; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CSConInboxHandler::GetMessageCenterDriveL() |
|
158 // Returns the current message center drive |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 TInt CSConInboxHandler::GetMessageCenterDriveL() |
|
162 { |
|
163 TRACE_FUNC_ENTRY; |
|
164 TInt drive; |
|
165 CMsvSession* msvSession = CMsvSession::OpenSyncL( *this ); |
|
166 CleanupStack::PushL( msvSession ); |
|
167 TDriveUnit driveUnit = msvSession->CurrentDriveL(); |
|
168 drive = driveUnit.operator TInt(); |
|
169 CleanupStack::PopAndDestroy( msvSession ); |
|
170 LOGGER_WRITE_1( "CSConInboxHandler::GetMessageCenterDriveL() returned %d", drive ); |
|
171 return drive; |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CSConInboxHandler::HandleSessionEventL( TMsvSessionEvent aEvent, |
|
176 // TAny* aArg1, |
|
177 // TAny* aArg2, |
|
178 // TAny* aArg3 ) |
|
179 // Implementation of MMsvSessionObserver::HandleSessionEventL |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 void CSConInboxHandler::HandleSessionEventL( TMsvSessionEvent /*aEvent*/, |
|
183 TAny* /*aArg1*/, |
|
184 TAny* /*aArg2*/, |
|
185 TAny* /*aArg3*/ ) |
|
186 { |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // CSConInboxHandler::CSConInboxHandler() |
|
191 // Default constructor |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 CSConInboxHandler::CSConInboxHandler() |
|
195 { |
|
196 } |
|
197 |
|
198 // End of file |
|
199 |
|