simpledatamodeladapter/src/presencepluginpublisher.cpp
changeset 12 e6a66db4e9d0
parent 0 c8caa15ef882
equal deleted inserted replaced
0:c8caa15ef882 12:e6a66db4e9d0
   354             {
   354             {
   355             DP_SDA("CPresencePluginPublisher::PublishReqCompleteL Save ETAG");
   355             DP_SDA("CPresencePluginPublisher::PublishReqCompleteL Save ETAG");
   356             TBuf8<KBufSize255> buf;
   356             TBuf8<KBufSize255> buf;
   357             buf.Copy( iPublisher->SIPETag() );
   357             buf.Copy( iPublisher->SIPETag() );
   358             iConnObs.SetETag( buf );
   358             iConnObs.SetETag( buf );
       
   359             iPresenceData->StoreDocumentIdL( iConnObs.ServiceId(), buf );
   359             }
   360             }
   360     	//Do not complete if error republish is true. XIMPFW is not knowing we 
   361     	//Do not complete if error republish is true. XIMPFW is not knowing we 
   361     	//are sending republish.
   362     	//are sending republish.
   362         if( EFalse == iRePublish && !aStatus )
   363         if( EFalse == iRePublish && !aStatus )
   363             {
   364             {
   372                 }
   373                 }
   373             //Complete stopPublish and close session if stopPublish is called
   374             //Complete stopPublish and close session if stopPublish is called
   374             if( iConnObs.IsStopPublishCalled() )
   375             if( iConnObs.IsStopPublishCalled() )
   375                 {
   376                 {
   376                 DP_SDA("PublishReqCompleteL complete closeSession"); 
   377                 DP_SDA("PublishReqCompleteL complete closeSession"); 
   377                 iPresenceData->DeletePresenceVariablesL( iConnObs.ServiceId() );
       
   378                 // successfull Online / others: store status to cache
   378                 // successfull Online / others: store status to cache
   379                 StoreOwnStatusToCacheL( );
   379                 StoreOwnStatusToCacheL( );
   380                 //Complete close session
   380                 //Complete close session
   381                 CompleteClientReq( aStatus );
   381                 CompleteClientReq( aStatus );
   382                 }
   382                 }
   386            DP_SDA("PublishReqCompleteL KSimpleErrTemporary"); 
   386            DP_SDA("PublishReqCompleteL KSimpleErrTemporary"); 
   387            // Make new publish request without ETag
   387            // Make new publish request without ETag
   388            CreatePublisherL();        
   388            CreatePublisherL();        
   389            iSimpleId = iPublisher->StartPublishL( *iDocument, ETrue );
   389            iSimpleId = iPublisher->StartPublishL( *iDocument, ETrue );
   390            }
   390            }
   391         else if( EFalse == iRePublish && ( KErrTimedOut == aStatus  ) )
   391         
   392             {
       
   393             DP_SDA("PublishReqCompleteL KErrTimedOut"); 
       
   394             iPublisher->StopPublishL();
       
   395             CompleteXIMPReq( KXIMPErrServicRequestTimeouted );
       
   396             }
       
   397         else
   392         else
   398         	{
   393         	{
   399         	//Set rePublish flag back to false.
   394         	//Set rePublish flag back to false.
   400         	iRePublish = EFalse;
   395         	iRePublish = EFalse;
   401         	}
   396         	}
   728     {
   723     {
   729     DP_SDA2("StopPublish - begin : iPublished= %d ",(TInt) iPublished);
   724     DP_SDA2("StopPublish - begin : iPublished= %d ",(TInt) iPublished);
   730     
   725     
   731     aStatus = KRequestPending;
   726     aStatus = KRequestPending;
   732     iClientStatus = &aStatus;
   727     iClientStatus = &aStatus;
   733     
   728     	
   734     TInt err1( 0 );
       
   735     TInt err2( 0 );
       
   736     
       
   737     // get stored document id if available
       
   738     HBufC8* oldDocumentId = HBufC8::NewLC( KBufSize255 );
       
   739     TPtr8 oldDocumentIdPtr( oldDocumentId->Des() );
       
   740     TRAP( err1, iPresenceData->ReadDocumentIdL( 
       
   741             iConnObs.ServiceId(), oldDocumentIdPtr ) );
       
   742     
       
   743     if ( iConnObs.GetStopPublishState() && iPublished )
   729     if ( iConnObs.GetStopPublishState() && iPublished )
   744         {
   730         {
   745         DP_SDA("CPresencePluginPublisher::StopPublish really Stop");
   731         DP_SDA("CPresencePluginPublisher::StopPublish really Stop");
   746         if ( !err1 )
   732         TRAPD( error, iPublisher->StopPublishL( iConnObs.GetETag() ););
   747             {
   733         DP_SDA2("StopPublish iPublisher->StopPublishL : error = %d ", error );
   748             TRAP( err2, iPublisher->StopPublishL( oldDocumentIdPtr ) );
   734         if ( KErrNone != error )
   749             }
       
   750         else 
       
   751             {
       
   752             // if stored document id is not available try with this
       
   753             TRAP( err2, iPublisher->StopPublishL( iConnObs.GetETag() ) );
       
   754             }
       
   755         DP_SDA2("StopPublish iPublisher->StopPublishL : error = %d ", err2 );
       
   756         if ( KErrNone != err2 )
       
   757             {            
   735             {            
   758             if( iPublisher )
   736             if( iPublisher )
   759                 {
   737                 {
   760                 DP_SDA("StopPublish delete and recreate publisher");
   738                 DP_SDA("StopPublish delete and recreate publisher");
   761                 iPublisher->Close();
   739                 iPublisher->Close();
   762                 iPublisher = NULL;
   740                 iPublisher = NULL;
   763                 DP_SDA("StopPublish really Stop try again 1 ");
   741                 DP_SDA("StopPublish really Stop try again 1 ");
   764                 iPublisher =
   742                 iPublisher =
   765                 	TSimpleFactory::NewPublisherL( iConnection, *this ); 
   743                 	TSimpleFactory::NewPublisherL( iConnection, *this ); 
   766                 DP_SDA("StopPublish really Stop try again 2 ");
   744                 DP_SDA("StopPublish really Stop try again 2 ");
   767                 err2 = KErrGeneral;
   745                 error = KErrGeneral;
   768                 TRAP( err2, iPublisher->StopPublishL( iConnObs.GetETag() ););
   746                 TRAP( error, iPublisher->StopPublishL( iConnObs.GetETag() ););
   769                 DP_SDA2("StopPublishL 2nd try : error = %d ", err2 );
   747                 DP_SDA2("StopPublishL 2nd try : error = %d ", error );
   770                 if ( KErrNone != err2 )
   748                 if ( KErrNone != error )
   771                     {
   749                     {
   772                     DP_SDA("StopPublish TWO TIME Error, last try without tag ");
   750                     DP_SDA("StopPublish TWO TIME Error, last try without tag ");
   773                     TRAP( err2, iPublisher->StopPublishL(); );
   751                     TRAP( error, iPublisher->StopPublishL(); );
   774                     DP_SDA2("StopPublishL 3rd try : error = %d ", err2 );
   752                     DP_SDA2("StopPublishL 3rd try : error = %d ", error );
   775                     }
   753                     }
   776                 }
   754                 }
   777             }
   755             }
   778         iConnObs.SetStopPublishState( ETrue );
   756         iConnObs.SetStopPublishState( ETrue );
   779         iPublished = EFalse;
   757         iPublished = EFalse;
   780         }
   758         }
   781     CleanupStack::PopAndDestroy( oldDocumentId );
       
   782     
       
   783     DP_SDA("CPresencePluginPublisher::StopPublish- end");        
   759     DP_SDA("CPresencePluginPublisher::StopPublish- end");        
   784     }
   760     }
   785     
   761     
   786 // ---------------------------------------------------------------------------
   762 // ---------------------------------------------------------------------------
   787 // CPresencePluginPublisher::Published()
       
   788 // ---------------------------------------------------------------------------
       
   789 //
       
   790 TBool CPresencePluginPublisher::Published()
       
   791     {
       
   792     return iPublished;
       
   793     }
       
   794 
       
   795 // ---------------------------------------------------------------------------
       
   796 // CPresencePluginPublisher::MakePublishReqL()
   763 // CPresencePluginPublisher::MakePublishReqL()
   797 // ---------------------------------------------------------------------------
   764 // ---------------------------------------------------------------------------
   798 //
   765 //
   799 void CPresencePluginPublisher::MakePublishReqL( )
   766 void CPresencePluginPublisher::MakePublishReqL( )
   800     {
   767     {
   801     DP_SDA("CPresencePluginPublisher::MakePublishReqL");
   768     DP_SDA("CPresencePluginPublisher::MakePublishReqL");
   802     
   769     
       
   770     if ( !iPublished )
       
   771         {
       
   772         DP_SDA("CPresencePluginPublisher::MakePublishReqL 1");       
       
   773         CreatePublisherL();
       
   774         
   803         DP_SDA(" -> MakePublishReqL, check for old doc id");       
   775         DP_SDA(" -> MakePublishReqL, check for old doc id");       
   804         HBufC8* oldDocumentId = HBufC8::NewLC( KBufSize255 );
   776         HBufC8* oldDocumentId = HBufC8::NewLC( KBufSize255 );
   805         TPtr8 oldDocumentIdPtr( oldDocumentId->Des() );
   777         TPtr8 oldDocumentIdPtr( oldDocumentId->Des() );
   806         TRAPD( error, iPresenceData->ReadDocumentIdL( 
   778         TRAPD( error, iPresenceData->ReadDocumentIdL( 
   807             iConnObs.ServiceId(), oldDocumentIdPtr ) );
   779             iConnObs.ServiceId(), oldDocumentIdPtr ) );
   808     if ( !iPublished )
       
   809         {
       
   810         DP_SDA("CPresencePluginPublisher::MakePublishReqL 1");       
       
   811         CreatePublisherL();
       
   812         
       
   813         DP_SDA2(" -> MakePublishReqL, doc id error: %d", error );
   780         DP_SDA2(" -> MakePublishReqL, doc id error: %d", error );
   814         if ( !error )
   781         if ( !error )
   815             {
   782             {
   816             DP_SDA(" -> MakePublishReqL, publish with old id");       
   783             DP_SDA(" -> MakePublishReqL, publish with old id");       
   817             iSimpleId = iPublisher->ContinuePublishL( 
   784             iSimpleId = iPublisher->ContinuePublishL( 
   820         else
   787         else
   821             {
   788             {
   822             DP_SDA(" -> MakePublishReqL, publish with new id");       
   789             DP_SDA(" -> MakePublishReqL, publish with new id");       
   823             iSimpleId = iPublisher->StartPublishL( *iDocument, ETrue );    
   790             iSimpleId = iPublisher->StartPublishL( *iDocument, ETrue );    
   824             }
   791             }
       
   792         CleanupStack::PopAndDestroy( oldDocumentId );
   825         }
   793         }
   826     else
   794     else
   827         {
   795         {
   828         DP_SDA("CPresencePluginPublisher::MakePublishReqL 2");
   796         DP_SDA("CPresencePluginPublisher::MakePublishReqL 2");
   829         CreatePublisherL();
   797         CreatePublisherL();
   830         DP_SDA("CPresencePluginPublisher::MakePublishReqL Continue Publish");
   798         DP_SDA("CPresencePluginPublisher::MakePublishReqL Continue Publish");
   831         if ( !error )
   799         iSimpleId =
   832             {
   800             iPublisher->ContinuePublishL( 
   833             DP_SDA(" -> MakePublishReqL, publish with stored id");
   801                 *iDocument ,ETrue, iConnObs.GetETag() );
   834             iSimpleId = iPublisher->ContinuePublishL( 
       
   835                 *iDocument ,ETrue, oldDocumentIdPtr );
       
   836             }
       
   837         else
       
   838             {
       
   839             DP_SDA(" -> MakePublishReqL, stored id not found" );
       
   840             DP_SDA(", publish with old id");
       
   841             iSimpleId = iPublisher->ContinuePublishL( 
       
   842                             *iDocument ,ETrue, iConnObs.GetETag() );
       
   843             }
       
   844 		DP_SDA("CPresencePluginPublisher::MakePublishReqL modifyed");
   802 		DP_SDA("CPresencePluginPublisher::MakePublishReqL modifyed");
   845         }
   803         }
   846     CleanupStack::PopAndDestroy( oldDocumentId );
   804                 
   847     DP_SDA("CPresencePluginPublisher::MakePublishReqL end");     
   805     DP_SDA("CPresencePluginPublisher::MakePublishReqL end");     
   848     } 
   806     } 
   849 
   807 
   850 // ---------------------------------------------------------------------------
   808 // ---------------------------------------------------------------------------
   851 // CPresencePluginPublisher::StartXdmOperationL
   809 // CPresencePluginPublisher::StartXdmOperationL