mmserv/radioutility/radioserver/Session/Src/RadioRequest.cpp
changeset 20 b67dd1fc57c5
parent 0 71ca22bcf22a
child 46 0ac9a5310753
equal deleted inserted replaced
19:4a629bc82c5e 20:b67dd1fc57c5
    19 
    19 
    20 
    20 
    21 // INCLUDE FILES
    21 // INCLUDE FILES
    22 #include    "RadioRequest.h"
    22 #include    "RadioRequest.h"
    23 #include    "RadioDebug.h"
    23 #include    "RadioDebug.h"
       
    24 #include    "trace.h"
    24 
    25 
    25 // ============================ MEMBER FUNCTIONS ===============================
    26 // ============================ MEMBER FUNCTIONS ===============================
    26 
    27 
    27 // -----------------------------------------------------------------------------
    28 // -----------------------------------------------------------------------------
    28 // CRadioRequest::CRadioRequest
    29 // CRadioRequest::CRadioRequest
    41 		iBool(EFalse),
    42 		iBool(EFalse),
    42 		iBoolPckg(iBool),
    43 		iBoolPckg(iBool),
    43 		iInt(0),
    44 		iInt(0),
    44 		iIntPckg(iInt)
    45 		iIntPckg(iInt)
    45     {
    46     {
       
    47     FUNC_LOG;
    46     }
    48     }
    47 
    49 
    48 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    49 // CRadioRequest::ConstructL
    51 // CRadioRequest::ConstructL
    50 // Symbian 2nd phase constructor can leave.
    52 // Symbian 2nd phase constructor can leave.
    51 // -----------------------------------------------------------------------------
    53 // -----------------------------------------------------------------------------
    52 //
    54 //
    53 void CRadioRequest::ConstructL()
    55 void CRadioRequest::ConstructL()
    54     {
    56     {
    55 	RADIO_RDEBUG(_L("[RADIO-SESS] CRadioRequest::ConstructL()"));
    57     FUNC_LOG;
    56 	CActiveScheduler::Add(this);
    58 	CActiveScheduler::Add(this);
    57     }
    59     }
    58 
    60 
    59 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    60 // CRadioRequest::NewLC
    62 // CRadioRequest::NewLC
    64 CRadioRequest* CRadioRequest::NewLC(
    66 CRadioRequest* CRadioRequest::NewLC(
    65 	RRadioSession& aSession,
    67 	RRadioSession& aSession,
    66 	MRadioObserver& aObserver,
    68 	MRadioObserver& aObserver,
    67 	TRadioServerRequest aRequest )
    69 	TRadioServerRequest aRequest )
    68     {
    70     {
       
    71     FUNC_LOG;
    69     CRadioRequest* self = new( ELeave ) CRadioRequest(aSession, aObserver, aRequest);
    72     CRadioRequest* self = new( ELeave ) CRadioRequest(aSession, aObserver, aRequest);
    70     CleanupStack::PushL( self );
    73     CleanupStack::PushL( self );
    71     self->ConstructL();
    74     self->ConstructL();
    72     return self;
    75     return self;
    73     }
    76     }
    74 
    77 
    75 // Destructor
    78 // Destructor
    76 CRadioRequest::~CRadioRequest()
    79 CRadioRequest::~CRadioRequest()
    77     {
    80     {
       
    81     FUNC_LOG;
       
    82     INFO_1("My pointer: 0x%x", this );
    78 	if ( IsActive() )
    83 	if ( IsActive() )
    79 		{
    84 		{
    80 		Cancel();
    85 		Cancel();
    81 		}
    86 		}
    82     }
    87     }
    89 //
    94 //
    90 void CRadioRequest::CompleteRequest(
    95 void CRadioRequest::CompleteRequest(
    91 	TRadioServerRequest aRequest,
    96 	TRadioServerRequest aRequest,
    92 	TInt aError )
    97 	TInt aError )
    93     {
    98     {
       
    99     FUNC_LOG;
    94 	iRequest = aRequest;
   100 	iRequest = aRequest;
    95 
   101 
    96 	TRequestStatus* stat = &iStatus;
   102 	TRequestStatus* stat = &iStatus;
    97     User::RequestComplete(stat, aError);
   103     User::RequestComplete(stat, aError);
    98 	SetActive();
   104 	SetActive();
   102 // CRadioRequest::DoCancel
   108 // CRadioRequest::DoCancel
   103 // -----------------------------------------------------------------------------
   109 // -----------------------------------------------------------------------------
   104 //
   110 //
   105 void CRadioRequest::DoCancel()
   111 void CRadioRequest::DoCancel()
   106     {
   112     {
       
   113     FUNC_LOG;
   107 	iSession.CancelRequest(iRequest);
   114 	iSession.CancelRequest(iRequest);
   108     }
   115     }
   109 
   116 
   110 // -----------------------------------------------------------------------------
   117 // -----------------------------------------------------------------------------
   111 // CRadioRequest::RunL
   118 // CRadioRequest::RunL
   112 // -----------------------------------------------------------------------------
   119 // -----------------------------------------------------------------------------
   113 //
   120 //
   114 void CRadioRequest::RunL()
   121 void CRadioRequest::RunL()
   115     {
   122     {
       
   123     FUNC_LOG;
   116 	TInt err = iStatus.Int();
   124 	TInt err = iStatus.Int();
   117 	if ( err == KErrCancel )
   125 	if ( err == KErrCancel )
   118 		{
   126 		{
   119 		// Ignore the cancelled request
   127 		// Ignore the cancelled request
   120 		RADIO_RDEBUG_INT(_L("[RADIO-SESS] CRadioRequest::RunL():cancelled [%d]"), iRequest);
   128 		INFO_1("cancelled iRequest [%d]", iRequest);
   121 		return;
   129 		return;
   122 		}
   130 		}
   123 
   131 
   124 	switch( iRequest )
   132 	switch( iRequest )
   125 		{
   133 		{
   126 		// Place the most frequent ones on top
   134 		// Place the most frequent ones on top
   127 		case ERadioServStationSeek:
   135 		case ERadioServStationSeek:
   128 			{
   136 			{
   129 			iInt = iIntPckg();
   137 			iInt = iIntPckg();
   130 			RADIO_RDEBUG_INT(_L("[RADIO-SESS] CRadioRequest::RunL(): ERadioServStationSeek [%d]"), iInt);
   138 			INFO_1("ERadioServStationSeek [%d]", iInt);
   131 			iObserver.StationSeekComplete(err, iInt);
   139 			iObserver.StationSeekComplete(err, iInt);
   132 			}
   140 			}
   133 			break;
   141 			break;
   134 		case ERadioServSetFrequency:
   142 		case ERadioServSetFrequency:
   135 			{
   143 			{
   136 			RADIO_RDEBUG(_L("[RADIO-SESS] CRadioRequest::RunL(): ERadioServSetFrequency"));
   144 			INFO("ERadioServSetFrequency");
   137 			iObserver.SetFrequencyComplete(err);
   145 			iObserver.SetFrequencyComplete(err);
   138 			}
   146 			}
   139 			break;
   147 			break;
   140 		case ERadioServRequestTunerControl:
   148 		case ERadioServRequestTunerControl:
   141 			{
   149 			{
   142 			RADIO_RDEBUG(_L("[RADIO-SESS] CRadioRequest::RunL(): ERadioServRequestTunerControl"));
   150 			INFO("ERadioServRequestTunerControl");
   143 			iObserver.RequestTunerControlComplete(err);
   151 			iObserver.RequestTunerControlComplete(err);
   144 			}
   152 			}
   145 			break;
   153 			break;
   146 		case ERadioServSetFrequencyRange:
   154 		case ERadioServSetFrequencyRange:
   147 			{
   155 			{
   148 			RADIO_RDEBUG(_L("[RADIO-SESS] CRadioRequest::RunL(): ERadioServSetFrequencyRange"));
   156 			INFO("ERadioServSetFrequencyRange");
   149 			iObserver.SetFrequencyRangeComplete(err);
   157 			iObserver.SetFrequencyRangeComplete(err);
   150 			}
   158 			}
   151 			break;
   159 			break;
   152 		case ERadioServPlay:
   160 		case ERadioServPlay:
   153 			{
   161 			{
   154 			RADIO_RDEBUG(_L("[RADIO-SESS] CRadioRequest::RunL(): ERadioServPlay"));
   162 			INFO("INFOERadioServPlay");
   155 			if ( err != KErrNone )
   163 			if ( err != KErrNone )
   156 				{
   164 				{
   157 				iObserver.RadioEventStateChange(EFalse, err);
   165 				iObserver.RadioEventStateChange(EFalse, err);
   158 				}
   166 				}
   159 			}
   167 			}
   160 			break;
   168 			break;
   161 		case ERadioServStationSeekByPTY:
   169 		case ERadioServStationSeekByPTY:
   162 			{
   170 			{
   163 			iInt = iIntPckg();
   171 			iInt = iIntPckg();
   164 			RADIO_RDEBUG_INT(_L("[RADIO-SESS] CRadioRequest::RunL(): ERadioServStationSeekByPTY [%d]"), iInt);
   172 			INFO_1("ERadioServStationSeekByPTY [%d]", iInt);
   165 			iObserver.StationSeekByPTYComplete(err, iInt);
   173 			iObserver.StationSeekByPTYComplete(err, iInt);
   166 			}
   174 			}
   167 			break;
   175 			break;
   168 		case ERadioServStationSeekByTA:
   176 		case ERadioServStationSeekByTA:
   169 			{
   177 			{
   170 			iInt = iIntPckg();
   178 			iInt = iIntPckg();
   171 			RADIO_RDEBUG_INT(_L("[RADIO-SESS] CRadioRequest::RunL(): ERadioServStationSeekByTA [%d]"), iInt);
   179 			INFO_1("ERadioServStationSeekByTA [%d]", iInt);
   172 			iObserver.StationSeekByTAComplete(err, iInt);
   180 			iObserver.StationSeekByTAComplete(err, iInt);
   173 			}
   181 			}
   174 			break;
   182 			break;
   175 		case ERadioServStationSeekByTP:
   183 		case ERadioServStationSeekByTP:
   176 			{
   184 			{
   177 			iInt = iIntPckg();
   185 			iInt = iIntPckg();
   178 			RADIO_RDEBUG_INT(_L("[RADIO-SESS] CRadioRequest::RunL(): ERadioServStationSeekByTP [%d]"), iInt);
   186 			INFO_1("ERadioServStationSeekByTP [%d]", iInt);
   179 			iObserver.StationSeekByTPComplete(err, iInt);
   187 			iObserver.StationSeekByTPComplete(err, iInt);
   180 			}
   188 			}
   181 			break;
   189 			break;
   182 		case ERadioServGetFreqByPTY:
   190 		case ERadioServGetFreqByPTY:
   183 			{
   191 			{
   203 			iObserver.GetPSByTAComplete(err, psList);
   211 			iObserver.GetPSByTAComplete(err, psList);
   204 			}
   212 			}
   205 			break;
   213 			break;
   206 		default:
   214 		default:
   207 			{
   215 			{
   208 			RADIO_RDEBUG(_L("[RADIO-SESS] CRadioRequest::RunL(): ERROR case default !!!"));
   216 			INFO("ERROR case default !!!");
   209 			User::Panic(_L("RadioServer"), KErrGeneral );
   217 			User::Panic(_L("RadioServer"), KErrGeneral );
   210 			break;
   218 			break;
   211 			}
   219 			}
   212 		}
   220 		}
   213     }
   221     }