304 } |
321 } |
305 } |
322 } |
306 return valueNum; |
323 return valueNum; |
307 } |
324 } |
308 |
325 |
309 //#ifdef RD_DM_TEXT_INPUT_ALERT |
|
310 // --------------------------------------------------------- |
|
311 // CNSmlDMCmds::AlertInputTypeParameter() |
|
312 // For 1102-User Input server alert |
|
313 // For Input Type optional parameter |
|
314 // --------------------------------------------------------- |
|
315 TInt CNSmlDMCmds::AlertInputTypeParameter( const SmlPcdata_t* aData, const TDesC8& aParamID ) const |
|
316 { |
|
317 _DBG_FILE("CNSmlDMCmds::AlertInputTypeParameter: begin"); |
|
318 TInt valueNum = 0;//alphanumeric by default |
|
319 if ( aData ) |
|
320 { |
|
321 if ( aData->content ) |
|
322 { |
|
323 TPtr8 parameters( (TUint8*) aData->content, aData->length, aData->length ); |
|
324 TrimRightSpaceAndNull( parameters ); |
|
325 TInt startPos = parameters.Find( aParamID ); |
|
326 if ( startPos >= 0 ) |
|
327 { |
|
328 if ( parameters.Length() > startPos + aParamID.Length() ) |
|
329 { |
|
330 TPtrC8 strPart = parameters.Right( parameters.Length() - ( startPos + aParamID.Length() ) ); |
|
331 TInt length = 0; |
|
332 TChar character = strPart[length]; |
|
333 |
|
334 switch( character ) |
|
335 { |
|
336 case 'A': //Alphanumeric |
|
337 valueNum = ESyncMLInputTypeAlphaNumeric; |
|
338 break; |
|
339 case 'N': //Numeric |
|
340 valueNum = ESyncMLInputTypeNumeric; |
|
341 break; |
|
342 case 'D': //Date |
|
343 valueNum = ESyncMLInputTypeDate; |
|
344 break; |
|
345 case 'T': //Time |
|
346 valueNum = ESyncMLInputTypeTime; |
|
347 break; |
|
348 case 'P': //Phone number |
|
349 valueNum = ESyncMLInputTypePhoneNumber; |
|
350 break; |
|
351 case 'I': //Ip address |
|
352 valueNum = ESyncMLInputTypeIPAddress; |
|
353 break; |
|
354 } |
|
355 } |
|
356 } |
|
357 } |
|
358 } |
|
359 _DBG_FILE("CNSmlDMCmds::AlertInputTypeParameter: end"); |
|
360 return valueNum; |
|
361 } |
|
362 |
|
363 // --------------------------------------------------------- |
|
364 // CNSmlDMCmds::AlertEchoTypeParameter() |
|
365 // For 1102-User Input server alert |
|
366 // For Echo Type optional parameter |
|
367 // --------------------------------------------------------- |
|
368 TInt CNSmlDMCmds::AlertEchoTypeParameter( const SmlPcdata_t* aData, const TDesC8& aParamID ) const |
|
369 { |
|
370 _DBG_FILE("CNSmlDMCmds::AlertEchoTypeParameter: begin"); |
|
371 TInt valueNum = 0;//Text by default |
|
372 if ( aData ) |
|
373 { |
|
374 if ( aData->content ) |
|
375 { |
|
376 TPtr8 parameters( (TUint8*) aData->content, aData->length, aData->length ); |
|
377 TrimRightSpaceAndNull( parameters ); |
|
378 TInt startPos = parameters.Find( aParamID ); |
|
379 if ( startPos >= 0 ) |
|
380 { |
|
381 if ( parameters.Length() > startPos + aParamID.Length() ) |
|
382 { |
|
383 TPtrC8 strPart = parameters.Right( parameters.Length() - ( startPos + aParamID.Length() ) ); |
|
384 TInt length = 0; |
|
385 TChar character = strPart[length]; |
|
386 switch( character ) |
|
387 { |
|
388 |
|
389 case 'T': valueNum = ESyncMLEchoTypeText; |
|
390 break; |
|
391 case 'P': valueNum = ESyncMLEchoTypePassword; |
|
392 break; |
|
393 default: |
|
394 break; |
|
395 } |
|
396 } |
|
397 } |
|
398 } |
|
399 } |
|
400 _DBG_FILE("CNSmlDMCmds::AlertEchoTypeParameter: end"); |
|
401 return valueNum; |
|
402 } |
|
403 // --------------------------------------------------------- |
|
404 // CNSmlDMCmds::CheckDRPresence() |
|
405 // For 1102-User Input server alert |
|
406 // For Default Response item existence verification |
|
407 // --------------------------------------------------------- |
|
408 TBool CNSmlDMCmds::CheckDRPresence( const SmlPcdata_t* aData, const TDesC8& aParamID ) const |
|
409 { |
|
410 if ( aData ) |
|
411 { |
|
412 if ( aData->content ) |
|
413 { |
|
414 TPtr8 parameters( (TUint8*) aData->content, aData->length, aData->length ); |
|
415 TrimRightSpaceAndNull( parameters ); |
|
416 TInt startPos = parameters.Find( aParamID ); |
|
417 if ( startPos >= 0 ) |
|
418 { |
|
419 return ETrue; |
|
420 } |
|
421 } |
|
422 } |
|
423 return EFalse; |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------- |
|
427 // CNSmlDMCmds::AlertDefaultResponseParam() |
|
428 // For 1102-User Input server alert |
|
429 // For Default Response optional parameter |
|
430 // --------------------------------------------------------- |
|
431 TPtrC8 CNSmlDMCmds::AlertDefaultResponseParam( const SmlPcdata_t* aData, const TDesC8& aParamID ) const |
|
432 { |
|
433 _DBG_FILE("CNSmlDMCmds::AlertDefaultResponseParam: begin"); |
|
434 TLex8 value; |
|
435 if ( aData ) |
|
436 { |
|
437 if ( aData->content ) |
|
438 { |
|
439 TPtr8 parameters( (TUint8*) aData->content, aData->length, aData->length ); |
|
440 TrimRightSpaceAndNull( parameters ); |
|
441 TInt startPos = parameters.Find( aParamID ); |
|
442 if ( startPos >= 0 ) |
|
443 { |
|
444 if ( parameters.Length() > startPos + aParamID.Length() ) |
|
445 { |
|
446 TPtrC8 strPart = parameters.Right( parameters.Length() - ( startPos + aParamID.Length() ) ); |
|
447 TInt length = 0; |
|
448 while ( length < strPart.Length() ) |
|
449 { |
|
450 TChar character = strPart[length]; |
|
451 if ( character != '&' ) |
|
452 { |
|
453 ++length; |
|
454 } |
|
455 else |
|
456 { |
|
457 break; |
|
458 } |
|
459 } |
|
460 TPtrC8 valueStr = strPart.Left( length ); |
|
461 value.Assign( valueStr ); |
|
462 |
|
463 } |
|
464 } |
|
465 } |
|
466 } |
|
467 _DBG_FILE("CNSmlDMCmds::AlertDefaultResponseParam: end"); |
|
468 return value.Remainder(); |
|
469 } |
|
470 //#endif |
|
471 |
|
472 // --------------------------------------------------------- |
326 // --------------------------------------------------------- |
473 // CNSmlDMCmds::AlertDataLC() |
327 // CNSmlDMCmds::AlertDataLC() |
474 // |
328 // |
475 // --------------------------------------------------------- |
329 // --------------------------------------------------------- |
476 HBufC8* CNSmlDMCmds::AlertDataLC( const SmlItemList_t* aItemList ) const |
330 HBufC8* CNSmlDMCmds::AlertDataLC( const SmlItemList_t* aItemList ) const |
1184 } |
1031 } |
1185 else if(alertCode == KNSmlDMAgentContinueOrAbortAlert) |
1032 else if(alertCode == KNSmlDMAgentContinueOrAbortAlert) |
1186 { |
1033 { |
1187 HandleConfirmationAlertL(aAlert,aStatusId); |
1034 HandleConfirmationAlertL(aAlert,aStatusId); |
1188 } |
1035 } |
1189 else if(alertCode == KNSmlDMAgentUserInputAlert) |
1036 |
1190 { |
|
1191 HandleUserInputalertL(aAlert,aStatusId); |
|
1192 } |
|
1193 else if(alertCode == KNSmlDMAgentSingleChoiceAlert |
|
1194 || alertCode == KNSmlDMAgentMultipleChoiceAlert) |
|
1195 { |
|
1196 HandleChoiceAlertsL(aAlert,aStatusId); |
|
1197 } |
|
1198 else // |
1037 else // |
1199 { |
1038 { |
1200 |
1039 |
1201 } |
1040 } |
1202 } |
1041 } |
1203 } |
1042 } |
1204 |
1043 |
1205 // --------------------------------------------------------- |
|
1206 // CNSmlDMCmds::HandleChoiceAlertsL |
|
1207 // Handles Choice Alert commands from a server. |
|
1208 // --------------------------------------------------------- |
|
1209 void CNSmlDMCmds::HandleChoiceAlertsL( SmlAlert_t* aAlert, TInt& aStatusId) |
|
1210 { |
|
1211 const TChar KDRSeparator('-'); |
|
1212 const TChar KChoiceItemSeparator(','); |
|
1213 TPtr8 alertCode = AlertCode( aAlert ); |
|
1214 // MINDT |
|
1215 TInt mindt = AlertParameter( aAlert->itemList->item->data, KNSmlDMAgentMINDT ); |
|
1216 // MAXDT |
|
1217 TInt maxdt = AlertParameter( aAlert->itemList->item->data, KNSmlDMAgentMAXDT ); |
|
1218 if ( mindt > maxdt ) |
|
1219 { |
|
1220 maxdt = mindt; |
|
1221 } |
|
1222 TSyncMLDlgNotifParams notifyParams; |
|
1223 TInt maxlen = AlertParameter( aAlert->itemList->item->data, KNSmlDMAgentMAXLEN ); |
|
1224 |
|
1225 //check if iDR, Default response parameter is there or not |
|
1226 //DRPresent is used for destroying how many items in the pop up stack |
|
1227 TBool DRPresent = CheckDRPresence( aAlert->itemList->item->data, KNSmlDMAgentDR ); |
|
1228 if( DRPresent ) |
|
1229 { |
|
1230 TPtrC8 DrPtr = AlertDefaultResponseParam( aAlert->itemList->item->data, KNSmlDMAgentDR ); |
|
1231 HBufC8* hptr = HBufC8::NewLC( DrPtr.Length()+ 4 ); //cs 1dr |
|
1232 TPtr8 DrBuf(hptr->Des()); |
|
1233 if(alertCode == KNSmlDMAgentMultipleChoiceAlert) |
|
1234 { |
|
1235 _DBG_FILE("drbuf multichoice"); |
|
1236 DrBuf.Append(KDRSeparator); |
|
1237 DrBuf.Append(DrPtr); |
|
1238 DrBuf.Append(KDRSeparator); |
|
1239 } |
|
1240 else |
|
1241 { |
|
1242 DrBuf.Append(DrPtr); |
|
1243 } |
|
1244 HBufC* DrBuf16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( DrBuf ); |
|
1245 CleanupStack::PushL( DrBuf16 ); //cs 2dr |
|
1246 notifyParams.iDR = *DrBuf16; |
|
1247 } |
|
1248 HBufC8* alertData = AlertDataLC( aAlert->itemList ); //cs 1 |
|
1249 if ( alertData->Length() == 0) |
|
1250 { |
|
1251 if( DRPresent ) |
|
1252 { |
|
1253 CleanupStack::PopAndDestroy(2);//alertData,hptr,DrBuf16 |
|
1254 } |
|
1255 CleanupStack::PopAndDestroy();//alertData |
|
1256 iStatusToServer->SetStatusCodeL( aStatusId, TNSmlError::ESmlStatusIncompleteCommand ); |
|
1257 HandleAlertErrorL(); |
|
1258 return; |
|
1259 } |
|
1260 |
|
1261 HBufC8* alertDataWithMDT = HBufC8::NewLC(alertData->Length()+KNSmlDMAgentMINDT().Length()+KNSmlDMAgentMAXDT().Length()+6); //cs 2 |
|
1262 TPtr8 dataBuf = alertDataWithMDT->Des(); |
|
1263 dataBuf.Append(*alertData); |
|
1264 HBufC* dataBuf16 = NULL; |
|
1265 TRAPD(errC, dataBuf16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L(dataBuf)); |
|
1266 if( errC == KErrCorrupt ) |
|
1267 { |
|
1268 if( DRPresent ) |
|
1269 { |
|
1270 CleanupStack::PopAndDestroy(2); //alertData hptr,DrBuf16,alertDataWithMDT |
|
1271 } |
|
1272 CleanupStack::PopAndDestroy(2); //alertData alertDataWithMDT |
|
1273 iStatusToServer->SetStatusCodeL( aStatusId, TNSmlError::ESmlStatusCommandFailed ); |
|
1274 return; |
|
1275 } |
|
1276 CleanupStack::PushL(dataBuf16); //cs 3 |
|
1277 //RNotifier notifier; |
|
1278 //User::LeaveIfError( notifier.Connect() ); |
|
1279 //CleanupClosePushL(notifier); //cs |
|
1280 TPckgBuf<TBool> resBuf; |
|
1281 /* |
|
1282 //TO reduce cyclomatic complexity |
|
1283 if( dataBuf16->Length() > KSyncMLMaxServerMsgLength ) |
|
1284 { |
|
1285 notifyParams.iServerMsg = (*dataBuf16).Left(KSyncMLMaxServerMsgLength) ; |
|
1286 } |
|
1287 else |
|
1288 { |
|
1289 notifyParams.iServerMsg = *dataBuf16; |
|
1290 } */ |
|
1291 TInt datalength = FindMaxLength(dataBuf16->Length(),KSyncMLMaxServerMsgLength); |
|
1292 notifyParams.iServerMsg = (*dataBuf16).Left(datalength); |
|
1293 notifyParams.iMaxTime = maxdt; |
|
1294 notifyParams.iMaxLength = maxlen; |
|
1295 TRequestStatus status; |
|
1296 _DBG_FILE("starting of choice alerts"); |
|
1297 //Retrieve items list |
|
1298 HBufC8* lengthbuf = HBufC8::NewLC(100); //cs 4 |
|
1299 TInt NumItems = 0 ; |
|
1300 HBufC8* listitems = AlertChoiceItemsLC(aAlert->itemList,lengthbuf,NumItems); //cs 5 |
|
1301 if(!NumItems) |
|
1302 { |
|
1303 if( DRPresent ) |
|
1304 { |
|
1305 CleanupStack::PopAndDestroy(2); |
|
1306 } |
|
1307 CleanupStack::PopAndDestroy(5); |
|
1308 iStatusToServer->SetStatusCodeL( aStatusId, TNSmlError::ESmlStatusIncompleteCommand ); |
|
1309 return; |
|
1310 } |
|
1311 notifyParams.iNumberOfItems = NumItems; |
|
1312 HBufC* choiceitemslength = NULL; |
|
1313 TRAPD(errL, choiceitemslength = CnvUtfConverter::ConvertToUnicodeFromUtf8L(lengthbuf->Des())); |
|
1314 if( errL/* == KErrCorrupt*/ )//useful for low memory and other cases |
|
1315 { |
|
1316 if( DRPresent ) |
|
1317 { |
|
1318 CleanupStack::PopAndDestroy(2); |
|
1319 } |
|
1320 CleanupStack::PopAndDestroy(5); |
|
1321 iStatusToServer->SetStatusCodeL( aStatusId, TNSmlError::ESmlStatusCommandFailed ); |
|
1322 return; |
|
1323 } |
|
1324 CleanupStack::PushL(choiceitemslength); //cs 6 |
|
1325 |
|
1326 /* if( choiceitemslength->Length() > KSyncMLChoiceItemsLengthBuffer ) |
|
1327 { |
|
1328 notifyParams.iItemLength = (*choiceitemslength).Left(KSyncMLChoiceItemsLengthBuffer) ; |
|
1329 } |
|
1330 else |
|
1331 { |
|
1332 notifyParams.iItemLength = *choiceitemslength; |
|
1333 } */ |
|
1334 datalength = FindMaxLength(choiceitemslength->Length(),KSyncMLChoiceItemsLengthBuffer); |
|
1335 notifyParams.iItemLength = (*choiceitemslength).Left(datalength); |
|
1336 if( alertCode == KNSmlDMAgentMultipleChoiceAlert) |
|
1337 { |
|
1338 _DBG_FILE("multiple choice alerts"); |
|
1339 notifyParams.iNoteType = ESyncMLMultiChoiceQuery; |
|
1340 } |
|
1341 else |
|
1342 { |
|
1343 _DBG_FILE("single choice alerts"); |
|
1344 notifyParams.iNoteType = ESyncMLSingleChoiceQuery; |
|
1345 } |
|
1346 if(iChunk.Handle()) |
|
1347 iChunk.Close(); |
|
1348 else |
|
1349 { |
|
1350 TTime now; |
|
1351 now.HomeTime(); |
|
1352 TInt64 rand = now.Int64(); |
|
1353 // Use timestamp to get a unique seed |
|
1354 TInt randnum = Math::Rand( rand ); |
|
1355 TBuf<KSyncMLMaxProfileNameLength> chunkname; |
|
1356 chunkname.AppendNum(randnum); |
|
1357 chunkname.Append(KChunkName); |
|
1358 notifyParams.iChunkName = chunkname; |
|
1359 TInt err1 = iChunk.CreateGlobal( chunkname, |
|
1360 KNSmlDmChoiceChunkMinSize, KNSmlDmChoiceChunkMaxSize ); |
|
1361 DBG_FILE_CODE(err1,_S8("chunk creating error is ")); |
|
1362 if( err1 < 0 && err1 != KErrAlreadyExists ) |
|
1363 User::LeaveIfError(err1); |
|
1364 if( err1 == KErrAlreadyExists ) |
|
1365 { err1 = iChunk.OpenGlobal(chunkname,EFalse); |
|
1366 DBG_FILE_CODE(err1,_S8("chunk opening error is ")); |
|
1367 User::LeaveIfError(err1); |
|
1368 } |
|
1369 } |
|
1370 TInt size1 = iChunk.Size(); |
|
1371 DBG_FILE_CODE(size1,_S8("chunk size is ")); |
|
1372 |
|
1373 RMemWriteStream chunkStream ( iChunk.Base(), iChunk.Size() ); |
|
1374 CleanupClosePushL ( chunkStream ); //cs |
|
1375 chunkStream.WriteL ( listitems->Des() ); |
|
1376 CleanupStack::PopAndDestroy(1);//chunkstream |
|
1377 TPckgBuf<TSyncMLDlgNotifParams> pkgBuf( notifyParams ); |
|
1378 TSyncMLDlgNotifReturnParams emptybuf; |
|
1379 TSyncMLDlgNotifReturnParamsPckg resultBuf( emptybuf ); |
|
1380 RNotifier notifier; |
|
1381 User::LeaveIfError( notifier.Connect() ); |
|
1382 CleanupClosePushL(notifier); //cs 7 |
|
1383 _DBG_FILE("starting choice notifier"); |
|
1384 notifier.StartNotifierAndGetResponse( status, KNSmlSyncDialogUid, pkgBuf, resultBuf ); |
|
1385 _DBG_FILE("notifier returned"); |
|
1386 User::WaitForRequest( status ); |
|
1387 CleanupStack::PopAndDestroy(4);//notifier,lengthbuf,listitems,choiceitemslength |
|
1388 iChunk.Close(); |
|
1389 TBuf8<KSyncMLMaxAlertResultLength> rettext; |
|
1390 rettext.Copy( resultBuf().irettext.Left( KSyncMLMaxAlertResultLength ) ); |
|
1391 if ( status != KErrNone ) |
|
1392 { |
|
1393 TInt error = TNSmlError::ESmlStatusOperationCancelled ; |
|
1394 iStatusToServer->SetStatusCodeL( aStatusId, error ); |
|
1395 HandleAlertErrorL(); |
|
1396 } |
|
1397 else |
|
1398 { |
|
1399 //For sending data to server |
|
1400 if( alertCode == KNSmlDMAgentMultipleChoiceAlert) |
|
1401 { |
|
1402 SendMultiChoiceDataToServerL(rettext,aStatusId); |
|
1403 } |
|
1404 else |
|
1405 { |
|
1406 SmlPcdata_t* data = NULL; |
|
1407 PcdataNewL( data, rettext); |
|
1408 CleanupStack::PushL( data ); |
|
1409 iStatusToServer->AddItemDataL( aStatusId, data ); |
|
1410 CleanupStack::PopAndDestroy(); //data |
|
1411 } |
|
1412 } |
|
1413 if( DRPresent ) |
|
1414 CleanupStack::PopAndDestroy(2); //hptr,DrBuf16 |
|
1415 |
|
1416 CleanupStack::PopAndDestroy(3); //notifier,alertData,alertDataWithMDT,dataBuf16 |
|
1417 } |
|
1418 |
|
1419 // --------------------------------------------------------- |
|
1420 // CNSmlDMCmds::SendMultiChoiceDataToServerL |
|
1421 // Sends Multiple Choice Alert status to server. |
|
1422 // --------------------------------------------------------- |
|
1423 void CNSmlDMCmds::SendMultiChoiceDataToServerL(TDes8& aData,TInt& aStatusId) |
|
1424 { |
|
1425 const TChar KDRSeparator('-'); |
|
1426 TPtrC8 temp1,temp2; |
|
1427 TInt prevcommapos = 0; |
|
1428 SmlPcdata_t* data = NULL; |
|
1429 for(TInt i=0;i<aData.Length();i++) |
|
1430 { |
|
1431 //find a slash |
|
1432 |
|
1433 if(aData[i]== KDRSeparator) |
|
1434 { |
|
1435 if(prevcommapos) |
|
1436 { |
|
1437 |
|
1438 temp1.Set(aData.Left(i)); |
|
1439 temp2.Set(temp1.Right(i-(prevcommapos+1))); |
|
1440 prevcommapos= i; |
|
1441 } |
|
1442 else //firsttime finding comma |
|
1443 { |
|
1444 prevcommapos= i; |
|
1445 temp1.Set(aData.Left(i)); |
|
1446 temp2.Set(temp1.Right(i)); |
|
1447 } |
|
1448 //convert temp2 to number |
|
1449 PcdataNewL( data, temp2); |
|
1450 CleanupStack::PushL( data ); |
|
1451 iStatusToServer->AddItemDataL( aStatusId, data ); |
|
1452 CleanupStack::PopAndDestroy(); //data |
|
1453 data = NULL; |
|
1454 |
|
1455 } |
|
1456 } |
|
1457 |
|
1458 } |
|
1459 |
1044 |
1460 // --------------------------------------------------------- |
1045 // --------------------------------------------------------- |
1461 // CNSmlDMCmds::HandleConfirmationAlertL |
1046 // CNSmlDMCmds::HandleConfirmationAlertL |
1462 // Handles Confirmation Alert command from a server. |
1047 // Handles Confirmation Alert command from a server. |
1463 // --------------------------------------------------------- |
1048 // --------------------------------------------------------- |
1508 notifyParams.iMaxTime = maxdt; |
1091 notifyParams.iMaxTime = maxdt; |
1509 notifyParams.iMaxLength = maxlen; |
1092 notifyParams.iMaxLength = maxlen; |
1510 TRequestStatus status; |
1093 TRequestStatus status; |
1511 //Note type to Query note |
1094 //Note type to Query note |
1512 notifyParams.iNoteType = ESyncMLYesNoQuery; |
1095 notifyParams.iNoteType = ESyncMLYesNoQuery; |
1513 TPckgBuf<TSyncMLDlgNotifParams> pkgBuf( notifyParams ); |
1096 TPckgBuf<TSyncMLDlgNotifParams> pkgBuf(notifyParams); |
1514 notifier.StartNotifierAndGetResponse(status,KNSmlSyncDialogUid,pkgBuf,resBuf); |
1097 |
1515 User::WaitForRequest(status); |
1098 |
1516 TBool ret = resBuf(); |
1099 if(!IsHbSyncmlNotifierEnabledL()) |
1517 if ( status == KErrCancel || status == KErrTimedOut ) |
1100 { |
|
1101 _DBG_FILE("starting notifier"); |
|
1102 |
|
1103 } |
|
1104 else |
|
1105 { |
|
1106 |
|
1107 TInt statusval; |
|
1108 ServerHbNotifierL(notifyParams.iNoteType, notifyParams.iServerMsg); |
|
1109 TInt err = RProperty::Get(dmagentuid, EHbDMSyncNotifierKeyStatusReturn, statusval); |
|
1110 LOGSTRING2("get error status = %d", err); |
|
1111 if(err == KErrNone) |
|
1112 { |
|
1113 status = statusval; |
|
1114 LOGSTRING2("get statusval = %d", status.Int()); |
|
1115 } |
|
1116 |
|
1117 } |
|
1118 |
|
1119 if (status == KErrCancel || status == KErrTimedOut) |
1518 { |
1120 { |
1519 TInt error = status == KErrCancel ? TNSmlError::ESmlStatusNotModified : TNSmlError::ESmlStatusRequestTimeout; |
1121 TInt error = status == KErrCancel ? TNSmlError::ESmlStatusNotModified : TNSmlError::ESmlStatusRequestTimeout; |
1520 iStatusToServer->SetStatusCodeL( aStatusId, error ); |
1122 iStatusToServer->SetStatusCodeL( aStatusId, error ); |
1521 HandleAlertErrorL(); |
1123 HandleAlertErrorL(); |
1522 } |
1124 } |
1523 CleanupStack::PopAndDestroy(4); //alertData alertDataWithMDT,databuf16,notifier |
1125 CleanupStack::PopAndDestroy(3); //alertData alertDataWithMDT,databuf16 |
1524 } |
1126 } |
1525 |
|
1526 // --------------------------------------------------------- |
|
1527 // CNSmlDMCmds::HandleUserInputalertL |
|
1528 // Handles user Text Input Alert command from a server. |
|
1529 // --------------------------------------------------------- |
|
1530 void CNSmlDMCmds::HandleUserInputalertL( SmlAlert_t* aAlert, TInt& aStatusId) |
|
1531 { |
|
1532 // MINDT |
|
1533 TInt mindt = AlertParameter( aAlert->itemList->item->data, KNSmlDMAgentMINDT ); |
|
1534 // MAXDT |
|
1535 TInt maxdt = AlertParameter( aAlert->itemList->item->data, KNSmlDMAgentMAXDT ); |
|
1536 if ( mindt > maxdt ) |
|
1537 { |
|
1538 maxdt = mindt; |
|
1539 } |
|
1540 TSyncMLDlgNotifParams notifyParams; |
|
1541 TInt maxlen = AlertParameter( aAlert->itemList->item->data, KNSmlDMAgentMAXLEN ); |
|
1542 TInt InputType = AlertInputTypeParameter( aAlert->itemList->item->data, KNSmlDMAgentIT ); |
|
1543 TInt EchoType = AlertEchoTypeParameter( aAlert->itemList->item->data, KNSmlDMAgentET ); |
|
1544 //check if iDR, Default response parameter is there or not |
|
1545 //DRPresent is used for destroying how many items in the pop up stack |
|
1546 TBool DRPresent = CheckDRPresence( aAlert->itemList->item->data, KNSmlDMAgentDR ); |
|
1547 if( DRPresent ) |
|
1548 { |
|
1549 TPtrC8 DrPtr = AlertDefaultResponseParam( aAlert->itemList->item->data, KNSmlDMAgentDR ); |
|
1550 HBufC8* hptr = HBufC8::NewLC( DrPtr.Length()+ 4 ); //cs |
|
1551 TPtr8 DrBuf(hptr->Des()); |
|
1552 |
|
1553 DrBuf.Append(DrPtr); |
|
1554 |
|
1555 HBufC* DrBuf16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( DrBuf ); |
|
1556 CleanupStack::PushL( DrBuf16 );//cs |
|
1557 notifyParams.iDR = *DrBuf16; |
|
1558 } |
|
1559 HBufC8* alertData = AlertDataLC( aAlert->itemList );//cs |
|
1560 if ( alertData->Length() == 0) |
|
1561 { |
|
1562 if( DRPresent ) |
|
1563 { |
|
1564 CleanupStack::PopAndDestroy(3);//alertData,hptr,DrBuf16 |
|
1565 } |
|
1566 else |
|
1567 { |
|
1568 CleanupStack::PopAndDestroy();//alertData |
|
1569 } |
|
1570 iStatusToServer->SetStatusCodeL( aStatusId, TNSmlError::ESmlStatusIncompleteCommand ); |
|
1571 HandleAlertErrorL(); |
|
1572 return; |
|
1573 } |
|
1574 HBufC8* alertDataWithMDT = HBufC8::NewLC(alertData->Length()+KNSmlDMAgentMINDT().Length()+KNSmlDMAgentMAXDT().Length()+6);//cs |
|
1575 TPtr8 dataBuf = alertDataWithMDT->Des(); |
|
1576 dataBuf.Append(*alertData); |
|
1577 HBufC* dataBuf16 = NULL; |
|
1578 TRAPD(errC, dataBuf16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L(dataBuf)); |
|
1579 if( errC == KErrCorrupt ) |
|
1580 { |
|
1581 if( DRPresent ) |
|
1582 { |
|
1583 CleanupStack::PopAndDestroy(4); //alertData hptr,DrBuf16,alertDataWithMDT |
|
1584 } |
|
1585 else |
|
1586 { |
|
1587 CleanupStack::PopAndDestroy(2); //alertData alertDataWithMDT |
|
1588 } |
|
1589 iStatusToServer->SetStatusCodeL( aStatusId, TNSmlError::ESmlStatusCommandFailed ); |
|
1590 return; |
|
1591 } |
|
1592 CleanupStack::PushL(dataBuf16); //cs |
|
1593 RNotifier notifier; |
|
1594 User::LeaveIfError( notifier.Connect() ); |
|
1595 CleanupClosePushL(notifier); //cs |
|
1596 TPckgBuf<TBool> resBuf; |
|
1597 if( dataBuf16->Length() > KSyncMLMaxServerMsgLength ) |
|
1598 { |
|
1599 notifyParams.iServerMsg = (*dataBuf16).Left(KSyncMLMaxServerMsgLength) ; |
|
1600 } |
|
1601 else |
|
1602 { |
|
1603 notifyParams.iServerMsg = *dataBuf16; |
|
1604 } |
|
1605 notifyParams.iMaxTime = maxdt; |
|
1606 notifyParams.iMaxLength = maxlen; |
|
1607 notifyParams.iET = EchoType; |
|
1608 notifyParams.iIT = InputType; |
|
1609 TRequestStatus status; |
|
1610 //Note type to Text input note |
|
1611 notifyParams.iNoteType = ESyncMLInputQuery; |
|
1612 TPckgBuf<TSyncMLDlgNotifParams> pkgBuf( notifyParams ); |
|
1613 TSyncMLDlgNotifReturnParams emptybuf; |
|
1614 TSyncMLDlgNotifReturnParamsPckg resultBuf( emptybuf ); |
|
1615 notifier.StartNotifierAndGetResponse( status, KNSmlSyncDialogUid, pkgBuf, resultBuf ); |
|
1616 User::WaitForRequest( status ); |
|
1617 TBuf8<KSyncMLMaxDefaultResponseMsgLength> rettext; |
|
1618 rettext.Copy( resultBuf().irettext.Left( KSyncMLMaxDefaultResponseMsgLength ) ); |
|
1619 if ( status == KErrCancel || status == KErrTimedOut || status == KErrAbort ) |
|
1620 { |
|
1621 TInt error = TNSmlError::ESmlStatusOperationCancelled ; |
|
1622 iStatusToServer->SetStatusCodeL( aStatusId, error ); |
|
1623 HandleAlertErrorL(); |
|
1624 } |
|
1625 //For sending data to server |
|
1626 SmlPcdata_t* data = NULL; |
|
1627 PcdataNewL( data, rettext); |
|
1628 CleanupStack::PushL( data ); |
|
1629 iStatusToServer->AddItemDataL( aStatusId, data ); |
|
1630 CleanupStack::PopAndDestroy(); //data |
|
1631 if( DRPresent ) |
|
1632 CleanupStack::PopAndDestroy(6); //notifier,alertData,alertDataWithMDT,dataBuf16,hptr,DrBuf16 |
|
1633 else |
|
1634 //#endif |
|
1635 CleanupStack::PopAndDestroy(4); //notifier,alertData,alertDataWithMDT,dataBuf16 |
|
1636 } |
|
1637 |
1127 |
1638 // --------------------------------------------------------- |
1128 // --------------------------------------------------------- |
1639 // CNSmlDMCmds::HandleDisplayAlertL |
1129 // CNSmlDMCmds::HandleDisplayAlertL |
1640 // Handles Display Alert command from a server. |
1130 // Handles Display Alert command from a server. |
1641 // --------------------------------------------------------- |
1131 // --------------------------------------------------------- |
1686 notifyParams.iMaxTime = maxdt; |
1174 notifyParams.iMaxTime = maxdt; |
1687 notifyParams.iMaxLength = maxlen; |
1175 notifyParams.iMaxLength = maxlen; |
1688 TRequestStatus status; |
1176 TRequestStatus status; |
1689 notifyParams.iNoteType = ESyncMLInfoNote; |
1177 notifyParams.iNoteType = ESyncMLInfoNote; |
1690 TPckgBuf<TSyncMLDlgNotifParams> pkgBuf( notifyParams ); |
1178 TPckgBuf<TSyncMLDlgNotifParams> pkgBuf( notifyParams ); |
1691 notifier.StartNotifierAndGetResponse(status,KNSmlSyncDialogUid,pkgBuf,resBuf); |
1179 if(!IsHbSyncmlNotifierEnabledL()) |
1692 User::WaitForRequest(status); |
1180 { |
1693 CleanupStack::PopAndDestroy(4); //alertData alertDataWithMDT,databuf16,notifier |
1181 |
1694 } |
1182 } |
1695 |
1183 else |
|
1184 { |
|
1185 LOGSTRING("HandleDisplayAlertL Start test 1 start"); |
|
1186 ServerHbNotifierL(notifyParams.iNoteType, notifyParams.iServerMsg); |
|
1187 LOGSTRING("HandleDisplayAlertL Start test 2 end"); |
|
1188 } |
|
1189 |
|
1190 CleanupStack::PopAndDestroy(3); //alertData alertDataWithMDT,databuf16 |
|
1191 |
|
1192 |
|
1193 } |
|
1194 |
|
1195 void CNSmlDMCmds::ServerHbNotifierL(TSyncMLDlgNoteTypes& aNotetype, TDesC& aServerMsg) |
|
1196 |
|
1197 { |
|
1198 LOGSTRING("HandleDisplayAlertL ServerHbNotifier start"); |
|
1199 RDmDevDialog DmDevdialog; |
|
1200 TInt err = DmDevdialog.OpenL(); |
|
1201 User::LeaveIfError(err); |
|
1202 TRequestStatus status = KRequestPending; |
|
1203 if(aNotetype == ESyncMLInfoNote) |
|
1204 { |
|
1205 DmDevdialog.ShowDisplayAlert(aServerMsg,status); |
|
1206 } |
|
1207 |
|
1208 else |
|
1209 { |
|
1210 TInt timeout = 30; // dummy |
|
1211 TBuf<30> header; // dummy |
|
1212 DmDevdialog.ShowConfirmationAlert(timeout,header,aServerMsg,status); |
|
1213 } |
|
1214 |
|
1215 User::WaitForRequest(status); |
|
1216 |
|
1217 DmDevdialog.Close(); |
|
1218 LOGSTRING("HandleDisplayAlertL ServerHbNotifier end"); |
|
1219 |
|
1220 } |
|
1221 TBool CNSmlDMCmds::IsHbSyncmlNotifierEnabledL() |
|
1222 { |
|
1223 CRepository * rep = |
|
1224 CRepository::NewLC(KCRUidDeviceManagementInternalKeys); |
|
1225 |
|
1226 TInt notifierenabled = KErrNone; |
|
1227 |
|
1228 TInt err = rep->Get(KDevManEnableHbNotifier, notifierenabled); |
|
1229 |
|
1230 CleanupStack::PopAndDestroy(rep); |
|
1231 |
|
1232 if (err == KErrNone && notifierenabled) |
|
1233 { |
|
1234 return ETrue; |
|
1235 } |
|
1236 else |
|
1237 { |
|
1238 return EFalse; |
|
1239 } |
|
1240 |
|
1241 } |
|
1242 |
1696 // --------------------------------------------------------- |
1243 // --------------------------------------------------------- |
1697 // CNSmlDMCmds::ProcessSyncL() |
1244 // CNSmlDMCmds::ProcessSyncL() |
1698 // Process received Add, Replace and Delete commands |
1245 // Process received Add, Replace and Delete commands |
1699 // --------------------------------------------------------- |
1246 // --------------------------------------------------------- |
1700 void CNSmlDMCmds::ProcessSyncL( SmlSync_t* /*aSync*/ ) |
1247 void CNSmlDMCmds::ProcessSyncL( SmlSync_t* /*aSync*/ ) |
2287 if ( !aItem->target||!aItem->target->locURI ) |
1834 if ( !aItem->target||!aItem->target->locURI ) |
2288 { |
1835 { |
2289 aStatusCode = TNSmlError::ESmlStatusIncompleteCommand; |
1836 aStatusCode = TNSmlError::ESmlStatusIncompleteCommand; |
2290 } |
1837 } |
2291 } |
1838 } |
2292 |
|
2293 // --------------------------------------------------------------------------------------------------------------- |
|
2294 // CNSmlDMCmds::AlertChoiceItemsLC() |
|
2295 // Retrieves the choice alerts information |
|
2296 // --------------------------------------------------------------------------------------------------------------- |
|
2297 HBufC8* CNSmlDMCmds::AlertChoiceItemsLC(SmlItemList_t* aItemList,HBufC8*& aLengthBuf ,TInt& aNumItems ) const |
|
2298 { |
|
2299 /*cleanupstack contains |
|
2300 * top : tempdata |
|
2301 * : unicodeData |
|
2302 * bottom: aLengthBuf |
|
2303 */ |
|
2304 const TChar KDRSeparator('-'); |
|
2305 const TChar KChoiceItemSeparator(','); |
|
2306 HBufC8* unicodeData = HBufC8::NewLC(200); |
|
2307 HBufC8* tempdata = NULL; |
|
2308 HBufC8* lengthbuf = aLengthBuf; |
|
2309 TBuf<20> lennum; |
|
2310 SmlItemList_t* temp; |
|
2311 if ( aItemList )//Not null |
|
2312 { |
|
2313 if(aItemList->next)//removing header of dialog |
|
2314 { |
|
2315 temp = aItemList->next; |
|
2316 while(temp->next) |
|
2317 { |
|
2318 if ( temp->next->item ) |
|
2319 { |
|
2320 if ( temp->next->item->data ) |
|
2321 { |
|
2322 if ( temp->next->item->data->content ) |
|
2323 { |
|
2324 TPtr8 data( (TUint8*) temp->next->item->data->content, temp->next->item->data->length, temp->next->item->data->length ); |
|
2325 TrimRightSpaceAndNull( data ); |
|
2326 tempdata = data.AllocLC(); |
|
2327 TInt length = data.Length();//item length |
|
2328 //add length to buffer and add comma |
|
2329 if(lengthbuf->Des().MaxLength() > (lengthbuf->Des().Length() + 5/*bytes*/) ) |
|
2330 { |
|
2331 if(length > KSyncMLMaxChoiceItemLength ) // choice item length restricting to 200 |
|
2332 { |
|
2333 lennum.Num(KSyncMLMaxChoiceItemLength); |
|
2334 lengthbuf->Des().Append(lennum); |
|
2335 lengthbuf->Des().Append(KChoiceItemSeparator); |
|
2336 } |
|
2337 else |
|
2338 { |
|
2339 lennum.Num(length); |
|
2340 lengthbuf->Des().Append(lennum); |
|
2341 lengthbuf->Des().Append(KChoiceItemSeparator); |
|
2342 } |
|
2343 } |
|
2344 else |
|
2345 { |
|
2346 //Pop the aLengthBuf from cleanupstack and realloc |
|
2347 CleanupStack::Pop(3); //tempdata,unicodeData,aLengthBuf |
|
2348 lengthbuf = lengthbuf->ReAllocL(lengthbuf->Des().Length() + 100); |
|
2349 CleanupStack::PushL(lengthbuf); |
|
2350 CleanupStack::PushL(unicodeData); |
|
2351 CleanupStack::PushL(tempdata); |
|
2352 if(length > KSyncMLMaxChoiceItemLength ) // choice item length restricting to 200 |
|
2353 { |
|
2354 lengthbuf->Des().AppendNum(KSyncMLMaxChoiceItemLength); |
|
2355 lengthbuf->Des().Append(KChoiceItemSeparator); |
|
2356 } |
|
2357 else |
|
2358 { |
|
2359 lengthbuf->Des().AppendNum(length); //Append(length); |
|
2360 lengthbuf->Des().Append(KChoiceItemSeparator); |
|
2361 } |
|
2362 } |
|
2363 if(unicodeData->Des().MaxLength()> (unicodeData->Des().Length() + length)) |
|
2364 { |
|
2365 if(length > KSyncMLMaxChoiceItemLength ) // choice item length restricting to 200 |
|
2366 { |
|
2367 unicodeData->Des().Append(tempdata->Des().Left(KSyncMLMaxChoiceItemLength)); |
|
2368 } |
|
2369 else |
|
2370 { |
|
2371 unicodeData->Des().Append(tempdata->Des()); |
|
2372 } |
|
2373 } |
|
2374 else |
|
2375 { |
|
2376 CleanupStack::Pop(2);//tempdata,unicodeData |
|
2377 unicodeData = unicodeData->ReAllocL(unicodeData->Des().Length() + length + 200); |
|
2378 CleanupStack::PushL(unicodeData); |
|
2379 CleanupStack::PushL(tempdata); |
|
2380 if(length > KSyncMLMaxChoiceItemLength ) // choice item length restricting to 200 |
|
2381 { |
|
2382 unicodeData->Des().Append(tempdata->Des().Left(KSyncMLMaxChoiceItemLength)); |
|
2383 } |
|
2384 else |
|
2385 { |
|
2386 unicodeData->Des().Append(tempdata->Des()); |
|
2387 } |
|
2388 } |
|
2389 CleanupStack::PopAndDestroy(tempdata); |
|
2390 aNumItems++; |
|
2391 data.Zero(); |
|
2392 } |
|
2393 } |
|
2394 } |
|
2395 temp = temp->next; |
|
2396 } |
|
2397 } |
|
2398 } |
|
2399 _DBG_FILE("CNSmlDMCmds::AlertDataLC: end"); |
|
2400 aLengthBuf = lengthbuf; |
|
2401 return unicodeData; |
|
2402 } |
|
2403 |
|
2404 // --------------------------------------------------------------------------------------------------------------- |
|
2405 // CNSmlDMCmds::FindMaxLength() |
|
2406 // --------------------------------------------------------------------------------------------------------------- |
|
2407 TInt CNSmlDMCmds::FindMaxLength(TInt aSourceLength, TInt aDestLength) |
|
2408 { |
|
2409 TInt length = 0; |
|
2410 if(aSourceLength > aDestLength ) |
|
2411 { |
|
2412 length = aDestLength; |
|
2413 } |
|
2414 else |
|
2415 { |
|
2416 length = aSourceLength; |
|
2417 } |
|
2418 return length; |
|
2419 } |
|