multimediacommsengine/mmcesrv/mmceevent/src/mcecomevent.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Server side SIP event class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include  <e32base.h>
       
    22 #include  <sipsubscribedialogassoc.h>
       
    23 #include  <sipreferdialogassoc.h>
       
    24 #include  <sipdialog.h>
       
    25 #include  <sipservertransaction.h>
       
    26 #include  <sipconnection.h>
       
    27 #include  <sipclienttransaction.h>
       
    28 #include  "mcecomevent.h"
       
    29 #include  "mcesipevent.h"
       
    30 #include  "mceeventcontext.h"
       
    31 #include  "mcesipconnection.h"
       
    32 #include  "mcesipeventhelper.h"
       
    33 #include  "mceserial.h"
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CMceComMoSubscribeEvent::NewL
       
    37 // Two-phased constructor.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40  CMceComEvent* CMceComEvent::NewL( CMceSipEvent& aSIPEvent,
       
    41 								   TUint32 aRefreshInterval )
       
    42 	{
       
    43     CMceComEvent* self = new( ELeave ) CMceComEvent( aSIPEvent,
       
    44                                                      aRefreshInterval );
       
    45     
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     CleanupStack::Pop(self);
       
    49 
       
    50     return self;
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CMceComEvent::CMceComEvent
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CMceComEvent::CMceComEvent( CMceSipEvent& aSIPEvent,
       
    58                             TUint32 aRefreshInterval ):
       
    59     iSIPEvent( aSIPEvent ),
       
    60     iPreviousAction( KErrNotFound ),
       
    61     iRefreshInterval( aRefreshInterval ),
       
    62     iReferType( CMceRefer::ENoSuppression ),
       
    63     iSilentSuppression( EFalse ),
       
    64     iIdValue( KMceEventIdNotAssigned )
       
    65 	{
       
    66 	
       
    67 	}
       
    68 	
       
    69 // -----------------------------------------------------------------------------
       
    70 // CMceComEvent::ConstructL
       
    71 // -----------------------------------------------------------------------------
       
    72 //	
       
    73 void CMceComEvent::ConstructL()
       
    74 	{
       
    75 	iEventContext = CMceEventContext::NewL( *this );
       
    76 	iMsgContent = KNullDesC8().AllocL();
       
    77 	iMsgContentType = KNullDesC8().AllocL();
       
    78 	}
       
    79 	
       
    80 // -----------------------------------------------------------------------------
       
    81 // CMceComEvent::~CMceComEvent
       
    82 // -----------------------------------------------------------------------------
       
    83 //	
       
    84  CMceComEvent::~CMceComEvent()
       
    85 	{
       
    86 	MCE_DELETE( iEventContext );
       
    87     if(iMsgHeaders)
       
    88     	{
       
    89     	if(iMsgHeaders->MdcaCount())
       
    90     		{
       
    91     		iMsgHeaders->Reset();
       
    92     		}
       
    93     	delete iMsgHeaders;
       
    94     	}
       
    95     
       
    96     MCE_DELETE( iMsgContent ); 
       
    97     
       
    98     MCE_DELETE( iMsgContentType );
       
    99     
       
   100     MCE_DELETE( iReason );
       
   101 	}
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CMceComEvent::PerformSubscribeActionL
       
   105 // This is to perform the specific action ex Subscribe...
       
   106 // for the specific event
       
   107 // -----------------------------------------------------------------------------
       
   108 //	
       
   109  void CMceComEvent::PerformActionL( TMceItcFunctions aEventAction )
       
   110 	{
       
   111 	iPreviousAction = aEventAction;
       
   112 
       
   113     iEventContext -> ProcessEventL( *this );
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CMceComEvent::EventContext
       
   118 // -----------------------------------------------------------------------------
       
   119 //		
       
   120  CMceEventContext& CMceComEvent::EventContext()
       
   121 	{
       
   122 	return *iEventContext;
       
   123 	}
       
   124 
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CMceComEvent::PreviousAction
       
   128 // -----------------------------------------------------------------------------
       
   129 //		
       
   130  TInt CMceComEvent::PreviousAction() const
       
   131 	{
       
   132 	return iPreviousAction;
       
   133 	}
       
   134 	
       
   135 // -----------------------------------------------------------------------------
       
   136 // CMceComEvent::SetPreviousAction
       
   137 // -----------------------------------------------------------------------------
       
   138 //		         
       
   139  void CMceComEvent::SetPreviousAction( TInt aEventAction )
       
   140 	{
       
   141 	iPreviousAction = aEventAction;
       
   142 	}
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CMceComEvent::SetPreviousAction
       
   146 // -----------------------------------------------------------------------------
       
   147 //		         
       
   148 CMceSipEvent& CMceComEvent::SIPEvent()
       
   149 	{
       
   150 	return iSIPEvent;
       
   151 	}	
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CMceComEvent::RefreshInterval
       
   155 // -----------------------------------------------------------------------------
       
   156 //		         
       
   157 TUint32 CMceComEvent::RefreshInterval()
       
   158 	{
       
   159 	return iRefreshInterval;
       
   160 	}
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CMceComEvent::SetRefreshInterval
       
   164 // -----------------------------------------------------------------------------
       
   165 //		         
       
   166 void  CMceComEvent::SetRefreshInterval( TUint32 aRefreshInterval )
       
   167 	{
       
   168 	iRefreshInterval = aRefreshInterval;
       
   169 	}
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CMceComEvent::ProceedL
       
   173 // This is for incoming response and error occured
       
   174 // -----------------------------------------------------------------------------
       
   175 //		         
       
   176 void CMceComEvent::ProceedL()
       
   177 	{
       
   178     iEventContext->ProcessIncomingResponseEventL( *this );
       
   179     }    
       
   180 	
       
   181 // -----------------------------------------------------------------------------
       
   182 // CMceComEvent::SetMsgHeaders
       
   183 // -----------------------------------------------------------------------------
       
   184 //               
       
   185 void CMceComEvent::SetMsgHeaders( CDesC8Array* aMsgHeaders )
       
   186 	{
       
   187 	delete iMsgHeaders;
       
   188 	iMsgHeaders = aMsgHeaders;
       
   189 	}
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CMceComEvent::ReceivedRequestL
       
   193 // This is for incoming request, if the dialog is not existed then nothing will
       
   194 // be done
       
   195 // -----------------------------------------------------------------------------
       
   196 //      
       
   197 void CMceComEvent::ReceivedRequestL()
       
   198 	{
       
   199     iEventContext->ProcessRequestReceivedEventL( *this );
       
   200     }
       
   201         
       
   202 // -----------------------------------------------------------------------------
       
   203 // CMceComEvent::SetMsgContentL
       
   204 // -----------------------------------------------------------------------------
       
   205 // 
       
   206 void CMceComEvent::SetMsgContentL( HBufC8* aContentType, 
       
   207         					       HBufC8* aContent )
       
   208 	{
       
   209 	MCE_DELETE( iMsgContentType );
       
   210 	MCE_DELETE( iMsgContent );
       
   211 	
       
   212 	if ( !aContentType )
       
   213 	    {
       
   214 	    iMsgContentType = KNullDesC8().AllocL();
       
   215 	    }
       
   216     if ( !aContent )
       
   217         {
       
   218         iMsgContent = KNullDesC8().AllocL();
       
   219         }
       
   220         
       
   221     iMsgContentType = aContentType ? aContentType : iMsgContentType;
       
   222     iMsgContent = aContent ? aContent : iMsgContent;
       
   223     
       
   224 	}
       
   225        
       
   226 // -----------------------------------------------------------------------------
       
   227 // CMceComEvent::MsgContent
       
   228 // -----------------------------------------------------------------------------
       
   229 // 
       
   230 HBufC8* CMceComEvent::MsgContent()
       
   231 	{
       
   232 	HBufC8* ret = iMsgContent;
       
   233 	iMsgContent = NULL;
       
   234 	return ret;	
       
   235 	}
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // CMceComEvent::SetReasonPhraseL
       
   239 // -----------------------------------------------------------------------------
       
   240 // 
       
   241 void CMceComEvent::SetReasonPhraseL( TUint32 aStatusCode,
       
   242 								 	 HBufC8* aReasonPhrase )
       
   243 	{
       
   244 	iStatusCode = aStatusCode;
       
   245 	if(iReason)
       
   246 		{
       
   247 		delete iReason;
       
   248 		iReason = NULL;	
       
   249 		}
       
   250 	if ( aReasonPhrase )
       
   251 	    {
       
   252 	    iReason = aReasonPhrase;    
       
   253 	    }
       
   254 	else
       
   255 	    {
       
   256 	    iReason = KNullDesC8().AllocL();
       
   257 	    }
       
   258 	}
       
   259 	
       
   260 // -----------------------------------------------------------------------------
       
   261 // CMceComEvent::ReasonPhrase
       
   262 // -----------------------------------------------------------------------------
       
   263 // 
       
   264 TUint32 CMceComEvent::StatusCode() const
       
   265 	{
       
   266 	return iStatusCode;	
       
   267 	}
       
   268 	
       
   269 // -----------------------------------------------------------------------------
       
   270 // CMceComEvent::ReasonPhrase
       
   271 // -----------------------------------------------------------------------------
       
   272 // 
       
   273 TDesC8& CMceComEvent::ReasonPhrase()
       
   274 	{
       
   275 	return *iReason;	
       
   276 	}  
       
   277 	             
       
   278 // -----------------------------------------------------------------------------
       
   279 // CMceComEvent::MsgContentType
       
   280 // -----------------------------------------------------------------------------
       
   281 // 
       
   282 TDesC8& CMceComEvent::MsgContentType()
       
   283 	{
       
   284 	return *iMsgContentType;	
       
   285 	}
       
   286 	
       
   287 // -----------------------------------------------------------------------------
       
   288 // CMceComEvent::MsgHeaders
       
   289 // -----------------------------------------------------------------------------
       
   290 //        
       
   291  CDesC8Array& CMceComEvent::MsgHeaders( TInt aMethodInd )
       
   292 	{
       
   293 	if ( iMsgHeaders )
       
   294 	    {
       
   295 	    return *iMsgHeaders;    
       
   296 	    }
       
   297 	else
       
   298 	    {
       
   299 	    return iSIPEvent.DefaultHeaders( aMethodInd );
       
   300 	    }
       
   301 	}
       
   302 
       
   303 // -----------------------------------------------------------------------------
       
   304 // CMceComEvent::SetReferType
       
   305 // -----------------------------------------------------------------------------
       
   306 //        
       
   307 void CMceComEvent::SetReferType( CMceRefer::TType aType)
       
   308     {
       
   309     iReferType = aType;
       
   310     }
       
   311     
       
   312 // -----------------------------------------------------------------------------
       
   313 // CMceComEvent::ReferType
       
   314 // -----------------------------------------------------------------------------
       
   315 //        
       
   316 CMceRefer::TType CMceComEvent::ReferType() const
       
   317     {
       
   318     return iReferType;
       
   319     }
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // CMceComEvent::SetSilentSuppressionOn
       
   323 // -----------------------------------------------------------------------------
       
   324 //        
       
   325 void CMceComEvent::SetSilentSuppressionOn()
       
   326     {
       
   327     iSilentSuppression = ETrue;
       
   328     }
       
   329 
       
   330 // -----------------------------------------------------------------------------
       
   331 // CMceComEvent::SilentSuppression
       
   332 // -----------------------------------------------------------------------------
       
   333 //        
       
   334 TBool CMceComEvent::SilentSuppression() const
       
   335     {
       
   336     return iSilentSuppression;
       
   337     }
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // CMceComEvent::SetIdValue
       
   341 // -----------------------------------------------------------------------------
       
   342 //        
       
   343 void CMceComEvent::SetIdValue( TUint aIdValue )
       
   344     {
       
   345     iIdValue = aIdValue;
       
   346     }
       
   347 
       
   348 // -----------------------------------------------------------------------------
       
   349 // CMceComEvent::IdValue
       
   350 // -----------------------------------------------------------------------------
       
   351 //        
       
   352 TUint CMceComEvent::IdValue() const
       
   353     {
       
   354     return iIdValue;
       
   355     }
       
   356     
       
   357 //  End of File