serviceproviders/sapi_calendar/tsrc/testing/tcalendarservice/tcal_update/src/tcal_updateblocks.cpp
changeset 22 fc9cf246af83
parent 19 989d2f495d90
child 33 50974a8b132e
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
   112         ENTRY( "UpdateRepeatingEntry", Ctcal_update::UpdateRepeatingEntry ),
   112         ENTRY( "UpdateRepeatingEntry", Ctcal_update::UpdateRepeatingEntry ),
   113         ENTRY( "UpdateApt", Ctcal_update::UpdateApt ),
   113         ENTRY( "UpdateApt", Ctcal_update::UpdateApt ),
   114         ENTRY( "UpdateAptWithAttendees", Ctcal_update::UpdateAptWithAttendees ),
   114         ENTRY( "UpdateAptWithAttendees", Ctcal_update::UpdateAptWithAttendees ),
   115         ENTRY( "UpdateRepeatDate", Ctcal_update::UpdateRepeatDate ),
   115         ENTRY( "UpdateRepeatDate", Ctcal_update::UpdateRepeatDate ),
   116         ENTRY( "UpdateInstance", Ctcal_update::UpdateInstance ),
   116         ENTRY( "UpdateInstance", Ctcal_update::UpdateInstance ),
   117         
   117  
       
   118         ENTRY( "UpdateToDoWithGlobalId", Ctcal_update::UpdateToDoWithGlobalId ),
       
   119         ENTRY( "UpdateInstanceWithGlobalId", Ctcal_update::UpdateInstanceWithGlobalId ),
       
   120 
   118         //ADD NEW ENTRY HERE
   121         //ADD NEW ENTRY HERE
   119 
   122 
   120         };
   123         };
   121 
   124 
   122     const TInt count = sizeof( KFunctions ) / 
   125     const TInt count = sizeof( KFunctions ) / 
   981 
   984 
   982 // ========================== OTHER EXPORTED FUNCTIONS =========================
   985 // ========================== OTHER EXPORTED FUNCTIONS =========================
   983 // None
   986 // None
   984 
   987 
   985 //  End of File
   988 //  End of File
       
   989 TInt Ctcal_update::UpdateToDoWithGlobalId( CStifItemParser& /*aItem*/ )
       
   990     {
       
   991 
       
   992     TInt result = KErrNone;
       
   993     
       
   994     
       
   995     CCalendarService* service = CCalendarService::NewL();
       
   996     
       
   997     RemoveCalendarFile( service, KTestCal1File );
       
   998 //  TRAPD(err_add,AddCalendarFile( service, KTestCalTestFile ));
       
   999     AddCalendarFile( service, KTestCal1File);
       
  1000     
       
  1001 
       
  1002     RPointerArray<TUIDSet> arruids(5);
       
  1003     
       
  1004     TUIDSet* uids = NULL;
       
  1005     
       
  1006     TInt err_addtodo;
       
  1007     
       
  1008 //  TInt test_addtodo = AddToDo(service, KTestCalTestFile, uids);
       
  1009     
       
  1010 //  if(test_addtodo != KErrNone)
       
  1011          err_addtodo = AddToDo(service, KTestCal1File, uids);
       
  1012     
       
  1013     if(err_addtodo == KErrNone && uids)
       
  1014         {
       
  1015         arruids.Append(uids);
       
  1016         uids = NULL;
       
  1017         }
       
  1018 
       
  1019         delete uids;
       
  1020     if ( arruids.Count() > 0 )
       
  1021         {
       
  1022         RPointerArray<CCalEntry> entryArray;
       
  1023         
       
  1024         CEntryAttributes* entryObj = CEntryAttributes::NewL();
       
  1025         
       
  1026         
       
  1027         entryObj->SetEntryStatusL(KStatusTodoCompleted); 
       
  1028         
       
  1029         
       
  1030         
       
  1031         
       
  1032         TRAPD(err_rep,entryObj->SetReplicationL(KTestRep));
       
  1033         if(err_rep != KErrNone)
       
  1034             entryObj->SetReplicationL(KReplPrivate);
       
  1035         
       
  1036     
       
  1037                 
       
  1038         service->GetListL( KTestCal1File, *(arruids[0]->iGlobalUID) , entryArray );
       
  1039 
       
  1040         if( entryArray.Count() == 1 )
       
  1041             {
       
  1042             entryObj->SetUidL( *(arruids[0]->iGlobalUID) );
       
  1043             
       
  1044             }
       
  1045             
       
  1046         TCalLocalUid modifiedEntryId;   
       
  1047         TUIDSet* entryUids = NULL;  
       
  1048         TRAPD( err, service->AddL(KTestCal1File,entryObj,entryUids) );
       
  1049         TInt err_new;
       
  1050         TInt err_add;
       
  1051                         
       
  1052         delete entryUids;
       
  1053         entryArray.ResetAndDestroy();
       
  1054         if ( err == KErrNone )
       
  1055             { 
       
  1056             service->GetListL( KTestCal1File, *(arruids[0]->iGlobalUID) , entryArray );
       
  1057             if( entryArray.Count() == 1 )
       
  1058                 {
       
  1059                 if( !(entryArray[0]->ReplicationStatusL() == CCalEntry::EPrivate && entryArray[0]->StatusL() == CCalEntry::ETodoCompleted))
       
  1060                     {
       
  1061                     result = KErrGeneral;   
       
  1062                     }
       
  1063                 }
       
  1064             }
       
  1065         else
       
  1066             {
       
  1067             result = KErrGeneral;       
       
  1068             }
       
  1069         entryArray.ResetAndDestroy();
       
  1070         arruids.ResetAndDestroy();
       
  1071         delete entryObj;
       
  1072         
       
  1073         
       
  1074         }
       
  1075         else
       
  1076             result = KErrGeneral;   
       
  1077 
       
  1078     RemoveCalendarFile( service, KTestCal1File );
       
  1079     
       
  1080     delete service;
       
  1081     
       
  1082     return result;
       
  1083     
       
  1084 
       
  1085     }
       
  1086     
       
  1087 TInt Ctcal_update::UpdateInstanceWithGlobalId( CStifItemParser& /*aItem*/ )
       
  1088     {
       
  1089 
       
  1090    TInt result = KErrNone;
       
  1091     
       
  1092     __UHEAP_MARK;
       
  1093     
       
  1094     CCalendarService* service = CCalendarService::NewL();
       
  1095     
       
  1096     RemoveCalendarFile( service, KTestCal1File );
       
  1097     AddCalendarFile( service, KTestCal1File );
       
  1098 
       
  1099     RPointerArray<TUIDSet> arruids(5);
       
  1100     
       
  1101     RPointerArray<CCalInstance> calInstanceArray;
       
  1102     
       
  1103     CCalendarFilter *getListfilter2 = CCalendarFilter::NewL();
       
  1104     
       
  1105     getListfilter2->SetFilterTypeL( KIncludeAll );
       
  1106     
       
  1107     TUIDSet* uids = NULL;
       
  1108     
       
  1109     if(AddRepeatingAppointmentEntryL(service, KTestCal1File, uids) == KErrNone && uids)
       
  1110         {
       
  1111         arruids.Append(uids);
       
  1112         uids = NULL;
       
  1113         }
       
  1114         
       
  1115     if(AddEvent(service, KTestCal1File, uids) == KErrNone && uids)
       
  1116         {
       
  1117         arruids.Append(uids);
       
  1118         uids = NULL;
       
  1119         }
       
  1120         
       
  1121     service->GetListL( KTestCal1File, getListfilter2 , calInstanceArray );
       
  1122     
       
  1123     TInt count = calInstanceArray.Count();
       
  1124     
       
  1125     calInstanceArray.ResetAndDestroy();
       
  1126     
       
  1127 
       
  1128     if ( arruids.Count() > 0 )
       
  1129         {
       
  1130         RPointerArray<CCalEntry> entryArray;
       
  1131         
       
  1132         CEntryAttributes* entryObj = CEntryAttributes::NewL();
       
  1133         
       
  1134         TTime stTime(TDateTime(2007, ESeptember, 17, 9, 0, 0, 0));
       
  1135         entryObj->SetInstanceStartTimeL(stTime);
       
  1136         TTime startTime(TDateTime(2007, ESeptember, 17, 14, 0, 0, 0));
       
  1137         entryObj->SetStartTimeL(startTime);
       
  1138         TTime endTime(TDateTime(2007, ESeptember, 17, 17, 30, 0, 0));
       
  1139         entryObj->SetEndTimeL(endTime);  
       
  1140         
       
  1141         CAttendeeInfo* attendee = CAttendeeInfo::NewL(_L("carendar@yahoo.com"));
       
  1142         CleanupStack::PushL(attendee);
       
  1143         attendee->SetRoleL(KAttRoleReqParticipant);
       
  1144         attendee->SetStatusL(KAttStatusTentative);
       
  1145         attendee->SetRsvp(EFalse);
       
  1146         
       
  1147         entryObj->AddAttendeeL(attendee);
       
  1148         CleanupStack::PopAndDestroy(attendee);
       
  1149         
       
  1150         attendee = CAttendeeInfo::NewL(_L("bettinapinto@gmail.com"));
       
  1151         CleanupStack::PushL(attendee);
       
  1152         attendee->SetCommonNameL(_L("SAPI"));
       
  1153         attendee->SetRoleL(KAttRoleReqParticipant);
       
  1154         attendee->SetStatusL(KAttStatusTentative);
       
  1155         attendee->SetRsvp(EFalse);
       
  1156         
       
  1157         entryObj->AddAttendeeL(attendee);
       
  1158         CleanupStack::PopAndDestroy(attendee);
       
  1159         
       
  1160         service->GetListL( KTestCal1File, *(arruids[0]->iGlobalUID) , entryArray );
       
  1161 
       
  1162         if( entryArray.Count() == 1 )
       
  1163             {
       
  1164             entryObj->SetUidL( *(arruids[0]->iGlobalUID) );
       
  1165             }
       
  1166             
       
  1167         TUIDSet* uids = NULL;
       
  1168        // TCalLocalUid modifiedEntryId;       
       
  1169         TRAPD( err, service->AddL(KTestCal1File,entryObj,uids) );
       
  1170         //modifiedEntryId = uids->iLocalUID;
       
  1171         delete uids;
       
  1172         entryArray.ResetAndDestroy();
       
  1173         if ( err == KErrNone )
       
  1174             { 
       
  1175                 
       
  1176                 getListfilter2->SetFilterTypeL( KIncludeAll );
       
  1177             
       
  1178                 service->GetListL( KTestCal1File, getListfilter2 , calInstanceArray );
       
  1179     
       
  1180                 TInt new_count = calInstanceArray.Count();
       
  1181                 if(new_count != count)
       
  1182                 {
       
  1183                     
       
  1184                     result = KErrGeneral;
       
  1185                 }
       
  1186                  calInstanceArray.ResetAndDestroy();
       
  1187                 delete getListfilter2;
       
  1188             }
       
  1189         else
       
  1190             {
       
  1191             result = KErrGeneral;       
       
  1192             }
       
  1193             
       
  1194         
       
  1195         entryArray.ResetAndDestroy();
       
  1196         arruids.ResetAndDestroy();
       
  1197         delete entryObj;
       
  1198         }
       
  1199         else
       
  1200             result = KErrGeneral;   
       
  1201 
       
  1202     RemoveCalendarFile( service, KTestCal1File );
       
  1203     
       
  1204     delete service;
       
  1205     
       
  1206     
       
  1207     __UHEAP_MARKEND;
       
  1208 
       
  1209     return result;
       
  1210 
       
  1211 
       
  1212     }