|
1 // Copyright (c) 2003-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 "debug.h" |
|
17 #include <e32std.h> |
|
18 #include <e32base.h> |
|
19 #include <e32svr.h> |
|
20 #include "tranp.h" |
|
21 #include "tranpprot.h" |
|
22 #include "BFTP.H" |
|
23 #include "GLOBAL.H" |
|
24 |
|
25 CTranpProtocol::CTranpProtocol(MTranpNotification& aNotifier) : iNotifier(aNotifier) |
|
26 { |
|
27 } |
|
28 |
|
29 CTranpProtocol::~CTranpProtocol() |
|
30 { |
|
31 delete iBFTP; |
|
32 } |
|
33 |
|
34 CTranpProtocol* CTranpProtocol::NewL(MTranpNotification& aNotifier) |
|
35 { |
|
36 DEBUG_OPEN(); |
|
37 SESSIONPRINT(_L("CTranpProtocol::NewL()\n")); |
|
38 CTranpProtocol* self = new(ELeave) CTranpProtocol(aNotifier); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(aNotifier); |
|
41 CleanupStack::Pop(); |
|
42 return self; |
|
43 } |
|
44 |
|
45 void CTranpProtocol::ConstructL(const MTranpNotification& aNotifier) |
|
46 { |
|
47 iBFTP = BFTP::NewL(this, &aNotifier); |
|
48 TUint8 MaxPDU = '4'; // 4096 bytes PDU |
|
49 |
|
50 iBFTP->SetPMID(KDefaultPMID); |
|
51 iBFTP->SetSMID(KNullPMID); |
|
52 iBFTP->SetPDU(MaxPDU); |
|
53 |
|
54 } |
|
55 |
|
56 void CTranpProtocol::Connect() |
|
57 { |
|
58 } |
|
59 |
|
60 void CTranpProtocol::Disconnect() |
|
61 { |
|
62 } |
|
63 |
|
64 void CTranpProtocol::Abort() |
|
65 { |
|
66 iBFTP->Abort(); |
|
67 } |
|
68 |
|
69 |
|
70 void CTranpProtocol::Query(CTranpSession::TTranP /*aWhat*/) |
|
71 { |
|
72 } |
|
73 |
|
74 void CTranpProtocol::Get(TTranpPicture& aPicture) |
|
75 { |
|
76 iTranpPicture = &aPicture; |
|
77 iBFTP->Pump(iTranpPicture->iLatticeSize); //Start the ball rolling... |
|
78 } |
|
79 |
|
80 void CTranpProtocol::Put(const TTranpPicture& /*aPicture*/) |
|
81 { |
|
82 } |
|
83 |
|
84 void CTranpProtocol::Config(const TTranpConfig& /*aConfig*/) |
|
85 { |
|
86 } |
|
87 |
|
88 TTranpConfig CTranpProtocol::Config(const TTranpConfig& aConfig) const |
|
89 { |
|
90 return aConfig; |
|
91 } |
|
92 |
|
93 void CTranpProtocol::SetPicture(TDesC8& /*aPicture*/, TDesC8& aFilename, TDesC8& aUPFPicture, TDesC8& aLongFilename) |
|
94 // This function needs to take account of exact location of image data so iPicture needs |
|
95 // to be set from image address location specified in UPF header |
|
96 { |
|
97 // Full UPF image information |
|
98 iTranpPicture->iUPFPicture = &aUPFPicture; |
|
99 |
|
100 // Thumbnail image information is stored in UPF Entry 1 |
|
101 // UPF file bytes 240-243 contain address of thumbnail |
|
102 TUint UPFThumbnailAddress = IrTranpUtil::LExtract(iTranpPicture->iUPFPicture->Mid(KTranpUPFEntryArea1,4) , 0); //address is 4 bytes long |
|
103 // UPF file bytes 244-247 contain size of thumbnail |
|
104 TInt UPFThumbnailSize = IrTranpUtil::LExtract(iTranpPicture->iUPFPicture->Mid(KTranpUPFEntryArea1+4,4) , 0); //size is 4 bytes long + offset by 4 |
|
105 |
|
106 if (UPFThumbnailAddress != KNullImageAddress) // Thumbnail Image exists |
|
107 iTranpPicture->iThumbNail.Set(iTranpPicture->iUPFPicture->Mid(KTranpUPFHeader + UPFThumbnailAddress,UPFThumbnailSize)); |
|
108 |
|
109 // Full image information is stored in UPF Entry Area 2 |
|
110 // UPF file bytes 276-279 contain address of image |
|
111 TUint UPFImageAddress = IrTranpUtil::LExtract(iTranpPicture->iUPFPicture->Mid(KTranpUPFEntryArea2,4) , 0); //address is 4 bytes long |
|
112 // UPF file bytes 279-282 contain size of image |
|
113 TInt UPFImageSize = IrTranpUtil::LExtract(iTranpPicture->iUPFPicture->Mid(KTranpUPFEntryArea2+4,4) , 0); //address is 4 bytes long + offset by 4 |
|
114 |
|
115 if (UPFImageAddress != KNullImageAddress) // Image exists |
|
116 iTranpPicture->iPicture.Set(iTranpPicture->iUPFPicture->Mid(KTranpUPFHeader + UPFImageAddress,UPFImageSize)); |
|
117 |
|
118 iTranpPicture->iFilename = aFilename; |
|
119 iTranpPicture->iLongFilename = aLongFilename; |
|
120 |
|
121 // Set picture creation date |
|
122 TPtr8 timePtr((unsigned char*) aUPFPicture.Ptr() + KTranpDateOffset, 8, 8); |
|
123 |
|
124 iTranpPicture->iTime.Format(_L8("%04d%02d%02d%02d%02d%02d"),IrTranpUtil::DExtract(timePtr, KTranpYearOffset), |
|
125 timePtr[KTranpMonthOffset],timePtr[KTranpDayOffset], |
|
126 timePtr[KTranpHourOffset],timePtr[KTranpMinuteOffset], |
|
127 timePtr[KTranpSecondOffset]); |
|
128 |
|
129 // Set Picture Size |
|
130 TPtr8 pictureSizePtr((unsigned char*) aUPFPicture.Ptr() + KTranpPictureInfOffset, 4, 4); |
|
131 |
|
132 iTranpPicture->iWidth = IrTranpUtil::DExtract(pictureSizePtr, KTranpPictureXSizeOffset); |
|
133 iTranpPicture->iHeight = IrTranpUtil::DExtract(pictureSizePtr, KTranpPictureYSizeOffset); |
|
134 |
|
135 // QVGA:=320x240, VGA:=640x480, SVGA:=800x600, XGA:=1024x768, SXGA:=1280x960, FREE:=m x n |
|
136 |
|
137 switch (iTranpPicture->iWidth) |
|
138 { |
|
139 case 320: |
|
140 case 240: |
|
141 iTranpPicture->iLatticeSize = EQVGA; |
|
142 break; |
|
143 case 640: |
|
144 case 480: |
|
145 iTranpPicture->iLatticeSize = EVGA; |
|
146 break; |
|
147 case 800: |
|
148 case 600: |
|
149 iTranpPicture->iLatticeSize = ESVGA; |
|
150 break; |
|
151 case 1024: |
|
152 case 768: |
|
153 iTranpPicture->iLatticeSize = EXGA; |
|
154 break; |
|
155 case 1280: |
|
156 case 960: |
|
157 iTranpPicture->iLatticeSize = ESXGA; |
|
158 break; |
|
159 default: |
|
160 iTranpPicture->iLatticeSize = EFREE; |
|
161 break; |
|
162 } |
|
163 } |