syncmlfw/ds/hostserver/dshostserverbase/src/Nsmldshostsession.cpp
branchRCL_3
changeset 14 9e9792ae22e3
parent 0 b497e44ab2fc
child 19 86979fe66c4c
equal deleted inserted replaced
13:06f47423ecee 14:9e9792ae22e3
    28 #include <SmlDataFormat.h>
    28 #include <SmlDataFormat.h>
    29 
    29 
    30 #include "NSmlAdapterLog.h"
    30 #include "NSmlAdapterLog.h"
    31 #include "nsmldshostconstants.h"
    31 #include "nsmldshostconstants.h"
    32 #include "Nsmldshostserver.h"
    32 #include "Nsmldshostserver.h"
       
    33 #include "nsmldshostsessioncanceleventhandler.h"
       
    34 #include "Nsmldshostsessioncancel.h"
    33 #include "Nsmldshostsession.h"
    35 #include "Nsmldshostsession.h"
    34 #include "nsmldsdpinformation.h"
    36 #include "nsmldsdpinformation.h"
    35 #include "Nsmldsdataproviderarray.h"
    37 #include "Nsmldsdataproviderarray.h"
    36 
    38 
    37 #ifdef __HOST_SERVER_MTEST__
    39 #ifdef __HOST_SERVER_MTEST__
   172 	{
   174 	{
   173 	_DBG_FILE( "CNSmlDSHostSession::~CNSmlDSHostSession(): begin" );
   175 	_DBG_FILE( "CNSmlDSHostSession::~CNSmlDSHostSession(): begin" );
   174     iMemPtr.iChunk.Close();
   176     iMemPtr.iChunk.Close();
   175     iDataProviders.ResetAndDestroy();
   177     iDataProviders.ResetAndDestroy();
   176     iStringPool.Close();
   178     iStringPool.Close();
       
   179     if(iDsoDeleteAll)
       
   180       {
       
   181       delete iDsoDeleteAll;
       
   182       iDsoDeleteAll = NULL;
       
   183       }   
       
   184     if(iCancelEventHandler)
       
   185         {
       
   186         delete iCancelEventHandler;
       
   187         iCancelEventHandler = NULL;
       
   188         }
   177     REComSession::FinalClose();
   189     REComSession::FinalClose();
   178     iServer.DecSessionCount();
   190     iServer.DecSessionCount();
   179 	_DBG_FILE( "CNSmlDSHostSession::~CNSmlDSHostSession(): end" );
   191 	_DBG_FILE( "CNSmlDSHostSession::~CNSmlDSHostSession(): end" );
   180 	}
   192 	}
   181 
   193 
   408 // ------------------------------------------------------------------------------------------------
   420 // ------------------------------------------------------------------------------------------------
   409 void CNSmlDSHostSession::ConstructL()
   421 void CNSmlDSHostSession::ConstructL()
   410 	{
   422 	{
   411 	_DBG_FILE( "CNSmlDSHostSession::ConstructL(): begin" );
   423 	_DBG_FILE( "CNSmlDSHostSession::ConstructL(): begin" );
   412     iStringPool.OpenL();
   424     iStringPool.OpenL();
       
   425 	iDsoDeleteAll = NULL;
       
   426 	iCancelEventHandler = NULL;
   413 	_DBG_FILE( "CNSmlDSHostSession::ConstructL(): end" );
   427 	_DBG_FILE( "CNSmlDSHostSession::ConstructL(): end" );
   414 	}
   428 	}
   415 	
   429 	
   416 
   430 
   417 // ------------------------------------------------------------------------------------------------
   431 // ------------------------------------------------------------------------------------------------
  1484 // CNSmlDSHostSession::DeleteAllItemsL
  1498 // CNSmlDSHostSession::DeleteAllItemsL
  1485 // Deletes all items at Data Store permanently.
  1499 // Deletes all items at Data Store permanently.
  1486 // ------------------------------------------------------------------------------------------------	
  1500 // ------------------------------------------------------------------------------------------------	
  1487 void CNSmlDSHostSession::DeleteAllItemsL( const RMessage2& aMessage )
  1501 void CNSmlDSHostSession::DeleteAllItemsL( const RMessage2& aMessage )
  1488 	{
  1502 	{
       
  1503     //Create cancel event handler
       
  1504     iCancelEventHandler = CNSmlHostSessionCancel::NewL(this);
  1489     TNSmlDSDataStoreElement* dsi = DataStoreItemL( aMessage );
  1505     TNSmlDSDataStoreElement* dsi = DataStoreItemL( aMessage );
  1490     CNSmlDSAsyncCallBack* dsao = new ( ELeave ) CNSmlDSAsyncCallBack( this, dsi, aMessage );
  1506     CNSmlDSAsyncCallBack* dsao = new ( ELeave ) CNSmlDSAsyncCallBack( this, dsi, aMessage, DeleteAllFinishedL );
  1491     CleanupStack::PushL( dsao );
  1507     CleanupStack::PushL( dsao );
  1492     dsao->CallDSAsyncLC().DeleteAllItemsL( dsao->iStatus );
  1508     dsao->CallDSAsyncLC().DeleteAllItemsL( dsao->iStatus );   
  1493     CleanupStack::Pop(2); //CallDSAsyncLC(), dsao
  1509     CleanupStack::Pop(2); //CallDSAsyncLC(), dsao
       
  1510     iDsoDeleteAll = dsao;
  1494 	}
  1511 	}
  1495 
  1512 
  1496 // ------------------------------------------------------------------------------------------------
  1513 // ------------------------------------------------------------------------------------------------
  1497 // CNSmlDSHostSession::HasSyncHistoryL
  1514 // CNSmlDSHostSession::HasSyncHistoryL
  1498 // Checks if the Data Store has sync history. If not then slow sync is proposed to Sync Partner.
  1515 // Checks if the Data Store has sync history. If not then slow sync is proposed to Sync Partner.
  1889 	wStream.WriteL( *aSb->iRead );
  1906 	wStream.WriteL( *aSb->iRead );
  1890 	wStream.CommitL();
  1907 	wStream.CommitL();
  1891 	CleanupStack::PopAndDestroy(); //wStream
  1908 	CleanupStack::PopAndDestroy(); //wStream
  1892 	}
  1909 	}
  1893 
  1910 
       
  1911 // ------------------------------------------------------------------------------------------------
       
  1912 // CNSmlDSHostSession::HandleCancelEventL
       
  1913 // called when user canceled the operation
       
  1914 // ------------------------------------------------------------------------------------------------ 
       
  1915 void CNSmlDSHostSession::HandleCancelEventL()
       
  1916     {
       
  1917     if(iCancelEventHandler)
       
  1918         {
       
  1919         iDsoDeleteAll->Cancel();
       
  1920         }
       
  1921     }
       
  1922 
       
  1923 // ------------------------------------------------------------------------------------------------
       
  1924 // CNSmlDSHostSession::DeleteAllFinishedL
       
  1925 // called when DeleteAll request is finished.
       
  1926 // Note! when aOperation is CNSmlDSAsyncCallBack::ECanceled or CNSmlDSAsyncCallBack::EFree, 
       
  1927 // aDSAO->iDSItem might be NULL.
       
  1928 // ------------------------------------------------------------------------------------------------ 
       
  1929 TInt CNSmlDSHostSession::DeleteAllFinishedL( CNSmlDSAsyncCallBack* aDSAO, TCallBackOperation aOperation )
       
  1930     {
       
  1931     TInt err( aDSAO->iStatus.Int() );
       
  1932 
       
  1933     switch( aOperation )
       
  1934         {
       
  1935         case CNSmlDSAsyncCallBack::EFinished:
       
  1936         case CNSmlDSAsyncCallBack::ECanceled:
       
  1937         case CNSmlDSAsyncCallBack::EFree:
       
  1938             {
       
  1939             if(iCancelEventHandler)
       
  1940                 {
       
  1941                 delete iCancelEventHandler;
       
  1942                 iCancelEventHandler = NULL;
       
  1943                 iDsoDeleteAll = NULL;
       
  1944                 }
       
  1945             break;
       
  1946             }
       
  1947         default:
       
  1948             User::Leave( KErrUnknown );
       
  1949         };
       
  1950 
       
  1951     return err;
       
  1952     }
  1894 // End of File
  1953 // End of File