serviceproviders/sapi_calendar/src/calendarinterface.cpp
changeset 26 5d0ec8b709be
parent 10 fc9cf246af83
child 34 5dae2c62e9b6
equal deleted inserted replaced
23:50974a8b132e 26:5d0ec8b709be
  1301 				    entryType = GetEntryType( aCalendarName, entryAttributes->LocalUid() );
  1301 				    entryType = GetEntryType( aCalendarName, entryAttributes->LocalUid() );
  1302 				    }
  1302 				    }
  1303 				if ( entryType == -1 )
  1303 				if ( entryType == -1 )
  1304 					{
  1304 					{
  1305 					AppendErrorMessageL( KCmdAdd, KLocalId, KInvalid );
  1305 					AppendErrorMessageL( KCmdAdd, KLocalId, KInvalid );
  1306 					User::Leave( KErrArgument );
  1306 					User::Leave( KErrNotFound );
  1307 					}
  1307 					}
  1308 					
  1308 					
  1309 				// Leave if tring to set different entry type
  1309 				// Leave if tring to set different entry type
  1310 				if ( entryAttributes->ModifiedAttributes() & CEntryAttributes::EEntryType )
  1310 				if ( entryAttributes->ModifiedAttributes() & CEntryAttributes::EEntryType )
  1311 					{
  1311 					{
  1312 					TInt tmpType = entryAttributes->EntryType();
  1312 					TInt tmpType = entryAttributes->EntryType();
  1313 					if ( tmpType != entryType )
  1313 					if ( tmpType != entryType )
  1314 						{
  1314 						{
  1315 						AppendErrorMessageL( KCmdAdd, _L8("Entry Type "), KInvalid );
  1315 						AppendErrorMessageL( KCmdAdd, _L8("Entry Type "), KInvalid );
  1316 						User::Leave( KErrArgument );
  1316 						User::Leave( KErrBadName );
  1317 						}
  1317 						}
  1318 					}
  1318 					}
  1319 				}
  1319 				}
  1320 			
  1320 			
  1321 			//For Add			
  1321 			//For Add			
  1355 			if ( ( entryType != CCalEntry::ETodo ) && 
  1355 			if ( ( entryType != CCalEntry::ETodo ) && 
  1356 						inMap->FindL( KStartTime, inParam ) ) 
  1356 						inMap->FindL( KStartTime, inParam ) ) 
  1357 				{
  1357 				{
  1358 				ValidateParamTypeL( inParam, LIW::EVariantTypeTTime, 
  1358 				ValidateParamTypeL( inParam, LIW::EVariantTypeTTime, 
  1359 									KCmdAdd, KStartTime, KInvalid );
  1359 									KCmdAdd, KStartTime, KInvalid );
  1360 				
  1360 				iStTime = inParam.AsTTime();
  1361 				entryAttributes->SetStartTimeL( inParam.AsTTime() );
  1361 				entryAttributes->SetStartTimeL( inParam.AsTTime() );
  1362 				}
  1362 				}
  1363 				
  1363 				
  1364 			if ( ( ( entryType == CCalEntry::EAppt ) ||
  1364 			if ( ( ( entryType == CCalEntry::EAppt ) ||
  1365 					( entryType == CCalEntry::ETodo ) ||
  1365 					( entryType == CCalEntry::ETodo ) ||
  1366 					( entryType == CCalEntry::EEvent ) ) &&  
  1366 					( entryType == CCalEntry::EEvent ) ) &&  
  1367 					inMap->FindL( KEndTime, inParam ) )
  1367 					inMap->FindL( KEndTime, inParam ) )
  1368 				{
  1368 				{
  1369 				ValidateParamTypeL( inParam, LIW::EVariantTypeTTime, 
  1369 				ValidateParamTypeL( inParam, LIW::EVariantTypeTTime, 
  1370 									KCmdAdd, KEndTime, KInvalid );
  1370 									KCmdAdd, KEndTime, KInvalid );
  1371 				
  1371 				iEnTime = inParam.AsTTime();
  1372 				entryAttributes->SetEndTimeL( inParam.AsTTime() );
  1372 				entryAttributes->SetEndTimeL( inParam.AsTTime() );
  1373 				}
  1373 				}
  1374 				
  1374 				
  1375 			if ( inMap->FindL( KAlarmTime, inParam ) ) 
  1375 			if ( inMap->FindL( KAlarmTime, inParam ) ) 
  1376 				{
  1376 				{
  1608 						CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &rptParam));
  1608 						CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &rptParam));
  1609 						if ( map->FindL( KRepeatType, rptParam ) ) 
  1609 						if ( map->FindL( KRepeatType, rptParam ) ) 
  1610 							{
  1610 							{
  1611 							ValidateParamTypeL( rptParam, LIW::EVariantTypeTInt32, 
  1611 							ValidateParamTypeL( rptParam, LIW::EVariantTypeTInt32, 
  1612 											KCmdAdd, KRepeatType, KInvalid );
  1612 											KCmdAdd, KRepeatType, KInvalid );
       
  1613 							if(!isValidEntryDuration(rptParam.AsTInt32()))
       
  1614 							{
       
  1615                                 AppendErrorMessageL( KCmdAdd, KRepeatType, KInvalid );
       
  1616                                 User::Leave( KErrBadName );
       
  1617 							}
  1613 
  1618 
  1614 							rrule = CRepeatInfo::NewL( rptParam.AsTInt32() );
  1619 							rrule = CRepeatInfo::NewL( rptParam.AsTInt32() );
  1615 							CleanupStack::PushL( rrule );
  1620 							CleanupStack::PushL( rrule );
  1616 	                        }
  1621 	                        }
  1617 						else
  1622 						else
  3067 			break;
  3072 			break;
  3068 			}
  3073 			}
  3069 		}
  3074 		}
  3070 	return retValue;
  3075 	return retValue;
  3071 	}
  3076 	}
       
  3077 
       
  3078 
       
  3079 bool CCalendarInterface::isValidEntryDuration(int type)
       
  3080     {
       
  3081     TTime temp;
       
  3082     TDateTime temp1;
       
  3083     switch(type)
       
  3084         {
       
  3085         case TCalRRule::EDaily :
       
  3086             {
       
  3087             TTimeIntervalDays days = 1;
       
  3088             temp = iStTime + days;
       
  3089                       
       
  3090             }
       
  3091             break;
       
  3092 
       
  3093         case TCalRRule::EWeekly :
       
  3094             {
       
  3095             TTimeIntervalDays days = 7;
       
  3096             temp = iStTime + days;
       
  3097                                         
       
  3098             }
       
  3099             break;
       
  3100 
       
  3101         case TCalRRule::EMonthly :
       
  3102             {
       
  3103             TTimeIntervalMonths month = 1;
       
  3104             temp = iStTime + month;
       
  3105                   
       
  3106             }
       
  3107             break;
       
  3108 
       
  3109         case TCalRRule::EYearly :
       
  3110             {
       
  3111             TTimeIntervalYears yr = 1;
       
  3112             temp = iStTime + yr;
       
  3113                
       
  3114             }
       
  3115             break;
       
  3116 
       
  3117         }
       
  3118 
       
  3119     if(temp < iEnTime)
       
  3120         {
       
  3121         return false;
       
  3122         }
       
  3123 
       
  3124     else
       
  3125         {
       
  3126         return true;
       
  3127         }
       
  3128     
       
  3129     }