internetradio2.0/streamsourceinc/iricyflowinitiator.h
changeset 0 09774dfdd46b
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Initiates an ICY session.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /* ---------------------------------------------------------------------------
       
    20 *  Version history:
       
    21 *  Template version:
       
    22 *  <ccm_history>
       
    23 *
       
    24 *  Version: 3, Tue Mar 11 20:00:00 2008 by Rohit
       
    25 *  Ref:
       
    26 *  Merged IRv1.0 Engine code changes
       
    27 *
       
    28 *  Version: 2, Tue Feb 28 18:00:00 2008 by Rohit/Kranthi
       
    29 *  Ref:
       
    30 *  Added NetworkController instance for Byte Counter Impl
       
    31 *
       
    32 *  </ccm_history>
       
    33 * ============================================================================
       
    34 */
       
    35 
       
    36 #ifndef IR_IRICYFLOWINITIATOR
       
    37 #define IR_IRICYFLOWINITIATOR
       
    38 
       
    39 #include <e32base.h>
       
    40 
       
    41 #include "irsockettimeouttimer.h"
       
    42 
       
    43 class RSocket;
       
    44 class CIRStationConnection;
       
    45 class TChannelInfo;
       
    46 class CIRNetworkController;
       
    47 
       
    48 /**
       
    49 * This class manages the connection to a channel server
       
    50 */
       
    51 NONSHARABLE_CLASS ( CIRIcyFlowInitiator ) : public CActive,  public MIRSocketTimeoutNotifier
       
    52     {
       
    53 public:
       
    54 
       
    55     /**
       
    56      * Standard Symbian two-phase construction
       
    57      *
       
    58      * @param aSocket       Socket to be read.
       
    59      * @param aUri          The URI of the ICY source (channel server)
       
    60      * @param aOwner        The owner of this CIRIcyFlowReader
       
    61      * @param aChannelInfo  Information describing the ICY session (to be filled)
       
    62      * @return Instance of CIRIcyFlowInitiator
       
    63      */
       
    64     static CIRIcyFlowInitiator* NewL( RSocket& aSocket, const TDesC& aUri,
       
    65     			 CIRStationConnection& aOwner, TChannelInfo& aChannelInfo );
       
    66 
       
    67     /**
       
    68      * Default C++ destructor
       
    69      */
       
    70     ~CIRIcyFlowInitiator();
       
    71 
       
    72     /**
       
    73      * From base class MIRSocketTimeoutNotifier
       
    74      */
       
    75     void TimerExpired();
       
    76 
       
    77 	/**
       
    78      * Send an ICY session request (ICY GET) to the channel server
       
    79      */
       
    80     void RequestFlow();
       
    81 
       
    82 protected:
       
    83 
       
    84 // From base class CActive
       
    85 
       
    86     /**
       
    87      * From base class CActive.
       
    88      */
       
    89     void RunL();
       
    90 
       
    91     /**
       
    92      * From base class CActive.
       
    93      */
       
    94 	TInt RunError(TInt aError);
       
    95 
       
    96     /**
       
    97      * From base class CActive.
       
    98      */
       
    99     void DoCancel();
       
   100 
       
   101 private:
       
   102 	/**
       
   103      * The states of the flow initiator
       
   104      */
       
   105     enum TIRIcyFlowInitiatorState
       
   106 		{
       
   107 		EIRIdle,
       
   108         EIRSending,
       
   109 		EIRReceiving,
       
   110 		EIRFinished
       
   111 		};
       
   112 
       
   113 private:
       
   114 
       
   115     /**
       
   116      * C++ constructor.
       
   117      *
       
   118      * @param aSocket       Socket to be read.
       
   119      * @param aUri          The URI of the ICY source (channel server)
       
   120      * @param aOwner        The owner of this CIRIcyFlowReader
       
   121      * @param aChannelInfo  Information describing the ICY session (to be filled)
       
   122      * @return Instance of CIRIcyFlowInitiator
       
   123      */
       
   124     CIRIcyFlowInitiator( RSocket& aSocket, const TDesC& aUri, CIRStationConnection& aOwner,
       
   125     						 TChannelInfo& aChannelInfo );
       
   126 
       
   127     /**
       
   128      * Standard Symbian second-phase construction.
       
   129      */
       
   130     void ConstructL();
       
   131 
       
   132 	/**
       
   133      * Parse and validate the url
       
   134      *
       
   135      * @return ETrue if all the URI components could be extracted, EFalse otherwise.
       
   136      */
       
   137     TBool ExtractUriComponentsL();
       
   138 
       
   139    	/**
       
   140      * Validates the response from the channel server
       
   141      *
       
   142      * @return ETrue if channel server is acceptable.
       
   143      */
       
   144     TBool ValidateChannelServer();
       
   145 
       
   146 	/**
       
   147      * Parses the channel headers to get the channel information
       
   148      */
       
   149 	void ParseChannelInfoL();
       
   150 
       
   151 	/**
       
   152 	 * Extract the specified meta data information
       
   153 	 *
       
   154 	 * @param aMetaField Metafield to be extracted
       
   155  	 * @param aBuffer Buffer into which the meta data is to be extracted
       
   156      * @return ETrue if extraction is sucessful, EFalse otherwise
       
   157      */
       
   158 	TBool ExtractMetaInfoL(const TDesC8& aMetaField, TDes8 &aBuffer ) const;
       
   159 
       
   160 private:
       
   161 
       
   162 	/**
       
   163      * Used for timeout mechanism.
       
   164      * Owned.
       
   165      */
       
   166 	CIRSocketTimeOutTimer* iSocketTimer;
       
   167 
       
   168     /**
       
   169      * Holds the resolved host information.
       
   170      * Owned.
       
   171      */
       
   172 	RBuf8 iHost;
       
   173 
       
   174 	/**
       
   175      * Holds the resolved path information.
       
   176      * Owned.
       
   177      */
       
   178 	RBuf8 iPath;
       
   179 
       
   180 	/**
       
   181 	 * Incoming data buffer.
       
   182 	 * Owned.
       
   183 	 */
       
   184 	RBuf8 iBuffer;
       
   185 
       
   186 	/**
       
   187 	 * Buffer used to read the data from socket. 
       
   188 	 * Owned.
       
   189 	 */
       
   190 	RBuf8 iReadBuffer;	
       
   191 	
       
   192 	/** 
       
   193 	 * Holds the UAProf string.
       
   194 	 * Owned.
       
   195 	 */
       
   196 	RBuf8 iUAProfString;
       
   197 
       
   198 	/**
       
   199 	 * Indicates the state of this IRIcyFlowInitiator
       
   200 	 */
       
   201 	TIRIcyFlowInitiatorState iState;
       
   202 
       
   203 	/**
       
   204 	 * Socket connected to channel server
       
   205 	 */
       
   206 	RSocket& iSocket;
       
   207 
       
   208     /**
       
   209      * Reference to the URI associated with the channel server
       
   210      */
       
   211     const TDesC& iUri;
       
   212 
       
   213     /**
       
   214      * Owner of this object in whole-part relation.
       
   215      */
       
   216     CIRStationConnection& iOwner;
       
   217 
       
   218 	/**
       
   219      * Information about the current ICY session.
       
   220      */
       
   221 	TChannelInfo& iChannelInfo;
       
   222 
       
   223 	CIRNetworkController* iNetworkControllerHandle;
       
   224     };
       
   225 
       
   226 #endif // IR_IRICYFLOWINITIATOR
       
   227 
       
   228 
       
   229