omads/omadsappui/AspSyncUtil/src/AspProfile.cpp
changeset 4 e6e896426eac
parent 2 19dc812fb587
child 8 ad0f53516d84
equal deleted inserted replaced
3:c2b8a5ae6ed5 4:e6e896426eac
  1256 			}
  1256 			}
  1257 		else
  1257 		else
  1258 			{
  1258 			{
  1259 			if (aDataProviderId == KUidNSmlAdapterCalendar.iUid )
  1259 			if (aDataProviderId == KUidNSmlAdapterCalendar.iUid )
  1260                 {
  1260                 {
  1261                 TBuf<128> calLocalDb ;
  1261                 TBuf<KBufSize> calLocalDb ;
  1262                 CreateCalLocalDatabaseL(calLocalDb);
  1262 				TRAPD(err ,RetrieveCalLocalDatabaseL(calLocalDb));
       
  1263 				if (err != KErrNone)
       
  1264 					{
       
  1265 					CreateCalLocalDatabaseL(calLocalDb);
       
  1266 					}				
       
  1267                 
  1263                 task.CreateL(iProfile->Profile(), aDataProviderId, 
  1268                 task.CreateL(iProfile->Profile(), aDataProviderId, 
  1264                                               aRemoteDatabase, calLocalDb);
  1269                                               aRemoteDatabase, calLocalDb);
  1265                 }
  1270                 }
  1266             else
  1271             else
  1267                 {
  1272                 {
  1332 void CAspContentList::CreateCalLocalDatabaseL(TDes& aCalName)
  1337 void CAspContentList::CreateCalLocalDatabaseL(TDes& aCalName)
  1333     {
  1338     {
  1334             
  1339             
  1335     aCalName.Copy(KDrive);
  1340     aCalName.Copy(KDrive);
  1336     
  1341     
  1337     TBuf<128> buffer;
  1342     TBuf<KBufSize> buffer;
  1338     iProfile->GetName(buffer);
  1343     iProfile->GetName(buffer);
  1339      
  1344 	
       
  1345 	TInt currentProfileId = iProfile->ProfileId();
       
  1346 	
       
  1347 	if (buffer.Compare(KAutoSyncProfileName) == 0)
       
  1348 		{
       
  1349 		CAspSchedule* schedule = CAspSchedule::NewLC();
       
  1350 		currentProfileId = schedule->ProfileId();
       
  1351 		TAspParam param(iApplicationId, iSyncSession);
       
  1352 		CAspProfile* selectedProfile = CAspProfile::NewLC(param);
       
  1353 		selectedProfile->OpenL(currentProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
       
  1354 		selectedProfile->GetName(buffer);
       
  1355 		CleanupStack::PopAndDestroy(selectedProfile);
       
  1356 		CleanupStack::PopAndDestroy(schedule);
       
  1357 		}
       
  1358 		
  1340     CCalSession* calSession = CCalSession::NewL();
  1359     CCalSession* calSession = CCalSession::NewL();
  1341     CleanupStack::PushL(calSession);
  1360     CleanupStack::PushL(calSession);
  1342     
  1361     
  1343         
  1362         
  1344     TInt suffix = 0;
  1363     TInt suffix = 0;
  1422     calinfo->SetPropertyL( keyBuff, pckgAppUIDValue );
  1441     calinfo->SetPropertyL( keyBuff, pckgAppUIDValue );
  1423 
  1442 
  1424 
  1443 
  1425     keyBuff.Zero();
  1444     keyBuff.Zero();
  1426     keyBuff.AppendNum( EDeviceSyncProfileID );
  1445     keyBuff.AppendNum( EDeviceSyncProfileID );
  1427     TPckgC<TInt> pckgProfileIdValue( iProfile->ProfileId() );    
  1446     TPckgC<TInt> pckgProfileIdValue( currentProfileId );    
  1428     calinfo->SetPropertyL( keyBuff, pckgProfileIdValue );
  1447     calinfo->SetPropertyL( keyBuff, pckgProfileIdValue );
  1429 
  1448 
  1430     
  1449     
  1431     // Create the CalFile
  1450     // Create the CalFile
  1432     HBufC* calfilename = CCalenMultiCalUtil::GetNextAvailableCalFileL();
  1451     HBufC* calfilename = CCalenMultiCalUtil::GetNextAvailableCalFileL();
  1505         TInt profileId;
  1524         TInt profileId;
  1506         keyBuff.Zero();
  1525         keyBuff.Zero();
  1507         keyBuff.AppendNum( EDeviceSyncProfileID );
  1526         keyBuff.AppendNum( EDeviceSyncProfileID );
  1508         TPckgC<TInt> intBuf(profileId);
  1527         TPckgC<TInt> intBuf(profileId);
  1509         TRAP_IGNORE(intBuf.Set(caleninfo->PropertyValueL(keyBuff)));
  1528         TRAP_IGNORE(intBuf.Set(caleninfo->PropertyValueL(keyBuff)));
  1510                 
       
  1511         profileId = intBuf();
  1529         profileId = intBuf();
  1512         
  1530 		
  1513         if ( profileId == iProfile->ProfileId())
  1531         TBuf<KBufSize> buffer;
       
  1532 		iProfile->GetName(buffer);
       
  1533 		
       
  1534 		TInt currentProfileId = iProfile->ProfileId();
       
  1535 	
       
  1536 		if (buffer.Compare(KAutoSyncProfileName) == 0)
       
  1537 			{
       
  1538 			CAspSchedule* schedule = CAspSchedule::NewLC();
       
  1539 			currentProfileId = schedule->ProfileId();
       
  1540 			CleanupStack::PopAndDestroy(schedule);		
       
  1541 			}
       
  1542 		
       
  1543         if ( profileId == currentProfileId)
  1514             {
  1544             {
  1515             aCalName.Append(caleninfo->FileNameL());
  1545             aCalName.Append(caleninfo->FileNameL());
  1516             dbFound = ETrue;
  1546             dbFound = ETrue;
  1517             CleanupStack::PopAndDestroy(caleninfo);   
  1547             CleanupStack::PopAndDestroy(caleninfo);   
  1518             CleanupStack::PopAndDestroy(vCalSubSession);
  1548             CleanupStack::PopAndDestroy(vCalSubSession);
  2253     Session().ListProfilesL(arr, ESmlDataSync);
  2283     Session().ListProfilesL(arr, ESmlDataSync);
  2254    	CleanupClosePushL(arr);
  2284    	CleanupClosePushL(arr);
  2255 
  2285 
  2256 	TInt count = arr.Count();
  2286 	TInt count = arr.Count();
  2257 
  2287 
       
  2288 	//Hiding OVI Sync profile
       
  2289 	const TUid KUidOtaSyncCenRep                = { 0x20016C06 };
       
  2290 	const TUid KCRUidOtaSyncProfileId           = { 0x102 };
       
  2291 	TInt oviProfileId = KErrNotFound;
       
  2292 	CRepository* centRep = NULL;
       
  2293 
       
  2294 	TRAPD(err ,centRep = CRepository::NewL(KUidOtaSyncCenRep));
       
  2295 	if (err == KErrNone)
       
  2296 		{
       
  2297 		CleanupStack::PushL(centRep);
       
  2298 		centRep->Get(KCRUidOtaSyncProfileId.iUid, oviProfileId);
       
  2299     	CleanupStack::PopAndDestroy();// centRep
       
  2300 		}
  2258 	for (TInt i=0; i<count; i++)
  2301 	for (TInt i=0; i<count; i++)
  2259 		{
  2302 		{
  2260 		TAspParam param(iApplicationId, iSyncSession);
  2303 		TAspParam param(iApplicationId, iSyncSession);
  2261 		CAspProfile* profile = CAspProfile::NewLC(param);
  2304 		CAspProfile* profile = CAspProfile::NewLC(param);
  2262 		TInt id = arr[i];
  2305 		TInt id = arr[i];
  2263 		
  2306 		
       
  2307 		//Hiding OVI Sync profile
       
  2308 		if (id == oviProfileId)
       
  2309 			{
       
  2310 			CleanupStack::PopAndDestroy(profile);
       
  2311 			continue;
       
  2312 		    }
  2264 		if (aListMode == EBasePropertiesOnly)
  2313 		if (aListMode == EBasePropertiesOnly)
  2265 			{
  2314 			{
  2266 			profile->OpenL(id, CAspProfile::EOpenRead, CAspProfile::EBaseProperties);
  2315 			profile->OpenL(id, CAspProfile::EOpenRead, CAspProfile::EBaseProperties);
  2267 			}
  2316 			}
  2268 		else
  2317 		else