irda/irdastack/irtranp/BFTP.CPP
branchRCL_3
changeset 11 20fda83a6398
parent 0 29b1cd4cb562
equal deleted inserted replaced
10:8a27654f7b62 11:20fda83a6398
    56 *
    56 *
    57 * Parameter:			a_Header - TPtr pointing the command buffer
    57 * Parameter:			a_Header - TPtr pointing the command buffer
    58 * Parameter:			a_offset - the offset into the buffer where we should start parsing
    58 * Parameter:			a_offset - the offset into the buffer where we should start parsing
    59 */
    59 */
    60 
    60 
    61 void BFTP::ReqPDU(const TDesC8& a_Header, TInt a_offset)
    61 void BFTP::ReqPDU(const TDesC8& /*a_Header*/, TInt /*a_offset*/)
       
    62 /** No Longer used.
       
    63 
       
    64 irda client libraries left in to avoid breaks */
    62 	{
    65 	{
    63 	BFTPPRINT(_L("BFTP: ReqPDU\n"));
       
    64 	
       
    65 	TUint16 AttNum = IrTranpUtil::DExtract(a_Header, a_offset);
       
    66 	a_offset+=2;
       
    67 	
       
    68 	for(TInt i=0;i<AttNum;i++) // Loop all AttNames
       
    69 		{
       
    70 		TBuf8<4> attName; // BFTP Attribute name
       
    71 		for(TInt j=0;j<4;j++) // we don't like it .. hardcoded
       
    72 			{
       
    73 			attName.Append(a_Header[a_offset+j]);
       
    74 			}
       
    75 		
       
    76 		a_offset+=4;
       
    77 		
       
    78 		if(attName.Compare(KTranpFIL0) == 0)
       
    79 			{
       
    80 			TUint32 length = IrTranpUtil::LExtract(a_Header, a_offset);
       
    81 			BFTPPRINT(_L("BFTP: Attribute FIL0\n"));
       
    82 			
       
    83 			m_FileName.SetLength(0);
       
    84 			m_FileName.Append((unsigned char*)a_Header.Ptr() + a_offset + 6, length-2);
       
    85 			
       
    86 			a_offset+=(length+4);
       
    87 			}
       
    88 		else if(attName.Compare(KTranpLFL0) == 0)
       
    89 			{
       
    90 			TUint32 length = IrTranpUtil::LExtract(a_Header, a_offset);
       
    91 			BFTPPRINT(_L("BFTP: Attribute LFL0\n"));
       
    92 
       
    93 			iLongFilename.Append((unsigned char*)a_Header.Ptr() + a_offset + 6, length-2);
       
    94 
       
    95 			a_offset+=(length+4);
       
    96 			}
       
    97 		else if(attName.Compare(KTranpTIM0) == 0)
       
    98 			{
       
    99 			TUint32 length = IrTranpUtil::LExtract(a_Header, a_offset);
       
   100 			BFTPPRINT(_L("BFTP: Attribute TIM0\n"));
       
   101 			a_offset+=(length+4);
       
   102 			}
       
   103 		else if(attName.Compare(KTranpTYP0) == 0)
       
   104 			{
       
   105 			TUint32 length = IrTranpUtil::LExtract(a_Header, a_offset);
       
   106 			BFTPPRINT(_L("BFTP: Attribute TYP0\n"));
       
   107 			a_offset+=(length+4);
       
   108 			}
       
   109 		else if(attName.Compare(KTranpTMB0) == 0)
       
   110 			{
       
   111 			TUint32 length = IrTranpUtil::LExtract(a_Header, a_offset);
       
   112 			BFTPPRINT(_L("BFTP: Attribute TMB0\n"));
       
   113 			a_offset+=(length+4);
       
   114 			}
       
   115 		else if(attName.Compare(KTranpBDY0) == 0)
       
   116 			{
       
   117 			TUint32 length = IrTranpUtil::LExtract(a_Header, a_offset);
       
   118 			BFTPPRINT(_L("BFTP: Attribute BDY0\n"));
       
   119 			
       
   120 			//iPicture.Set((unsigned char*)a_Header.Ptr() + a_offset + 6 + KTranpUPFHeader, length-2, length-2);
       
   121 			iUPFPicture.Set((unsigned char*)a_Header.Ptr() + a_offset + 6, length-2, length-2);
       
   122 			
       
   123 			iTranpProtocol->SetPicture(iPicture, m_FileName, iUPFPicture, iLongFilename);
       
   124 
       
   125 			a_offset+=(length+4);
       
   126 			/**/
       
   127 			TBuf8<256> userData;
       
   128 		
       
   129 			// AttNum
       
   130 			userData.Append(0x00);
       
   131 			userData.Append(0x01);
       
   132 			// attName
       
   133 			userData.Append(KTranpRPL0);
       
   134 			// AttLength
       
   135 			userData.Append(0x00);
       
   136 			userData.Append(0x00);
       
   137 			userData.Append(0x00);
       
   138 			userData.Append(2 + m_FileName.Length());
       
   139 			// AttType
       
   140 			userData.Append(0x01);
       
   141 			// AFLG
       
   142 			userData.Append(0x00);
       
   143 			// AttValue
       
   144 			userData.Append(m_FileName);
       
   145 			
       
   146 			TUint8 pduType = KTranpPduTypeRplAck;
       
   147 			m_oSCEP->SCEPSendCommand(userData, pduType); // We want SCEP to send a packet with this command
       
   148 			}
       
   149 		else if(attName.Compare(KTranpCMD0) == 0)
       
   150 			{
       
   151 			TUint32 length = IrTranpUtil::LExtract(a_Header, a_offset);
       
   152 			BFTPPRINT(_L("BFTP: Attribute CMD0\n"));
       
   153 			a_offset+=(length+4);
       
   154 			}
       
   155 		else if(attName.Compare(KTranpWHT0) == 0)
       
   156 			{
       
   157 			TUint32 length = IrTranpUtil::LExtract(a_Header, a_offset);
       
   158 			BFTPPRINT(_L("BFTP: Attribute WHT0\n"));
       
   159 			
       
   160 			// how to avoid copying of the information we put in the command??? Don't avoid it for now.
       
   161 			TPtr8 queryType((unsigned char*)a_Header.Ptr() + a_offset+6, 4, 4);
       
   162 
       
   163 			TBuf8<256> userData;
       
   164 			//TPtr8 userDataPtr = userData.Des();
       
   165 			
       
   166 			if (queryType.Compare(KTranpRIMG) == 0)
       
   167 				{
       
   168 				//This reply is for an RIMG query
       
   169 				// Its instructs the peer to send the image in its orginal lattice size
       
   170 
       
   171 				// AttNum
       
   172 				userData.Append(0x00);
       
   173 				userData.Append(0x01);
       
   174 				// AttName
       
   175 				userData.Append(KTranpBDY0);
       
   176 				// AttLength
       
   177 				userData.Append(0x00);
       
   178 				userData.Append(0x00);
       
   179 				userData.Append(0x00);
       
   180 				userData.Append(0x0d);
       
   181 				// AttType
       
   182 				userData.Append(0x00);
       
   183 				// AFLG
       
   184 				userData.Append(0x00);
       
   185 				
       
   186 				/*userData.Append(0x00);// <tag-pix-aspect> 3 bytes
       
   187 				userData.Append(0x01);
       
   188 				userData.Append(0x01);	*/
       
   189 
       
   190 				switch(iLatticeSize)
       
   191 					{
       
   192 				case EQVGA:
       
   193 					//QVGA:=320x240  (0x0140 x 0x00f0)
       
   194 //					userData.Append(0x01);// <tag-org-size>     5 bytes
       
   195 //					userData.Append(0x40); // width [2 bytes]
       
   196 //					userData.Append(0x01);
       
   197 //					userData.Append(0xf0);// height [2 bytes]
       
   198 //					userData.Append(0x00);
       
   199 				
       
   200 					userData.Append(0x02);// <tag-acc-size>     6 bytes
       
   201 					userData.Append(0x01);// <num-acc-size>
       
   202 					userData.Append(0x40);// width [2 bytes]
       
   203 					userData.Append(0x01);
       
   204 					userData.Append(0xf0);// height [2 bytes]
       
   205 					userData.Append(0x00);
       
   206 				break;
       
   207 				case EVGA :
       
   208 					// VGA:=640x480 ( 0x0280 x 0x01e0)
       
   209 //					userData.Append(0x01);// <tag-org-size>     5 bytes
       
   210 //					userData.Append(0x80); // width [2 bytes]
       
   211 //					userData.Append(0x02);
       
   212 //					userData.Append(0xe0);// height [2 bytes]
       
   213 //					userData.Append(0x01);
       
   214 				
       
   215 					userData.Append(0x02);// <tag-acc-size>     6 bytes
       
   216 					userData.Append(0x01);// <num-acc-size>
       
   217 					userData.Append(0x80); // width [2 bytes]
       
   218 					userData.Append(0x02);
       
   219 					userData.Append(0xe0);// height [2 bytes]
       
   220 					userData.Append(0x01);
       
   221 				break;
       
   222 				case ESVGA:
       
   223 					// SVGA:=800x600 (0x0320 x 0x0258)
       
   224 //					userData.Append(0x01);// <tag-org-size>     5 bytes
       
   225 //					userData.Append(0x20);// width [2 bytes]
       
   226 //					userData.Append(0x03);
       
   227 //					userData.Append(0x58);// height [2 bytes]
       
   228 //					userData.Append(0x02);
       
   229 				
       
   230 					userData.Append(0x02);// <tag-acc-size>     6 bytes
       
   231 					userData.Append(0x01);// <num-acc-size>
       
   232 					userData.Append(0x20);// width [2 bytes]
       
   233 					userData.Append(0x03);
       
   234 					userData.Append(0x58);// height [2 bytes]
       
   235 					userData.Append(0x02);
       
   236 					break;
       
   237 				case EXGA:
       
   238 					// XGA:=1024x768 ( 0x0400 x 0x0300)
       
   239 //					userData.Append(0x01);// <tag-org-size>     5 bytes
       
   240 //					userData.Append(0x00);// width [2 bytes]
       
   241 //					userData.Append(0x04);
       
   242 //					userData.Append(0x00);// height [2 bytes]
       
   243 //					userData.Append(0x30);
       
   244 				
       
   245 					userData.Append(0x02);// <tag-acc-size>     6 bytes
       
   246 					userData.Append(0x01);// <num-acc-size>
       
   247 					userData.Append(0x00);// width [2 bytes]
       
   248 					userData.Append(0x04);
       
   249 					userData.Append(0x00);// height [2 bytes]
       
   250 					userData.Append(0x03);	
       
   251 					break;
       
   252 				case ESXGA: 
       
   253 					// SXGA:=1280x960 (0x0500 x 0x03c0)
       
   254 //					userData.Append(0x01);// <tag-org-size>     5 bytes
       
   255 //					userData.Append(0x00);// width [2 bytes]
       
   256 //					userData.Append(0x05);
       
   257 //					userData.Append(0xc0);// height [2 bytes]
       
   258 //					userData.Append(0x03);
       
   259 				
       
   260 					userData.Append(0x02);// <tag-acc-size>     6 bytes
       
   261 					userData.Append(0x01);// <num-acc-size>
       
   262 					userData.Append(0x00);// width [2 bytes]
       
   263 					userData.Append(0x05);
       
   264 					userData.Append(0xc0);// height [2 bytes]
       
   265 					userData.Append(0x03);
       
   266 				break;
       
   267 				case EFREE:
       
   268 					// FREE:=m x n
       
   269 				default:
       
   270 					// Send in orginal size
       
   271 //					userData.Append(0x01);// <tag-org-size>     5 bytes
       
   272 //					userData.Append(0xFF);
       
   273 //					userData.Append(0xFF);
       
   274 //					userData.Append(0xFF);
       
   275 //					userData.Append(0xFF);
       
   276 				
       
   277 					userData.Append(0x02);// <tag-acc-size>     6 bytes
       
   278 					userData.Append(0x01);// <num-acc-size>
       
   279 					userData.Append(0xFF);// width [2 bytes]
       
   280 					userData.Append(0xFF);
       
   281 					userData.Append(0xFF);// height [2 bytes]
       
   282 					userData.Append(0xFF);	
       
   283 					};
       
   284 
       
   285 				/*userData.Append(0x03);// <tag-org-samp>   3 bytes
       
   286 				userData.Append(0xC4);
       
   287 				userData.Append(0x20);
       
   288 				
       
   289 				userData.Append(0x04);// <tag-acc-samp>   3 bytes
       
   290 				userData.Append(0xC4);
       
   291 				userData.Append(0x20);*/
       
   292 				
       
   293 				userData.Append(0x05);//<tag-acc-filesize> 5 bytes
       
   294 				userData.Append(0xFF);
       
   295 				userData.Append(0xFF);
       
   296 				userData.Append(0xFF);
       
   297 				userData.Append(0xFF);	
       
   298 				}
       
   299 			else if (queryType.Compare(KTranpRINF) == 0)
       
   300 				{
       
   301 				// This  reply is for an RINF query
       
   302 				userData.Append(0x00);
       
   303 				userData.Append(0x01);
       
   304 				// AttName
       
   305 				userData.Append(KTranpBDY0);
       
   306 				// AttLength
       
   307 				userData.Append(0x00);
       
   308 				userData.Append(0x00);
       
   309 				userData.Append(0x00);
       
   310 				userData.Append(0x08);
       
   311 				// AttType
       
   312 				userData.Append(0x00);
       
   313 				// AFLG
       
   314 				userData.Append(0x00);
       
   315 				// AttValue
       
   316 				userData.Append(0x10); // memory
       
   317 				userData.Append(0xff);
       
   318 				userData.Append(0xff);
       
   319 				userData.Append(0x11); // battery
       
   320 				userData.Append(0xff);
       
   321 				userData.Append(0xff);	
       
   322 				}
       
   323 			else if (queryType.Compare(KTranpRCMD) == 0)
       
   324 				{
       
   325                 // This  reply is for an RINF query
       
   326 				userData.Append(0x00);
       
   327 				userData.Append(0x01);
       
   328 				// AttName
       
   329 				userData.Append(KTranpBDY0);
       
   330 				// AttLength
       
   331 				userData.Append(0x00);
       
   332 				userData.Append(0x00);
       
   333 				userData.Append(0x00);
       
   334 				userData.Append(0x07);
       
   335 				// AttType
       
   336 				userData.Append(0x00);
       
   337 				// AFLG
       
   338 				userData.Append(0x00);
       
   339 				// AttValue
       
   340 				userData.Append(0x20); // tag-opt-func
       
   341                 userData.Append(0x00);
       
   342 				userData.Append(0x01);
       
   343 				userData.Append(0x00);
       
   344 				userData.Append(0x01); // func-multi-command
       
   345 				}
       
   346 
       
   347 			a_offset+=(length+4);
       
   348 
       
   349 			TUint8 pduType = KTranpPduTypeRplAck;
       
   350 			m_oSCEP->SCEPSendCommand(userData, pduType); // We want SCEP to send a packet with this command
       
   351 			}
       
   352 		else if(attName.Compare(KTranpERR0) == 0)
       
   353 			{
       
   354 			TUint32 length = IrTranpUtil::LExtract(a_Header, a_offset);
       
   355 			BFTPPRINT(_L("BFTP: Attribute ERR0\n"));
       
   356 			a_offset+=(length+4);
       
   357 			}
       
   358 		else if(attName.Compare(KTranpRPL0) == 0)
       
   359 			{
       
   360 			TUint32 length = IrTranpUtil::LExtract(a_Header, a_offset);
       
   361 			BFTPPRINT(_L("BFTP: Attribute RPL0\n"));
       
   362 			a_offset+=(length+4);
       
   363 			}
       
   364 	}
    66 	}
   365 	
       
   366 	BFTPPRINT(_L("BFTP: Exiting ReqPDU\n"));
       
   367 }
       
   368 
    67 
   369 /*
    68 /*
   370 * Method description:	Called from the application with a picture to send
    69 * Method description:	Called from the application with a picture to send
   371 *
    70 *
   372 * Parameter:			a_picture - TPtr pointing to the picture
    71 * Parameter:			a_picture - TPtr pointing to the picture