calendarui/controller/src/calenmultipledbui.cpp
branchRCL_3
changeset 60 96907930389d
parent 59 aba12c885d83
child 67 1539a383d7b6
equal deleted inserted replaced
59:aba12c885d83 60:96907930389d
    43 #include <calenmulticalutil.h>
    43 #include <calenmulticalutil.h>
    44 #include <calenmulticaluids.hrh>
    44 #include <calenmulticaluids.hrh>
    45 #include <featmgr.h>
    45 #include <featmgr.h>
    46 #include <hlplch.h>
    46 #include <hlplch.h>
    47 #include <csxhelp/cale.hlp.hrh>
    47 #include <csxhelp/cale.hlp.hrh>
       
    48 #include <calencontext.h>
       
    49 #include <calenservices.h>
    48 
    50 
    49 // User includes
    51 // User includes
    50 #include "calendarui_debug.h"
    52 #include "calendarui_debug.h"
    51 #include "calenmultipledbui.h"
    53 #include "calenmultipledbui.h"
    52 #include "calendar.hrh"
    54 #include "calendar.hrh"
   283     if(iCalendarInfoOriginal)
   285     if(iCalendarInfoOriginal)
   284         {
   286         {
   285         delete iCalendarInfoOriginal;
   287         delete iCalendarInfoOriginal;
   286         iCalendarInfoOriginal = NULL;
   288         iCalendarInfoOriginal = NULL;
   287         }
   289         }
   288 
   290 if(iCalEditedDefaultName)
       
   291         {
       
   292         delete iCalEditedDefaultName;
       
   293         iCalEditedDefaultName = NULL;
       
   294         }
   289     TRACE_EXIT_POINT;
   295     TRACE_EXIT_POINT;
   290     }
   296     }
   291 
   297 
   292 // ----------------------------------------------------------------------------
   298 // ----------------------------------------------------------------------------
   293 // CCalenMultipleDbUi::FocusChanged
   299 // CCalenMultipleDbUi::FocusChanged
   685     {
   691     {
   686     TRACE_ENTRY_POINT
   692     TRACE_ENTRY_POINT
   687 	TInt retError = KErrNone;
   693 	TInt retError = KErrNone;
   688     
   694     
   689 	iDbEditor = NULL;
   695 	iDbEditor = NULL;
       
   696 	if(iCalEditedDefaultName)
       
   697 	    {
       
   698         delete iCalEditedDefaultName;
       
   699         iCalEditedDefaultName = NULL;
       
   700 	    }
   690     
   701     
   691     if(aItemAdded)
   702     if(aItemAdded)
   692         {
   703         {
   693         TRAP(retError,
   704         TRAP(retError,
   694         // Set calendar properties for new calendar being created.
   705         // Set calendar properties for new calendar being created.
   762     iController.GetAllCalendarInfoL(calendarInfoList);
   773     iController.GetAllCalendarInfoL(calendarInfoList);
   763     CleanupClosePushL(calendarInfoList);
   774     CleanupClosePushL(calendarInfoList);
   764     
   775     
   765     iCalendarInfoEdited = calendarInfoList[currentIndex];
   776     iCalendarInfoEdited = calendarInfoList[currentIndex];
   766     
   777     
       
   778     iCalEditedDefaultName = calendarInfoList[currentIndex]->FileNameL().AllocL();
   767     CleanupStack::PopAndDestroy(&calendarInfoList);
   779     CleanupStack::PopAndDestroy(&calendarInfoList);
   768     
   780     
   769     //Take a copy of original before editing
   781     //Take a copy of original before editing
   770     if(iCalendarInfoOriginal)
   782     if(iCalendarInfoOriginal)
   771         {
   783         {
  1412     switch (aNotification)
  1424     switch (aNotification)
  1413         {
  1425         {
  1414         case ECalenNotifyCalendarInfoCreated:
  1426         case ECalenNotifyCalendarInfoCreated:
  1415         case ECalenNotifyCalendarInfoUpdated:
  1427         case ECalenNotifyCalendarInfoUpdated:
  1416             {
  1428             {
  1417             if (iDbEditor)
  1429             MCalenContext& context = iController.Services().Context();
       
  1430             TDesC& aConflictCalendarName  = context.GetCalendarFileNameL();
       
  1431             TBool isSameFileEdited = EFalse;
       
  1432             if(iCalEditedDefaultName)
       
  1433                 {
       
  1434                 if(!iCalEditedDefaultName->CompareF(aConflictCalendarName))
       
  1435                     {
       
  1436                     isSameFileEdited = ETrue; 
       
  1437                     }
       
  1438                 else
       
  1439                     {
       
  1440                     isSameFileEdited = EFalse;
       
  1441                     }
       
  1442                 }
       
  1443             
       
  1444             if (iDbEditor && isSameFileEdited)
  1418                 {
  1445                 {
  1419                 iConflictOccured = ETrue;
  1446                 iConflictOccured = ETrue;
  1420                 iDbEditor->SetConflict(CCalenMultiDBEditor::EConflictUpdate);
  1447                 iDbEditor->SetConflict(CCalenMultiDBEditor::EConflictUpdate);
  1421                 }
  1448                 }
  1422             }
  1449             }
  1423             break;
  1450             break;
  1424         case ECalenNotifyCalendarFileDeleted:
  1451         case ECalenNotifyCalendarFileDeleted:
  1425             {
  1452             {
  1426             if (iDbEditor)
  1453             RPointerArray<CCalCalendarInfo> calendarInfoList;
       
  1454             TBool isSameFileDeleted = EFalse;
       
  1455             iController.GetAllCalendarInfoL(calendarInfoList);
       
  1456             CleanupClosePushL(calendarInfoList);
       
  1457             if(iCalEditedDefaultName)
       
  1458                 {
       
  1459                 for(TInt i=0; i<calendarInfoList.Count(); i++)
       
  1460                     {
       
  1461                     if(!iCalEditedDefaultName->CompareF(calendarInfoList[i]->FileNameL()))
       
  1462                         {
       
  1463                         isSameFileDeleted = EFalse;
       
  1464                         break;
       
  1465                         }
       
  1466                     else
       
  1467                         {
       
  1468                         isSameFileDeleted = ETrue;
       
  1469                         }
       
  1470                     }
       
  1471                 }
       
  1472             CleanupStack::PopAndDestroy(&calendarInfoList);
       
  1473             
       
  1474             if (iDbEditor && isSameFileDeleted)
  1427                 {
  1475                 {
  1428                 iConflictOccured = ETrue;
  1476                 iConflictOccured = ETrue;
  1429                 iDbEditor->SetConflict(CCalenMultiDBEditor::EConflictDelete);
  1477                 iDbEditor->SetConflict(CCalenMultiDBEditor::EConflictDelete);
  1430                 }
  1478                 }
  1431             }
  1479             }
  1433         default:
  1481         default:
  1434             break;
  1482             break;
  1435         }
  1483         }
  1436 
  1484 
  1437     // refresh calendar list
  1485     // refresh calendar list
  1438     UpdateListboxL();
  1486     TRAP_IGNORE(UpdateListboxL());
  1439 
  1487 
  1440     TRACE_EXIT_POINT;
  1488     TRACE_EXIT_POINT;
  1441     }
  1489     }
  1442 
  1490 
  1443 
  1491