38 #include <centralrepository.h> //CRepository |
38 #include <centralrepository.h> //CRepository |
39 #include <calenmulticaluids.hrh> // Calendar File Meta Data Properties |
39 #include <calenmulticaluids.hrh> // Calendar File Meta Data Properties |
40 #include <calenmulticalutil.h> |
40 #include <calenmulticalutil.h> |
41 #include <CalenInterimUtils2.h> |
41 #include <CalenInterimUtils2.h> |
42 |
42 |
43 _LIT(KDrive ,"C:"); |
|
44 _LIT(KCharUnderscore, "_"); |
43 _LIT(KCharUnderscore, "_"); |
|
44 _LIT( KNSmlAgendaFileNameForDefaultDB, "c:calendar" ); |
45 |
45 |
46 /******************************************************************************* |
46 /******************************************************************************* |
47 * class TAspProviderItem |
47 * class TAspProviderItem |
48 *******************************************************************************/ |
48 *******************************************************************************/ |
49 |
49 |
896 return EMandatoryNoRemoteDatabase; |
896 return EMandatoryNoRemoteDatabase; |
897 } |
897 } |
898 |
898 |
899 if (task.iDataProviderId == KUidNSmlAdapterCalendar.iUid) |
899 if (task.iDataProviderId == KUidNSmlAdapterCalendar.iUid) |
900 { |
900 { |
901 CCalSession* session = CCalSession::NewL(); |
901 TBool status = EFalse; |
902 CleanupStack::PushL(session); |
902 status = IsValidClientDataSourceL( task.iClientDataSource ); |
903 TRAPD (err, session->OpenL(task.iClientDataSource)); |
903 if ( !status ) |
904 if (err == KErrNotFound) |
|
905 { |
904 { |
906 TInt index = FindProviderIndex(task.iDataProviderId); |
905 TInt index = FindProviderIndex(task.iDataProviderId); |
907 TAspProviderItem& provider = ProviderItem(index); |
906 TAspProviderItem& provider = ProviderItem(index); |
908 |
907 |
909 TBuf<KBufSize> localDatabase; |
908 TBuf<KBufSize> localDatabase; |
1240 CleanupClosePushL(task); |
1239 CleanupClosePushL(task); |
1241 |
1240 |
1242 if (aDataProvider.iDataProviderId == KUidNSmlAdapterCalendar.iUid ) |
1241 if (aDataProvider.iDataProviderId == KUidNSmlAdapterCalendar.iUid ) |
1243 { |
1242 { |
1244 TBuf<128> calLocalDb ; |
1243 TBuf<128> calLocalDb ; |
1245 CreateCalLocalDatabaseL(calLocalDb); |
1244 CreateCalLocalDatabaseL(calLocalDb); |
1246 task.CreateL(iProfile->Profile(), aDataProvider.iDataProviderId, |
1245 task.CreateL(iProfile->Profile(), aDataProvider.iDataProviderId, |
1247 KNullDesC, calLocalDb); |
1246 KNullDesC, calLocalDb); |
1248 } |
1247 } |
1249 else |
1248 else |
1250 { |
1249 { |
1315 TBuf<KBufSize> calLocalDb ; |
1314 TBuf<KBufSize> calLocalDb ; |
1316 TRAPD(err ,RetrieveCalLocalDatabaseL(calLocalDb)); |
1315 TRAPD(err ,RetrieveCalLocalDatabaseL(calLocalDb)); |
1317 if (err != KErrNone) |
1316 if (err != KErrNone) |
1318 { |
1317 { |
1319 CreateCalLocalDatabaseL(calLocalDb); |
1318 CreateCalLocalDatabaseL(calLocalDb); |
1320 } |
1319 } |
1321 |
|
1322 task.CreateL(iProfile->Profile(), aDataProviderId, |
1320 task.CreateL(iProfile->Profile(), aDataProviderId, |
1323 aRemoteDatabase, calLocalDb); |
1321 aRemoteDatabase, calLocalDb); |
1324 } |
1322 } |
1325 else |
1323 else |
1326 { |
1324 { |
1336 TBuf<128> calLocalDb ; |
1334 TBuf<128> calLocalDb ; |
1337 TRAPD(err ,RetrieveCalLocalDatabaseL(calLocalDb)); |
1335 TRAPD(err ,RetrieveCalLocalDatabaseL(calLocalDb)); |
1338 if (err != KErrNone) |
1336 if (err != KErrNone) |
1339 { |
1337 { |
1340 CreateCalLocalDatabaseL(calLocalDb); |
1338 CreateCalLocalDatabaseL(calLocalDb); |
1341 } |
1339 } |
1342 |
|
1343 task.CreateL(iProfile->Profile(), aDataProviderId, |
1340 task.CreateL(iProfile->Profile(), aDataProviderId, |
1344 aRemoteDatabase, calLocalDb); |
1341 aRemoteDatabase, calLocalDb); |
1345 } |
1342 } |
1346 else |
1343 else |
1347 { |
1344 { |
1388 // |
1385 // |
1389 // ----------------------------------------------------------------------------- |
1386 // ----------------------------------------------------------------------------- |
1390 // |
1387 // |
1391 void CAspContentList::CreateCalLocalDatabaseL(TDes& aCalName) |
1388 void CAspContentList::CreateCalLocalDatabaseL(TDes& aCalName) |
1392 { |
1389 { |
1393 |
1390 |
1394 aCalName.Copy(KDrive); |
|
1395 |
1391 |
1396 TBuf<KBufSize> buffer; |
1392 TBuf<KBufSize> buffer; |
1397 iProfile->GetName(buffer); |
1393 iProfile->GetName(buffer); |
1398 |
1394 |
1399 TInt currentProfileId = iProfile->ProfileId(); |
1395 TInt currentProfileId = iProfile->ProfileId(); |
1508 calinfo->SetPropertyL( keyBuff, pckgSyncLockValue ); |
1504 calinfo->SetPropertyL( keyBuff, pckgSyncLockValue ); |
1509 |
1505 |
1510 // Create the CalFile |
1506 // Create the CalFile |
1511 HBufC* calfilename = CCalenMultiCalUtil::GetNextAvailableCalFileL(); |
1507 HBufC* calfilename = CCalenMultiCalUtil::GetNextAvailableCalFileL(); |
1512 calSession->CreateCalFileL( calfilename->Des(), *calinfo ); |
1508 calSession->CreateCalFileL( calfilename->Des(), *calinfo ); |
1513 |
1509 |
1514 aCalName.Copy( calfilename->Des() ); |
1510 aCalName.Copy(KNSmlAgendaFileNameForDefaultDB); |
1515 |
1511 |
1516 delete calfilename; |
1512 delete calfilename; |
1517 |
1513 |
1518 CleanupStack::PopAndDestroy(calinfo); |
1514 CleanupStack::PopAndDestroy(calinfo); |
1519 CleanupStack::PopAndDestroy(calSession); |
1515 CleanupStack::PopAndDestroy(calSession); |
1578 CleanupStack::PushL(vCalSubSession); |
1574 CleanupStack::PushL(vCalSubSession); |
1579 vCalSubSession->OpenL(calfilearr->MdcaPoint(i)); |
1575 vCalSubSession->OpenL(calfilearr->MdcaPoint(i)); |
1580 |
1576 |
1581 CCalCalendarInfo* caleninfo = vCalSubSession->CalendarInfoL(); |
1577 CCalCalendarInfo* caleninfo = vCalSubSession->CalendarInfoL(); |
1582 CleanupStack::PushL(caleninfo); |
1578 CleanupStack::PushL(caleninfo); |
|
1579 |
|
1580 //Get MARKASDELETE MetaData property |
|
1581 keyBuff.Zero(); |
|
1582 TBool markAsdelete = EFalse; |
|
1583 keyBuff.AppendNum( EMarkAsDelete ); |
|
1584 TPckgC<TBool> pckMarkAsDelete(markAsdelete); |
|
1585 TRAPD(err,pckMarkAsDelete.Set(caleninfo->PropertyValueL(keyBuff))); |
|
1586 if ( err == KErrNone ) |
|
1587 { |
|
1588 markAsdelete = pckMarkAsDelete(); |
|
1589 if( markAsdelete ) |
|
1590 { |
|
1591 CleanupStack::PopAndDestroy(caleninfo); |
|
1592 CleanupStack::PopAndDestroy(vCalSubSession); |
|
1593 continue; |
|
1594 } |
|
1595 } |
1583 |
1596 |
1584 TInt profileId; |
1597 TInt profileId; |
1585 keyBuff.Zero(); |
1598 keyBuff.Zero(); |
1586 keyBuff.AppendNum( EDeviceSyncProfileID ); |
1599 keyBuff.AppendNum( EDeviceSyncProfileID ); |
1587 TPckgC<TInt> intBuf(profileId); |
1600 TPckgC<TInt> intBuf(profileId); |
1618 User::Leave( KErrNotFound ); |
1631 User::Leave( KErrNotFound ); |
1619 } |
1632 } |
1620 |
1633 |
1621 delete calfilearr; |
1634 delete calfilearr; |
1622 CleanupStack::PopAndDestroy(vCalSession); |
1635 CleanupStack::PopAndDestroy(vCalSession); |
|
1636 } |
|
1637 |
|
1638 // ----------------------------------------------------------------------------- |
|
1639 // CAspContentList::IsValidClientDataSource |
|
1640 // |
|
1641 // ----------------------------------------------------------------------------- |
|
1642 // |
|
1643 TBool CAspContentList::IsValidClientDataSourceL( TDes& aCalName ) |
|
1644 { |
|
1645 TBool datasourcefound = ETrue; |
|
1646 TBuf8<KBufSize> keyBuff; |
|
1647 CCalCalendarInfo* caleninfo = NULL; |
|
1648 CCalSession* session = CCalSession::NewL(); |
|
1649 CleanupStack::PushL(session); |
|
1650 TRAPD (err, session->OpenL(aCalName)); |
|
1651 |
|
1652 if( err == KErrNotFound ) |
|
1653 { |
|
1654 datasourcefound = EFalse; |
|
1655 } |
|
1656 else |
|
1657 { |
|
1658 caleninfo = session->CalendarInfoL(); |
|
1659 CleanupStack::PushL(caleninfo); |
|
1660 |
|
1661 //Get MARKASDELETE MetaData property |
|
1662 keyBuff.Zero(); |
|
1663 TBool markAsdelete = EFalse; |
|
1664 keyBuff.AppendNum( EMarkAsDelete ); |
|
1665 TPckgC<TBool> pckMarkAsDelete(markAsdelete); |
|
1666 TRAP(err,pckMarkAsDelete.Set(caleninfo->PropertyValueL(keyBuff))); |
|
1667 if ( err == KErrNone ) |
|
1668 { |
|
1669 markAsdelete = pckMarkAsDelete(); |
|
1670 if( markAsdelete ) |
|
1671 { |
|
1672 datasourcefound = EFalse; |
|
1673 } |
|
1674 } |
|
1675 CleanupStack::PopAndDestroy(caleninfo); |
|
1676 } |
|
1677 CleanupStack::PopAndDestroy(session); |
|
1678 return datasourcefound; |
1623 } |
1679 } |
1624 |
1680 |
1625 // ----------------------------------------------------------------------------- |
1681 // ----------------------------------------------------------------------------- |
1626 // CAspContentList::ReadTaskL |
1682 // CAspContentList::ReadTaskL |
1627 // |
1683 // |