videofeeds/provisioningprocessor/src/CIptvPPContentHandler.cpp
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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 the License "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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <utf.h>
       
    23 #include "IptvDebug.h"
       
    24 #include "iptvlocalisationliterals.h"
       
    25 #include <bautils.h>
       
    26 #include <hash.h>
       
    27 
       
    28 #include "CIptvService.h"
       
    29 #include "CIptvServices.h"
       
    30 #include "CIptvPPContentHandler.h"
       
    31 #include "CIptvProvisioningProcessor.h"
       
    32 
       
    33 const TInt KIptvIdleState = 0;
       
    34 const TInt KIptvServiceProviderState = 1;
       
    35 const TInt KIptvServiceState = 2;
       
    36 const TInt KIptvServiceDetailsState = 3;
       
    37 const TInt KIptvTextState = 4;
       
    38 const TInt KIptvTitleState = 5;
       
    39 const TInt KIptvDescriptionState = 6;
       
    40 const TInt KIptvServiceUriState = 7;
       
    41 const TInt KIptvIconUriState = 8;
       
    42 const TInt KIptvIapState = 9;
       
    43 const TInt KIptvServiceAccountUriState = 10;
       
    44 const TInt KIptvAuthState = 11;
       
    45 const TInt KIptvUsernameState = 12;
       
    46 const TInt KIptvPasswordState = 13;
       
    47 const TInt KIptvAppUIDState = 14;
       
    48 const TInt KIptvSearchUriState = 15;
       
    49 const TInt KIptvServiceGroupIdState = 16;
       
    50 const TInt KIptvUseCategoriesState = 17;
       
    51 const TInt KIptvUploadProviderState = 18;
       
    52 const TInt KIptvRecordUriState = 19;
       
    53 
       
    54 const TInt KIptvBufferMaxSize( 255 );
       
    55 const TInt KIptvMaxServiceCount( 20 );
       
    56 const TInt KIptvIapDefaultPriority( 50 );
       
    57 const TInt KIptvIapBufferLength( 100 );
       
    58 const TInt KIptvAppUIDMaxSize( 8 ); // Application UID in hex format: 12345678
       
    59 const TInt KIptvDriveLetterSpace( 2 );
       
    60 
       
    61 _LIT( KIptvServiceProvider, "ServiceProvider" );
       
    62 _LIT( KIptvServiceGroupProvider, "ServiceGroupProvider" );
       
    63 _LIT( KIptvService, "Service" );
       
    64 _LIT( KIptvServiceFeed, "ServiceFeed" );
       
    65 _LIT( KIptvServiceGroup, "ServiceGroup" );
       
    66 _LIT( KIptvServiceDetails, "ServiceDetails" );
       
    67 _LIT( KIptvUseCategories, "UseCategories" );
       
    68 _LIT( KIptvAppUID, "AppUID" );
       
    69 _LIT( KIptvText, "Text" );
       
    70 _LIT( KIptvTitle, "Title" );
       
    71 _LIT( KIptvDescription, "Description" );
       
    72 _LIT( KIptvServiceGroupId, "ServiceGroupId" );
       
    73 _LIT( KIptvServiceUri, "ServiceURI" );
       
    74 _LIT( KIptvIconUri, "IconURI" );
       
    75 _LIT( KIptvUploadProvider, "UploadProvider" );
       
    76 _LIT( KIptvServiceAccountUriSmallCase, "serviceAccountURI" );
       
    77 _LIT( KIptvServiceAccountUriCapitalCase, "ServiceAccountURI" );
       
    78 _LIT( KIptvAuth, "Auth" );
       
    79 _LIT( KIptvUsername, "UserName" );
       
    80 _LIT( KIptvPassword, "Password" );
       
    81 _LIT( KIptvIap, "IAP" );
       
    82 _LIT( KIptvType, "Type" );
       
    83 _LIT( KIptvProtocol, "Protocol" );
       
    84 _LIT( KIptvSearchURISmallCase, "searchURI" );
       
    85 _LIT( KIptvSearchURICapitalCase, "SearchURI" );
       
    86 _LIT( KIptvRecordURI, "RecordURI" );
       
    87 _LIT( KIptvEmpty, "" );
       
    88 
       
    89 _LIT( KIptvServiceAttrProviderId, "ProviderID" );
       
    90 _LIT( KIptvTextAttrLang, "lang" );
       
    91 
       
    92 // Type
       
    93 _LIT( KIptvVod, "VOD" );
       
    94 _LIT( KIptvVodCast, "VC" );
       
    95 _LIT( KIptvLiveTv, "LiveTV" );
       
    96 _LIT( KIptvBrowser, "Browser" );
       
    97 _LIT( KIptvSearch, "Search" );
       
    98 _LIT( KIptvUpload, "Upload" );
       
    99 _LIT( KIptvApplication, "Application" );
       
   100 _LIT( KIptvMobileTv, "MobileTv" );
       
   101 _LIT( KIptvSecureProvisioningServer, "SecureProvisioningServer" );
       
   102 
       
   103 // Protocol
       
   104 _LIT( KIptvProtocolRss, "RSS2.0" );
       
   105 _LIT( KIptvProtocolDvbIpi, "DVB-IPI" );
       
   106 _LIT( KIptvProtocolHTTPProp, "HTTP-PROP" );   // Application and plugin specific communication mechanism
       
   107 _LIT( KIptvProtocolHTTP, "HTTP" );            // Browser
       
   108 _LIT( KIptvProtocolXMLTV, "XMLTV" );
       
   109 _LIT( KIptvHttpPrefix, "http://" );
       
   110 
       
   111 _LIT( KIptvYes, "yes" );
       
   112 _LIT( KIptvOne, "1" );
       
   113 
       
   114 // ============================ MEMBER FUNCTIONS ===============================
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // CIptvPPContentHandler::NewL
       
   118 // Two-phased constructor.
       
   119 // Create instance of concrete interface implementation
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 CIptvPPContentHandler* CIptvPPContentHandler::NewL(
       
   123     CIptvProvisioningProcessor& aProcessor,
       
   124     const RFs& aFs )
       
   125     {
       
   126     CIptvPPContentHandler* self = new ( ELeave ) CIptvPPContentHandler( aProcessor, aFs );
       
   127     return self;
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CIptvPPContentHandler::~CIptvPPContentHandler
       
   132 // Destructor
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 CIptvPPContentHandler::~CIptvPPContentHandler()
       
   136     {
       
   137     delete iBuffer;
       
   138     delete iService;
       
   139     iServices = NULL;
       
   140     delete iPendingIcon;
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CIptvPPContentHandler::CIptvPPContentHandler
       
   145 // C++ default constructor
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 CIptvPPContentHandler::CIptvPPContentHandler(
       
   149     CIptvProvisioningProcessor& aProcessor,
       
   150     const RFs& aFs )
       
   151   : iState( KIptvIdleState ),
       
   152     iServiceCount( 0 ),
       
   153     iProcessor( aProcessor ),
       
   154     iService( NULL ),
       
   155     iBuffer( NULL ),
       
   156     iServices( NULL ),
       
   157     iError( KErrNone ),
       
   158     iServiceTitleState( EIptvServiceTitleNone ),
       
   159     iFs( aFs )
       
   160     {
       
   161     iCurrentDeviceLanguage = User::Language();
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // CIptvPPContentHandler::SetMode
       
   166 //
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 void CIptvPPContentHandler::SetMode( TBool aLocal )
       
   170     {
       
   171     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::SetMode" );
       
   172 
       
   173     iLocal = aLocal;
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // CIptvPPContentHandler::OnStartDocumentL
       
   178 //
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void CIptvPPContentHandler::OnStartDocumentL(
       
   182     const RDocumentParameters& /*aDocParam*/,
       
   183     TInt aErrorCode )
       
   184     {
       
   185     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnStartDocumentL" );
       
   186 
       
   187     if ( iError == KErrNone )
       
   188         {
       
   189         iError = aErrorCode;
       
   190         }
       
   191     }
       
   192 
       
   193 // ---------------------------------------------------------------------------
       
   194 // CIptvPPContentHandler::OnEndDocumentL
       
   195 //
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 void CIptvPPContentHandler::OnEndDocumentL( TInt aErrorCode )
       
   199     {
       
   200     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnEndDocumentL" );
       
   201 
       
   202     if ( iError == KErrNone )
       
   203         {
       
   204         iError = aErrorCode;
       
   205         }
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // CIptvPPContentHandler::OnStartElementL
       
   210 //
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 void CIptvPPContentHandler::OnStartElementL(
       
   214     const RTagInfo& aElement,
       
   215     const RAttributeArray& aAttributes,
       
   216     TInt aErrorCode )
       
   217     {
       
   218     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnStartElementL" );
       
   219 
       
   220     if ( iError == KErrNone )
       
   221         {
       
   222         iError = aErrorCode;
       
   223         }
       
   224 
       
   225     delete iBuffer;
       
   226     iBuffer = NULL;
       
   227 
       
   228     TBuf<KIptvBufferMaxSize> localName;
       
   229     TInt length = aElement.LocalName().DesC().Length();
       
   230     TInt valueLength = Min( length, KIptvBufferMaxSize );
       
   231     localName.Copy( aElement.LocalName().DesC().Mid( 0, valueLength ) );
       
   232 
       
   233     IPTVLOGSTRING2_LOW_LEVEL( "CIptvPPContentHandler::OnStartElementL %S", &localName );
       
   234 
       
   235     switch ( iState )
       
   236         {
       
   237         case KIptvIdleState:
       
   238             {
       
   239             if ( localName.Compare( KIptvServiceProvider ) == 0 )
       
   240                 {
       
   241                 iState = KIptvServiceProviderState;
       
   242                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvIdleState to KIptvServiceProviderState" );
       
   243                 }
       
   244             else if ( localName.Compare( KIptvServiceGroupProvider ) == 0 )
       
   245                 {
       
   246                 iState = KIptvServiceProviderState;
       
   247                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvIdleState to KIptvServiceProviderState with Grouping" );
       
   248                 }
       
   249             }
       
   250             break;
       
   251 
       
   252         case KIptvServiceProviderState:
       
   253             {
       
   254             if ( localName.Compare( KIptvServiceFeed ) == 0 ||
       
   255                ( localName.Compare( KIptvService ) == 0 && !iServiceGroupFeed ) )
       
   256                 {
       
   257                 // Start of new service
       
   258                 delete iService;
       
   259                 iService = NULL;
       
   260                 iService = CIptvService::NewL();
       
   261                 GetServiceTypeL( aAttributes );
       
   262                 iState = KIptvServiceState;
       
   263                 iServiceTitleState = EIptvServiceTitleNone;
       
   264                 iServiceGroupId = 0;
       
   265                 if ( iPendingIcon )
       
   266                     {
       
   267                     delete iPendingIcon;
       
   268                     iPendingIcon = NULL;
       
   269                     }
       
   270 
       
   271                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceProviderState to KIptvServiceState" );
       
   272                 }
       
   273             }
       
   274             break;
       
   275 
       
   276         case KIptvServiceState:
       
   277             {
       
   278             if ( localName.Compare( KIptvServiceDetails ) == 0 )
       
   279                 {
       
   280                 // Initially set this to false since all language specific data is
       
   281                 // presented inside service details block
       
   282                 iTitleLanguageDataSet = EFalse;
       
   283                 iDescriptionLanguageDataSet = EFalse;
       
   284                 iIconUriLanguageDataSet = EFalse;
       
   285                 iState = KIptvServiceDetailsState;
       
   286                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvServiceDetailsState" );
       
   287                 }
       
   288             else if ( localName.Compare( KIptvServiceUri ) == 0 )
       
   289                 {
       
   290                 iState = KIptvServiceUriState;
       
   291                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvServiceUriState" );
       
   292                 }
       
   293             else if ( localName.Compare( KIptvIconUri ) == 0 )
       
   294                 {
       
   295                 iState = KIptvIconUriState;
       
   296                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvIconUriState" );
       
   297                 }
       
   298             else if ( localName.Compare( KIptvUploadProvider ) == 0 )
       
   299                 {
       
   300                 iState = KIptvUploadProviderState;
       
   301                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvUploadProviderState" );
       
   302                 }
       
   303             else if ( localName.Compare( KIptvIap ) == 0 )
       
   304                 {
       
   305                 iState = KIptvIapState;
       
   306                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvIapState" );
       
   307                 }
       
   308             else if ( ( localName.Compare( KIptvServiceAccountUriSmallCase ) == 0 ) ||
       
   309                       ( localName.Compare( KIptvServiceAccountUriCapitalCase ) == 0 ) )
       
   310                 {
       
   311                 iState = KIptvServiceAccountUriState;
       
   312                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvServiceAccountUriState" );
       
   313                 }
       
   314             else if ( localName.Compare( KIptvAuth ) == 0 )
       
   315                 {
       
   316                 iState = KIptvAuthState;
       
   317                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvAuthState" );
       
   318                 }
       
   319             else if ( localName.Compare( KIptvAppUID ) == 0 )
       
   320                 {
       
   321                 iState = KIptvAppUIDState;
       
   322                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvAppUIDState" );
       
   323                 }
       
   324             else if ( ( localName.Compare( KIptvSearchURISmallCase ) == 0 ) ||
       
   325                       ( localName.Compare( KIptvSearchURICapitalCase ) == 0 ) )
       
   326                 {
       
   327                 iState = KIptvSearchUriState;
       
   328                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvSearchUriState" );
       
   329                 }
       
   330             else if ( localName.Compare( KIptvRecordURI ) == 0 )
       
   331                 {
       
   332                 iState = KIptvRecordUriState;
       
   333                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvRecordUriState" );
       
   334                 }
       
   335             }
       
   336             break;
       
   337 
       
   338         case KIptvServiceDetailsState:
       
   339             {
       
   340             if ( localName.Compare( KIptvText ) == 0 )
       
   341                 {
       
   342                 GetLanguageCode( aAttributes );
       
   343                 iState = KIptvTextState;
       
   344                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceDetailsState to KIptvTextState" );
       
   345                 }
       
   346             else if ( localName.Compare( KIptvServiceGroupId ) == 0 )
       
   347                 {
       
   348                 iState = KIptvServiceGroupIdState;
       
   349                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceDetailsState to KIptvServiceGroupIdState" );
       
   350                 }
       
   351             else if ( localName.Compare( KIptvUseCategories ) == 0 )
       
   352                 {
       
   353                 iState = KIptvUseCategoriesState;
       
   354                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceDetailsState to KIptvUseCategoriesState" );
       
   355                 }
       
   356             }
       
   357             break;
       
   358 
       
   359         case KIptvTextState:
       
   360             {
       
   361             if ( localName.Compare( KIptvTitle ) == 0 )
       
   362                 {
       
   363                 iState = KIptvTitleState;
       
   364                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvTextState to KIptvTitleState" );
       
   365                 }
       
   366             else if ( localName.Compare( KIptvDescription ) == 0 )
       
   367                 {
       
   368                 iState = KIptvDescriptionState;
       
   369                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvTextState to KIptvDescriptionState" );
       
   370                 }
       
   371             }
       
   372             break;
       
   373 
       
   374         case KIptvAuthState:
       
   375             {
       
   376             if ( localName.Compare( KIptvUsername ) == 0 )
       
   377                 {
       
   378                 iState = KIptvUsernameState;
       
   379                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvAuthState to KIptvUsernameState" );
       
   380                 }
       
   381             else if ( localName.Compare( KIptvPassword ) == 0 )
       
   382                 {
       
   383                 iState = KIptvPasswordState;
       
   384                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvAuthState to KIptvPasswordState" );
       
   385                 }
       
   386             }
       
   387             break;
       
   388 
       
   389         default:
       
   390             IPTVLOGSTRING_LOW_LEVEL( "Service provision::Unknown state" );
       
   391             break;
       
   392         }
       
   393     }
       
   394 
       
   395 // ---------------------------------------------------------------------------
       
   396 // CIptvPPContentHandler::OnEndElementL
       
   397 //
       
   398 // ---------------------------------------------------------------------------
       
   399 //
       
   400 void CIptvPPContentHandler::OnEndElementL( const RTagInfo& aElement, TInt aErrorCode )
       
   401     {
       
   402     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnEndElementL" );
       
   403 
       
   404     if ( iError == KErrNone )
       
   405         {
       
   406         iError = aErrorCode;
       
   407         }
       
   408 
       
   409     TBuf<KIptvBufferMaxSize> localName;
       
   410     TInt length = aElement.LocalName().DesC().Length();
       
   411     TInt valueLength = Min( length, KIptvBufferMaxSize );
       
   412     localName.Copy( aElement.LocalName().DesC().Mid( 0, valueLength ) );
       
   413     IPTVLOGSTRING2_LOW_LEVEL( "CIptvPPContentHandler::OnEndElementL %S", &localName );
       
   414 
       
   415     if ( iBuffer )
       
   416         {
       
   417         TPtr16 ptr = iBuffer->Des();
       
   418         ptr.Trim();
       
   419 
       
   420         // character conversion
       
   421         length = iBuffer->Length();
       
   422         HBufC* temp = HBufC::NewL( length );
       
   423         CleanupStack::PushL( temp );
       
   424         TPtr16 tempPtr = temp->Des();
       
   425 
       
   426         HBufC8* buffer = HBufC8::NewL( length );
       
   427         CleanupStack::PushL( buffer );
       
   428         buffer->Des().Copy( ptr );
       
   429 
       
   430         delete iBuffer;
       
   431         iBuffer = NULL;
       
   432 
       
   433         CnvUtfConverter::ConvertToUnicodeFromUtf8( tempPtr, *buffer );
       
   434 
       
   435         iBuffer = HBufC::NewL( length );
       
   436         iBuffer->Des().Copy( tempPtr );
       
   437 
       
   438         CleanupStack::PopAndDestroy( buffer );
       
   439         CleanupStack::PopAndDestroy( temp );
       
   440         //
       
   441         }
       
   442 
       
   443     switch ( iState )
       
   444         {
       
   445         case KIptvIdleState:
       
   446             break;
       
   447 
       
   448         case KIptvServiceProviderState:
       
   449             {
       
   450             if ( localName.Compare( KIptvServiceProvider ) == 0 )
       
   451                 {
       
   452                 iState = KIptvIdleState;
       
   453                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceProviderState to KIptvIdleState" );
       
   454                 }
       
   455             }
       
   456             break;
       
   457 
       
   458         case KIptvServiceState:
       
   459             {
       
   460             iServiceGroupFeed = !localName.Compare( KIptvServiceFeed );
       
   461             if ( iServiceGroupFeed || localName.Compare( KIptvService ) == 0 )
       
   462                 {
       
   463                 // End of one service
       
   464                 AddServiceL();
       
   465                 iProtocol.Zero();
       
   466                 delete iService;
       
   467                 iService = NULL;
       
   468 
       
   469                 iState = KIptvServiceProviderState;
       
   470                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceState to KIptvServiceProviderState" );
       
   471                 }
       
   472             }
       
   473             break;
       
   474 
       
   475         case KIptvServiceDetailsState:
       
   476             {
       
   477             if ( localName.Compare( KIptvServiceDetails ) == 0 )
       
   478                 {
       
   479                 iTitleLanguageDataSet = EFalse;
       
   480                 iDescriptionLanguageDataSet = EFalse;
       
   481                 iIconUriLanguageDataSet = EFalse;
       
   482                 iState = KIptvServiceState;
       
   483                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceDetailsState to KIptvServiceState" );
       
   484                 }
       
   485             }
       
   486             break;
       
   487 
       
   488         case KIptvTextState:
       
   489             {
       
   490             if ( localName.Compare( KIptvText ) == 0 )
       
   491                 {
       
   492                 iState = KIptvServiceDetailsState;
       
   493                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvTextState to KIptvServiceDetailsState" );
       
   494                 }
       
   495             }
       
   496             break;
       
   497 
       
   498         case KIptvTitleState:
       
   499             {
       
   500             if ( localName.Compare( KIptvTitle ) == 0 )
       
   501                 {
       
   502                 // If data is not already set or we hit correct language for the device
       
   503                 // then update title
       
   504                 if ( !iTitleLanguageDataSet ||
       
   505                     iCurrentlyParsedDetailLanguage == iCurrentDeviceLanguage )
       
   506                     {
       
   507                     CompleteTitleL();
       
   508                     }
       
   509                 iState = KIptvTextState;
       
   510                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvTitleState to KIptvTextState" );
       
   511                 }
       
   512             }
       
   513             break;
       
   514 
       
   515         case KIptvDescriptionState:
       
   516             {
       
   517             if ( localName.Compare( KIptvDescription ) == 0 )
       
   518                 {
       
   519                 // If data is not already set or we hit correct language for the device
       
   520                 // then update description
       
   521                 if ( !iDescriptionLanguageDataSet ||
       
   522                      iCurrentlyParsedDetailLanguage == iCurrentDeviceLanguage )
       
   523                     {
       
   524                     CompleteDescriptionL();
       
   525                     }
       
   526                 iState = KIptvTextState;
       
   527                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvDescriptionState to KIptvTextState" );
       
   528                 }
       
   529             }
       
   530             break;
       
   531 
       
   532         case KIptvServiceGroupIdState:
       
   533             {
       
   534             if ( localName.Compare( KIptvServiceGroupId ) == 0 )
       
   535                 {
       
   536                 CompleteGroupIdL();
       
   537                 iState = KIptvServiceDetailsState;
       
   538                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceGroupIdState to KIptvServiceDetailsState" );
       
   539                 }
       
   540             }
       
   541             break;
       
   542 
       
   543         case KIptvUseCategoriesState:
       
   544             {
       
   545             if ( localName.Compare( KIptvUseCategories ) == 0 )
       
   546                 {
       
   547                 CompleteUseCategoryL();
       
   548                 iState = KIptvServiceDetailsState;
       
   549                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvUseCategoriesState to KIptvServiceDetailsState" );
       
   550                 }
       
   551             }
       
   552             break;
       
   553 
       
   554         case KIptvServiceUriState:
       
   555             {
       
   556             if ( localName.Compare( KIptvServiceUri ) == 0 )
       
   557                 {
       
   558                 CompleteUriL();
       
   559                 iState = KIptvServiceState;
       
   560                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceUriState to KIptvServiceState" );
       
   561                 }
       
   562             }
       
   563             break;
       
   564 
       
   565         case KIptvIconUriState:
       
   566             {
       
   567             if ( localName.Compare( KIptvIconUri ) == 0 )
       
   568                 {
       
   569                 if ( iServiceGroupId > 0 )
       
   570                     {
       
   571                     // Use rel icon url for grouped services
       
   572                     CompleteIconUrlL();
       
   573                     }
       
   574                 else
       
   575                     {
       
   576                     // If data is not already set or we hit correct language for the device
       
   577                     // then update icon uri
       
   578                     if ( !iIconUriLanguageDataSet ||
       
   579                           iCurrentlyParsedDetailLanguage == iCurrentDeviceLanguage )
       
   580                         {
       
   581                         CompleteIconPathL();
       
   582                         }
       
   583                     }
       
   584 
       
   585                 iState = KIptvServiceState;
       
   586                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvIconUriState to KIptvServiceState" );
       
   587                 }
       
   588             }
       
   589             break;
       
   590 
       
   591         case KIptvUploadProviderState:
       
   592             if ( localName.Compare( KIptvUploadProvider ) == 0 )
       
   593                 {
       
   594                 CompleteUploadProvider();
       
   595                 iState = KIptvServiceState;
       
   596                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvUploadProviderState to KIptvServiceState" );
       
   597                 }
       
   598             break;
       
   599 
       
   600         case KIptvIapState:
       
   601             {
       
   602             if ( localName.Compare( KIptvIap ) == 0 )
       
   603                 {
       
   604                 CompleteIapL();
       
   605                 iState = KIptvServiceState;
       
   606                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvIapState to KIptvServiceState" );
       
   607                 }
       
   608             }
       
   609             break;
       
   610 
       
   611         case KIptvServiceAccountUriState:
       
   612             {
       
   613             if ( ( localName.Compare( KIptvServiceAccountUriSmallCase ) == 0 ) ||
       
   614                  ( localName.Compare( KIptvServiceAccountUriCapitalCase ) == 0 ) )
       
   615                 {
       
   616                 CompleteAccountMgmtUri();
       
   617                 iState = KIptvServiceState;
       
   618                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvServiceAccountUriState to KIptvServiceState" );
       
   619                 }
       
   620             }
       
   621             break;
       
   622 
       
   623         case KIptvAuthState:
       
   624             {
       
   625             if ( localName.Compare( KIptvAuth ) == 0 )
       
   626                 {
       
   627                 iState = KIptvServiceState;
       
   628                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvAuthState to KIptvServiceState" );
       
   629                 }
       
   630             }
       
   631             break;
       
   632 
       
   633         case KIptvUsernameState:
       
   634             {
       
   635             if ( localName.Compare( KIptvUsername ) == 0 )
       
   636                 {
       
   637                 CompleteUsernameL();
       
   638                 iState = KIptvAuthState;
       
   639                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvUsernameState to KIptvAuthState" );
       
   640                 }
       
   641             }
       
   642             break;
       
   643 
       
   644         case KIptvPasswordState:
       
   645             {
       
   646             if ( localName.Compare( KIptvPassword ) == 0 )
       
   647                 {
       
   648                 CompletePasswordL();
       
   649                 iState = KIptvAuthState;
       
   650                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvPasswordState to KIptvAuthState" );
       
   651                 }
       
   652             }
       
   653             break;
       
   654 
       
   655         case KIptvAppUIDState:
       
   656             {
       
   657             if ( localName.Compare( KIptvAppUID ) == 0 )
       
   658                 {
       
   659                 CompleteAppUIDL();
       
   660                 iState = KIptvServiceState;
       
   661                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvAppUIDState to KIptvServiceState" );
       
   662                 }
       
   663             }
       
   664             break;
       
   665 
       
   666         case KIptvSearchUriState:
       
   667             {
       
   668             if ( ( localName.Compare( KIptvSearchURISmallCase ) == 0 ) ||
       
   669                  ( localName.Compare( KIptvSearchURICapitalCase ) == 0 ) )
       
   670                 {
       
   671                 CompleteSearchUriL();
       
   672                 iState = KIptvServiceState;
       
   673                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvSearchUriState to KIptvServiceState" );
       
   674                 }
       
   675             }
       
   676             break;
       
   677 
       
   678         case KIptvRecordUriState:
       
   679             {
       
   680             if ( localName.Compare( KIptvRecordURI ) == 0 )
       
   681                 {
       
   682                 CompleteRecordUriL();
       
   683                 iState = KIptvServiceState;
       
   684                 IPTVLOGSTRING_LOW_LEVEL( "Service provision::State changed from KIptvAppUID to KIptvServiceState" );
       
   685                 }
       
   686             }
       
   687             break;
       
   688 
       
   689         default:
       
   690             IPTVLOGSTRING_LOW_LEVEL( "Service provision::Unknown state" );
       
   691             break;
       
   692         }
       
   693     delete iBuffer;
       
   694     iBuffer = NULL;
       
   695     }
       
   696 
       
   697 // ---------------------------------------------------------------------------
       
   698 // CIptvPPContentHandler::OnContentL
       
   699 //
       
   700 // ---------------------------------------------------------------------------
       
   701 //
       
   702 void CIptvPPContentHandler::OnContentL( const TDesC8& aBytes, TInt aErrorCode )
       
   703     {
       
   704     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnContentL" );
       
   705 
       
   706     if ( iError == KErrNone )
       
   707         {
       
   708         iError = aErrorCode;
       
   709         }
       
   710 
       
   711     TInt length = aBytes.Length();
       
   712     if ( iBuffer )
       
   713         {
       
   714         length = length + iBuffer->Length();
       
   715         }
       
   716 
       
   717     HBufC8* temp = HBufC8::NewL( length );
       
   718     CleanupStack::PushL( temp );
       
   719     TPtr8 ptr = temp->Des();
       
   720 
       
   721     if ( iBuffer )
       
   722         {
       
   723         ptr.Append( iBuffer->Des() );
       
   724         ptr.Append( aBytes );
       
   725         }
       
   726     else
       
   727         {
       
   728         ptr.Append( aBytes );
       
   729         }
       
   730 
       
   731     delete iBuffer;
       
   732     iBuffer = NULL;
       
   733     iBuffer = HBufC::NewL( length );
       
   734     TPtr16 desc = iBuffer->Des();
       
   735     desc.Copy( temp->Des() );
       
   736     CleanupStack::PopAndDestroy( temp );
       
   737     }
       
   738 
       
   739 // ---------------------------------------------------------------------------
       
   740 // CIptvPPContentHandler::CompleteSearchUriL
       
   741 //
       
   742 // ---------------------------------------------------------------------------
       
   743 //
       
   744 void CIptvPPContentHandler::CompleteSearchUriL()
       
   745     {
       
   746     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteSearchUriL" );
       
   747     if ( iBuffer && iService )
       
   748         {
       
   749         TInt length = iBuffer->Length();
       
   750         TInt dataToCopy = Min( length, KIptvSmServicesDbSearchUrlMaxLength );
       
   751         HBufC* temp = HBufC::NewL( dataToCopy );
       
   752         CleanupStack::PushL( temp ); // 1->
       
   753         TPtr tempPtr( temp->Des() );
       
   754         tempPtr.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
   755         iService->SetSearchUrlL( tempPtr );
       
   756         CleanupStack::PopAndDestroy( temp ); // <-1
       
   757         }
       
   758     }
       
   759 
       
   760 // ---------------------------------------------------------------------------
       
   761 // CIptvPPContentHandler::CompleteRecordUriL
       
   762 //
       
   763 // ---------------------------------------------------------------------------
       
   764 //
       
   765 void CIptvPPContentHandler::CompleteRecordUriL()
       
   766     {
       
   767     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteRecordUriL" );
       
   768     if ( iBuffer && iService )
       
   769         {
       
   770         TInt length = iBuffer->Length();
       
   771         TInt dataToCopy = Min( length, KIptvSmServicesDbRecordUrlMaxLength );
       
   772         HBufC* temp = HBufC::NewL( dataToCopy );
       
   773         CleanupStack::PushL( temp ); // 1->
       
   774         TPtr tempPtr( temp->Des() );
       
   775         tempPtr.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
   776         iService->SetRecordUrlL( tempPtr );
       
   777         CleanupStack::PopAndDestroy( temp ); // <-1
       
   778         }
       
   779     }
       
   780 
       
   781 // ---------------------------------------------------------------------------
       
   782 // CIptvPPContentHandler::CompleteTitleL
       
   783 //
       
   784 // ---------------------------------------------------------------------------
       
   785 //
       
   786 void CIptvPPContentHandler::CompleteTitleL()
       
   787     {
       
   788     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteTitleL" );
       
   789 
       
   790     if ( iBuffer )
       
   791         {
       
   792         TInt length = iBuffer->Length();
       
   793         TInt dataToCopy = Min( length, KIptvSmServicesDbNameMaxLength );
       
   794         TBuf<KIptvSmServicesDbNameMaxLength> temp;
       
   795         temp.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
   796 
       
   797         if ( iService )
       
   798             {
       
   799             iService->SetName( temp );
       
   800 
       
   801             if ( temp.CompareF( KQtnIptvVideoStoreList ) == 0 )
       
   802                 {
       
   803                 iServiceTitleState = EIptvServiceTitleStore;
       
   804                 if ( iPendingIcon )
       
   805                     {
       
   806                     // Store and delete pending icon.
       
   807                     SetIconPathL( *iPendingIcon );
       
   808 
       
   809                     delete iPendingIcon;
       
   810                     iPendingIcon = NULL;
       
   811                     }
       
   812                 }
       
   813              else
       
   814                 {
       
   815                 iServiceTitleState = EIptvServiceTitleNormal;
       
   816                 if ( iPendingIcon )
       
   817                     {
       
   818                     // Delete pending icon.
       
   819                     delete iPendingIcon;
       
   820                     iPendingIcon = NULL;
       
   821                     }
       
   822                 }
       
   823             }
       
   824         }
       
   825 
       
   826     iTitleLanguageDataSet = ETrue;
       
   827     }
       
   828 
       
   829 // ---------------------------------------------------------------------------
       
   830 // CIptvPPContentHandler::CompleteDescriptionL
       
   831 //
       
   832 // ---------------------------------------------------------------------------
       
   833 //
       
   834 void CIptvPPContentHandler::CompleteDescriptionL()
       
   835     {
       
   836     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteDescriptionL" );
       
   837 
       
   838     if ( iBuffer )
       
   839         {
       
   840         TInt length = iBuffer->Length();
       
   841         TInt dataToCopy = Min( length, KIptvSmServicesDbDescMaxLength );
       
   842         TBuf<KIptvSmServicesDbDescMaxLength> temp;
       
   843         temp.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
   844 
       
   845         if ( iService )
       
   846             {
       
   847             iService->SetDesc( temp );
       
   848             }
       
   849         }
       
   850     iDescriptionLanguageDataSet = ETrue;
       
   851     }
       
   852 
       
   853 // ---------------------------------------------------------------------------
       
   854 // CIptvPPContentHandler::CompleteGroupIdL
       
   855 //
       
   856 // ---------------------------------------------------------------------------
       
   857 //
       
   858 void CIptvPPContentHandler::CompleteGroupIdL()
       
   859     {
       
   860     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteGroupIdL" );
       
   861 
       
   862     if ( iBuffer )
       
   863         {
       
   864         TInt length( Min( iBuffer->Length(), KIptvSmServicesDbTempIdMaxLength ) );
       
   865         TBuf8<KIptvSmServicesDbTempIdMaxLength> groupId;
       
   866         groupId.Copy( iBuffer->Mid( 0, length ) );
       
   867 
       
   868         if ( iService )
       
   869             {
       
   870             // Make unique combined service provider id ( provider id + group id )
       
   871             length = Min( iService->GetProviderId().Length(),
       
   872                 KIptvSmServicesDbTempIdMaxLength );
       
   873             TBuf16<KIptvSmServicesDbTempIdMaxLength> providerId;
       
   874             providerId.Copy( iService->GetProviderId().Mid( 0, length ) );
       
   875 
       
   876             HBufC* comboId = HBufC::NewLC( length + groupId.Length() );
       
   877             TPtr ptr( comboId->Des() );
       
   878             ptr.Copy( groupId );
       
   879             ptr.Insert( 0, providerId );
       
   880             iService->SetProviderId( ptr );
       
   881             CleanupStack::PopAndDestroy( comboId );
       
   882 
       
   883             // Count hash
       
   884             CMD5* md5Calculator = CMD5::NewL();
       
   885             CleanupStack::PushL( md5Calculator );
       
   886             TPtrC8 hash( md5Calculator->Hash( groupId ) );
       
   887 
       
   888             // Group id
       
   889             TUint32 id( 0 );
       
   890             for ( TInt i( 0 ); i < hash.Length(); i++ )
       
   891                 {
       
   892                 id += hash[i];
       
   893                 }
       
   894 
       
   895             CleanupStack::PopAndDestroy( md5Calculator );
       
   896             iService->SetGroupId( id );
       
   897             iServiceGroupId = id;
       
   898             }
       
   899         }
       
   900     }
       
   901 
       
   902 // ---------------------------------------------------------------------------
       
   903 // CIptvPPContentHandler::CompleteUseCategoryL
       
   904 //
       
   905 // ---------------------------------------------------------------------------
       
   906 //
       
   907 void CIptvPPContentHandler::CompleteUseCategoryL()
       
   908     {
       
   909     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteUseCategoryL" );
       
   910 
       
   911     if ( iBuffer )
       
   912         {
       
   913         TInt length( Min( iBuffer->Length(), KMaxName ) );
       
   914         TName buffer( KNullDesC );
       
   915         buffer.Copy( iBuffer->Mid( 0, length ) );
       
   916 
       
   917         if ( iService && buffer.Length() > 0 )
       
   918             {
       
   919             buffer.LowerCase();
       
   920             TBool state = ( buffer.Compare( KIptvYes ) == 0 ||
       
   921                             buffer.Compare( KIptvOne ) == 0 );
       
   922             iService->SetUseCategory( state );
       
   923             }
       
   924         }
       
   925     }
       
   926 
       
   927 // ---------------------------------------------------------------------------
       
   928 // CIptvPPContentHandler::CompleteUriL
       
   929 //
       
   930 // ---------------------------------------------------------------------------
       
   931 //
       
   932 void CIptvPPContentHandler::CompleteUriL()
       
   933     {
       
   934     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteUriL" );
       
   935 
       
   936     TBuf<KIptvSmServicesDbAddressMaxLength> temp;
       
   937     if ( iBuffer )
       
   938         {
       
   939         TInt length = iBuffer->Length();
       
   940         TInt dataToCopy = Min( length, KIptvSmServicesDbAddressMaxLength );
       
   941         temp.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
   942         }
       
   943     else
       
   944         {
       
   945         // No URI available.
       
   946         temp.Copy( KIptvEmpty );
       
   947         }
       
   948 
       
   949     if ( iService )
       
   950         {
       
   951         iService->SetAddress( temp );
       
   952         }
       
   953     }
       
   954 
       
   955 // ---------------------------------------------------------------------------
       
   956 // CIptvPPContentHandler::CompleteIconUrlL
       
   957 //
       
   958 // ---------------------------------------------------------------------------
       
   959 //
       
   960 void CIptvPPContentHandler::CompleteIconUrlL()
       
   961     {
       
   962     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteIconUrlL" );
       
   963 
       
   964     TBuf<KIptvSmServicesDbAddressMaxLength> temp;
       
   965     if ( iBuffer )
       
   966         {
       
   967         TInt length = iBuffer->Length();
       
   968         TInt dataToCopy = Min( length, KIptvSmServicesDbAddressMaxLength );
       
   969         temp.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
   970         }
       
   971     else
       
   972         {
       
   973         // No URI available.
       
   974         temp.Copy( KIptvEmpty );
       
   975         }
       
   976 
       
   977     if ( iService )
       
   978         {
       
   979         iService->SetIconUrl( temp );
       
   980         }
       
   981     }
       
   982 
       
   983 // ---------------------------------------------------------------------------
       
   984 // CIptvPPContentHandler::CompleteIconPathL
       
   985 //
       
   986 // ---------------------------------------------------------------------------
       
   987 //
       
   988 void CIptvPPContentHandler::CompleteIconPathL()
       
   989     {
       
   990     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteIconPathL" );
       
   991 
       
   992     if ( iBuffer )
       
   993         {
       
   994         TInt length = iBuffer->Length();
       
   995         TInt dataToCopy = Min( length, KIptvSmServicesDbIconPathMaxLength );
       
   996         TBuf<KIptvSmServicesDbIconPathMaxLength> temp;
       
   997         temp.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
   998 
       
   999         temp.Trim();
       
  1000 
       
  1001         // We must accept local icon always for VideoStore Service.
       
  1002         TBool setIcon( ETrue );
       
  1003         if ( !iLocal && ( iServiceTitleState != EIptvServiceTitleStore ) )
       
  1004             {
       
  1005             // If this is from over the air path must not point to local file
       
  1006             if ( temp.Find( KIptvHttpPrefix ) != 0 )
       
  1007                 {
       
  1008                 if ( iServiceTitleState == EIptvServiceTitleNone )
       
  1009                     {
       
  1010                     // We don't yet know whether this is VideoStore Service.
       
  1011                     // Save 1st occurence of Icon.
       
  1012                     if ( !iPendingIcon )
       
  1013                         {
       
  1014                         iPendingIcon = HBufC::NewL( temp.Length() );
       
  1015                         iPendingIcon->Des().Copy( temp );
       
  1016                         setIcon = EFalse;
       
  1017                         }
       
  1018                     }
       
  1019                 else
       
  1020                     {
       
  1021                     IPTVLOGSTRING_LOW_LEVEL(
       
  1022                         "CIptvPPContentHandler::CompleteIconPathL: Error: local path not allowed" );
       
  1023                     setIcon = EFalse;
       
  1024                     }
       
  1025                 }
       
  1026             }
       
  1027 
       
  1028         if ( setIcon )
       
  1029             {
       
  1030             SetIconPathL( temp );
       
  1031             }
       
  1032         }
       
  1033 
       
  1034     iIconUriLanguageDataSet = ETrue;
       
  1035     }
       
  1036 
       
  1037 // ---------------------------------------------------------------------------
       
  1038 // CIptvPPContentHandler::CompleteUploadProvider
       
  1039 //
       
  1040 // ---------------------------------------------------------------------------
       
  1041 //
       
  1042 void CIptvPPContentHandler::CompleteUploadProvider()
       
  1043     {
       
  1044     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteUploadProvider" );
       
  1045 
       
  1046     if ( iBuffer )
       
  1047         {
       
  1048         TInt length( Min( iBuffer->Length(), KIptvSmServicesDbNameMaxLength ) );
       
  1049         TBuf<KIptvSmServicesDbNameMaxLength> temp( KNullDesC );
       
  1050         temp.Copy( iBuffer->Mid( 0, length ) );
       
  1051 
       
  1052         if ( iService && temp.Length() > 0 )
       
  1053             {
       
  1054             iService->SetUploadProvider( temp );
       
  1055             }
       
  1056         }
       
  1057     }
       
  1058 
       
  1059 // ---------------------------------------------------------------------------
       
  1060 // CIptvPPContentHandler::CompleteIapL
       
  1061 //
       
  1062 // ---------------------------------------------------------------------------
       
  1063 //
       
  1064 void CIptvPPContentHandler::CompleteIapL()
       
  1065     {
       
  1066     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteIapL" );
       
  1067 
       
  1068     if ( !iLocal )
       
  1069         {
       
  1070         IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteIapL, Not allowed OTA" );
       
  1071         return;
       
  1072         }
       
  1073 
       
  1074     if ( iBuffer )
       
  1075         {
       
  1076         TInt length = iBuffer->Length();
       
  1077         TBuf<KIptvIapBufferLength> buffer;
       
  1078         buffer.Copy( iBuffer->Mid( 0, length ) );
       
  1079 
       
  1080         if ( buffer.Length() > 0 )
       
  1081             {
       
  1082             TInt  iapValue = 0;
       
  1083             TBool iapAdded = EFalse;
       
  1084 
       
  1085             // Iap is defined either as number or with name.
       
  1086             if ( HasOnlyNumbers( buffer ) )
       
  1087                 {
       
  1088                 IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteIapL, IAP defined as number." );
       
  1089 
       
  1090                 TLex l( buffer );
       
  1091                 l.Val( iapValue );
       
  1092 
       
  1093                 // If IAP number available, add to service.
       
  1094                 if ( iService && iapValue != 0 )
       
  1095                     {
       
  1096                     TIptvIap iap;
       
  1097                     iap.iId = iapValue;
       
  1098                     iap.iPriority = KIptvIapDefaultPriority;
       
  1099 
       
  1100                     iService->iIapList->AddIap( iap );
       
  1101                     iapAdded = ETrue;
       
  1102                     }
       
  1103                 }
       
  1104             else
       
  1105                 {
       
  1106                 IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteIapL, IAP defined with name." );
       
  1107 
       
  1108                 iService->SetIapNameL( buffer.Left( KIptvSmServicesDbIapNameMaxLength ) );
       
  1109                 iapAdded = ETrue;
       
  1110                 }
       
  1111 
       
  1112             // Mark service so that IAPs cannot be modified.
       
  1113             if ( iapAdded )
       
  1114                 {
       
  1115                 iService->SetFlags(
       
  1116                     iService->GetFlags() | CIptvService::EReadOnlyIaps );
       
  1117                 }
       
  1118             }
       
  1119         }
       
  1120     }
       
  1121 
       
  1122 // ---------------------------------------------------------------------------
       
  1123 // CIptvPPContentHandler::HasOnlyNumbers
       
  1124 //
       
  1125 // ---------------------------------------------------------------------------
       
  1126 //
       
  1127 TBool CIptvPPContentHandler::HasOnlyNumbers( const TDesC& aString ) const
       
  1128     {
       
  1129     for ( TInt i = 0; i < aString.Length(); i++ )
       
  1130         {
       
  1131         TChar character = aString[i];
       
  1132 
       
  1133         if ( !( character == '0' || character == '1' || character == '2' ||
       
  1134                 character == '3' || character == '4' || character == '5' ||
       
  1135                 character == '6' || character == '7' || character == '8' ||
       
  1136                 character == '9' ) )
       
  1137             {
       
  1138             return EFalse;
       
  1139             }
       
  1140         }
       
  1141 
       
  1142     return ETrue;
       
  1143     }
       
  1144 
       
  1145 // ---------------------------------------------------------------------------
       
  1146 // CIptvPPContentHandler::CompleteUsernameL
       
  1147 //
       
  1148 // ---------------------------------------------------------------------------
       
  1149 //
       
  1150 void CIptvPPContentHandler::CompleteUsernameL()
       
  1151     {
       
  1152     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteUsernameL" );
       
  1153 
       
  1154     if ( iBuffer )
       
  1155         {
       
  1156         TInt length = iBuffer->Length();
       
  1157         TInt dataToCopy = Min( length, KIptvSmPasswordsDbUserNameMaxLength );
       
  1158         TBuf<KIptvSmPasswordsDbUserNameMaxLength> temp;
       
  1159         temp.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
  1160 
       
  1161         if ( iService )
       
  1162             {
       
  1163             iService->SetUserName( temp );
       
  1164             }
       
  1165         }
       
  1166     }
       
  1167 
       
  1168 // ---------------------------------------------------------------------------
       
  1169 // CIptvPPContentHandler::CompletePasswordL
       
  1170 //
       
  1171 // ---------------------------------------------------------------------------
       
  1172 //
       
  1173 void CIptvPPContentHandler::CompletePasswordL()
       
  1174     {
       
  1175     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompletePasswordL" );
       
  1176 
       
  1177     if ( iBuffer )
       
  1178        {
       
  1179        TInt length = iBuffer->Length();
       
  1180        TInt dataToCopy = Min( length, KIptvSmPasswordsDbPasswordMaxLength );
       
  1181        TBuf<KIptvSmPasswordsDbPasswordMaxLength> temp;
       
  1182        temp.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
  1183 
       
  1184        if ( iService )
       
  1185             {
       
  1186             iService->SetPassword( temp );
       
  1187             }
       
  1188        }
       
  1189     }
       
  1190 
       
  1191 // ---------------------------------------------------------------------------
       
  1192 // CIptvPPContentHandler::CompleteAccountMgmtUriL
       
  1193 // ---------------------------------------------------------------------------
       
  1194 //
       
  1195 void CIptvPPContentHandler::CompleteAccountMgmtUri()
       
  1196     {
       
  1197     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteAccountMgmtUri" );
       
  1198 
       
  1199     TBuf<KIptvSmServicesDbAccountManagementUrlMaxLength> temp;
       
  1200     if ( iBuffer )
       
  1201         {
       
  1202         TInt length = iBuffer->Length();
       
  1203         TInt dataToCopy = Min( length, KIptvSmServicesDbAccountManagementUrlMaxLength );
       
  1204         temp.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
  1205         }
       
  1206 
       
  1207     if ( iService )
       
  1208         {
       
  1209         iService->SetAccountManagementUrl( temp );
       
  1210         }
       
  1211     }
       
  1212 
       
  1213 // ---------------------------------------------------------------------------
       
  1214 // CIptvPPContentHandler::OnStartPrefixMappingL
       
  1215 //
       
  1216 // ---------------------------------------------------------------------------
       
  1217 //
       
  1218 void CIptvPPContentHandler::OnStartPrefixMappingL(
       
  1219     const RString& /*aPrefix*/,
       
  1220     const RString& /*aUri*/,
       
  1221     TInt aErrorCode )
       
  1222     {
       
  1223     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnStartPrefixMappingL" );
       
  1224 
       
  1225     if ( iError == KErrNone )
       
  1226         {
       
  1227         iError = aErrorCode;
       
  1228         }
       
  1229     }
       
  1230 
       
  1231 // ---------------------------------------------------------------------------
       
  1232 // CIptvPPContentHandler::OnEndPrefixMappingL
       
  1233 //
       
  1234 // ---------------------------------------------------------------------------
       
  1235 //
       
  1236 void CIptvPPContentHandler::OnEndPrefixMappingL(
       
  1237     const RString& /*aPrefix*/,
       
  1238     TInt aErrorCode )
       
  1239     {
       
  1240     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnEndPrefixMappingL" );
       
  1241 
       
  1242     if ( iError == KErrNone )
       
  1243         {
       
  1244         iError = aErrorCode;
       
  1245         }
       
  1246     }
       
  1247 
       
  1248 // ---------------------------------------------------------------------------
       
  1249 // CIptvPPContentHandler::OnIgnorableWhiteSpaceL
       
  1250 //
       
  1251 // ---------------------------------------------------------------------------
       
  1252 //
       
  1253 void CIptvPPContentHandler::OnIgnorableWhiteSpaceL(
       
  1254     const TDesC8& /*aBytes*/,
       
  1255     TInt aErrorCode )
       
  1256     {
       
  1257     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnIgnorableWhiteSpaceL" );
       
  1258 
       
  1259     if ( iError == KErrNone )
       
  1260         {
       
  1261         iError = aErrorCode;
       
  1262         }
       
  1263     }
       
  1264 
       
  1265 // ---------------------------------------------------------------------------
       
  1266 // CIptvPPContentHandler::OnSkippedEntityL
       
  1267 //
       
  1268 // ---------------------------------------------------------------------------
       
  1269 //
       
  1270 void CIptvPPContentHandler::OnSkippedEntityL(
       
  1271     const RString& /*aName*/,
       
  1272     TInt aErrorCode )
       
  1273     {
       
  1274     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnSkippedEntityL" );
       
  1275 
       
  1276     if ( iError == KErrNone )
       
  1277         {
       
  1278         iError = aErrorCode;
       
  1279         }
       
  1280     }
       
  1281 
       
  1282 // ---------------------------------------------------------------------------
       
  1283 // CIptvPPContentHandler::OnProcessingInstructionL
       
  1284 //
       
  1285 // ---------------------------------------------------------------------------
       
  1286 //
       
  1287 void CIptvPPContentHandler::OnProcessingInstructionL(
       
  1288     const TDesC8& /*aTarget*/,
       
  1289     const TDesC8& /*aData*/,
       
  1290     TInt aErrorCode )
       
  1291     {
       
  1292     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnProcessingInstructionL" );
       
  1293 
       
  1294     if ( iError == KErrNone )
       
  1295         {
       
  1296         iError = aErrorCode;
       
  1297         }
       
  1298     }
       
  1299 
       
  1300 // ---------------------------------------------------------------------------
       
  1301 // CIptvPPContentHandler::OnError
       
  1302 //
       
  1303 // ---------------------------------------------------------------------------
       
  1304 //
       
  1305 void CIptvPPContentHandler::OnError( TInt aErrorCode )
       
  1306     {
       
  1307     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::OnError" );
       
  1308 
       
  1309     if ( iError == KErrNone )
       
  1310         {
       
  1311         iError = aErrorCode;
       
  1312         }
       
  1313     }
       
  1314 
       
  1315 // ---------------------------------------------------------------------------
       
  1316 // CIptvPPContentHandler::GetExtendedInterface
       
  1317 //
       
  1318 // ---------------------------------------------------------------------------
       
  1319 //
       
  1320 TAny* CIptvPPContentHandler::GetExtendedInterface( const TInt32 /*aUid*/ )
       
  1321     {
       
  1322     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::GetExtendedInterface" );
       
  1323 
       
  1324     return NULL;
       
  1325     }
       
  1326 
       
  1327 // ---------------------------------------------------------------------------
       
  1328 // CIptvPPContentHandler::Reset
       
  1329 //
       
  1330 // ---------------------------------------------------------------------------
       
  1331 //
       
  1332 void CIptvPPContentHandler::Reset()
       
  1333     {
       
  1334     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::Reset" );
       
  1335 
       
  1336     iState = KIptvIdleState;
       
  1337     iServiceCount = 0;
       
  1338     }
       
  1339 
       
  1340 // ---------------------------------------------------------------------------
       
  1341 // CIptvPPContentHandler::isValidServiceL
       
  1342 //
       
  1343 // ---------------------------------------------------------------------------
       
  1344 //
       
  1345 TBool CIptvPPContentHandler::IsValidServiceL( TInt& aError )
       
  1346     {
       
  1347     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::IsValidServiceL" );
       
  1348 
       
  1349     TBool validType( EFalse );
       
  1350     aError = KErrNone;
       
  1351 
       
  1352     if ( iService->GetType() == CIptvService::EVodCast )
       
  1353         {
       
  1354         if ( iProtocol.Compare( KIptvProtocolRss ) == 0 )
       
  1355             {
       
  1356             validType = ETrue;
       
  1357             }
       
  1358         else
       
  1359             {
       
  1360             aError = KErrNotSupported;
       
  1361             }
       
  1362         }
       
  1363     else if ( iService->GetType() == CIptvService::EVod )
       
  1364         {
       
  1365         if ( ( iProtocol.Compare( KIptvProtocolRss ) == 0 ) ||
       
  1366              ( iProtocol.Compare( KIptvProtocolDvbIpi ) == 0 ) )
       
  1367             {
       
  1368             validType = ETrue;
       
  1369             }
       
  1370         else
       
  1371             {
       
  1372             aError = KErrNotSupported;
       
  1373             }
       
  1374         }
       
  1375     else if ( iService->GetType() == CIptvService::ELiveTv )
       
  1376         {
       
  1377         validType = EFalse;
       
  1378         }
       
  1379     else if ( iService->GetType() == CIptvService::EServiceGroup )
       
  1380         {
       
  1381         if ( iProtocol.Compare( KIptvProtocolRss ) == 0 &&
       
  1382              iService->GetGroupId() > 0 )
       
  1383             {
       
  1384             validType = ETrue;
       
  1385             }
       
  1386         else
       
  1387             {
       
  1388             aError = KErrNotSupported;
       
  1389             }
       
  1390         }
       
  1391     else if ( iService->GetType() == CIptvService::EBrowser )
       
  1392         {
       
  1393         validType = ETrue;
       
  1394         }
       
  1395     else if ( iService->GetType() == CIptvService::ESearch )
       
  1396         {
       
  1397         validType = ETrue;
       
  1398         }
       
  1399     else if ( iService->GetType() == CIptvService::EUpload )
       
  1400         {
       
  1401         validType = ETrue;
       
  1402         }
       
  1403     else if ( iService->GetType() == CIptvService::EApplication )
       
  1404         {
       
  1405         validType = ETrue;
       
  1406         }
       
  1407     else if ( iService->GetType() == CIptvService::EMobileTv )
       
  1408         {
       
  1409         validType = ETrue;
       
  1410         }
       
  1411     else if ( iService->GetType() == CIptvService::ESecureProvisioningServer )
       
  1412         {
       
  1413         validType = ETrue;
       
  1414         }
       
  1415     else
       
  1416         {
       
  1417         aError = KIptvInvalidServiceType;
       
  1418         }
       
  1419 
       
  1420     if ( validType )
       
  1421         {
       
  1422         if ( iService->GetName().Length() == 0 )
       
  1423             {
       
  1424             aError = KIptvRssParserError;
       
  1425             validType = EFalse;
       
  1426             }
       
  1427         if ( iService->SearchUrl().Length() > KIptvUrlMaxLength )
       
  1428             {
       
  1429             aError = KIptvInvalidUrl;
       
  1430             validType = EFalse;
       
  1431             }
       
  1432         }
       
  1433 
       
  1434     return validType;
       
  1435     }
       
  1436 
       
  1437 // ---------------------------------------------------------------------------
       
  1438 // CIptvPPContentHandler::AddService
       
  1439 //
       
  1440 // ---------------------------------------------------------------------------
       
  1441 //
       
  1442 void CIptvPPContentHandler::AddServiceL()
       
  1443     {
       
  1444     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::AddService" );
       
  1445 
       
  1446     if ( iServiceCount < KIptvMaxServiceCount && iError == KErrNone )
       
  1447         {
       
  1448         iService->SetDisplayOrder( iServiceCount );
       
  1449 
       
  1450         // Enable service
       
  1451         iService->SetId( 0 );
       
  1452         if ( iService->GetGroupId() == 0 ||
       
  1453              iService->GetType() == CIptvService::EServiceGroup )
       
  1454             {
       
  1455             iService->SetFlags( iService->GetFlags() | CIptvService::ESelected );
       
  1456             }
       
  1457         else if ( iService->GetGroupId() > 0 &&
       
  1458                   iService->GetType() != CIptvService::EServiceGroup )
       
  1459             {
       
  1460             iService->SetFlags( iService->GetFlags() | CIptvService::EGroupedService );
       
  1461             }
       
  1462 
       
  1463         if ( iLocal )
       
  1464             {
       
  1465             if ( iServices )
       
  1466                 {
       
  1467                 // Local provisioning sets readonly services.
       
  1468                 iService->SetFlags( iService->GetFlags() | CIptvService::EReadOnly );
       
  1469 
       
  1470                 TInt error( KErrNone );
       
  1471                 if ( IsValidServiceL( error ) )
       
  1472                     {
       
  1473                     iServiceCount++;
       
  1474                     iServices->AddL( *iService );
       
  1475                     }
       
  1476                 else
       
  1477                     {
       
  1478                     iError = error;
       
  1479                     }
       
  1480                 }
       
  1481             }
       
  1482         else
       
  1483             {
       
  1484             if ( iServices )
       
  1485                 {
       
  1486                 TInt error( KErrNone );
       
  1487                 if ( IsValidServiceL( error ) )
       
  1488                     {
       
  1489                     iServiceCount++;
       
  1490                     iServices->AddL( *iService );
       
  1491                     }
       
  1492                 else
       
  1493                     {
       
  1494                     iError = error;
       
  1495                     }
       
  1496                 }
       
  1497             }
       
  1498         }
       
  1499     }
       
  1500 
       
  1501 // ---------------------------------------------------------------------------
       
  1502 // CIptvPPContentHandler::GetServiceType
       
  1503 //
       
  1504 // ---------------------------------------------------------------------------
       
  1505 //
       
  1506 void CIptvPPContentHandler::GetServiceTypeL( const RAttributeArray& aAttributes )
       
  1507     {
       
  1508     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::GetServiceType" );
       
  1509 
       
  1510     TInt count = aAttributes.Count();
       
  1511     for ( TInt i = 0; i < count; i++ )
       
  1512         {
       
  1513         const RTagInfo& tag = aAttributes[i].Attribute();
       
  1514         TBuf<KIptvBufferMaxSize> name;
       
  1515         TInt length = tag.LocalName().DesC().Length();
       
  1516         TInt valueLength = Min( length, KIptvBufferMaxSize );
       
  1517         name.Copy( tag.LocalName().DesC().Mid( 0, valueLength ) );
       
  1518 
       
  1519         TBuf<KIptvBufferMaxSize> value;
       
  1520         length = aAttributes[i].Value().DesC().Length();
       
  1521         valueLength = Min( length, KIptvBufferMaxSize );
       
  1522         value.Copy( aAttributes[i].Value().DesC().Mid( 0, valueLength ) );
       
  1523 
       
  1524         // Type
       
  1525         if ( name.Compare( KIptvType ) == 0 )
       
  1526             {
       
  1527             SetServiceTypeL( value );
       
  1528             }
       
  1529         // Protocol
       
  1530         else if ( name.Compare( KIptvProtocol ) == 0 )
       
  1531             {
       
  1532             SetProtocolL( value );
       
  1533             }
       
  1534         // Provider id
       
  1535         else if ( name.Compare( KIptvServiceAttrProviderId ) == 0 )
       
  1536             {
       
  1537             iService->SetProviderId( value );
       
  1538             }
       
  1539         }
       
  1540     }
       
  1541 
       
  1542 // ---------------------------------------------------------------------------
       
  1543 // CIptvPPContentHandler::SetServiceTypeL
       
  1544 //
       
  1545 // ---------------------------------------------------------------------------
       
  1546 //
       
  1547 void CIptvPPContentHandler::SetServiceTypeL( const TDesC& aServiceType )
       
  1548     {
       
  1549     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::SetServiceTypeL" );
       
  1550 
       
  1551     if ( iService )
       
  1552        {
       
  1553         CIptvService::TServiceType type( CIptvService::EOther );
       
  1554         if ( aServiceType.Compare( KIptvVodCast ) == 0 )
       
  1555             {
       
  1556             type = CIptvService::EVodCast;
       
  1557             iService->SetFlags( 0 ); // Not main service
       
  1558             }
       
  1559         else if ( aServiceType.Compare( KIptvLiveTv ) == 0 )
       
  1560             {
       
  1561             type = CIptvService::ELiveTv;
       
  1562             iService->SetFlags( CIptvService::EMainService );
       
  1563             }
       
  1564         else if ( aServiceType.Compare( KIptvVod ) == 0 )
       
  1565             {
       
  1566             type = CIptvService::EVod;
       
  1567             iService->SetFlags( CIptvService::EMainService );
       
  1568             }
       
  1569         else if ( aServiceType.Compare( KIptvBrowser ) == 0 )
       
  1570             {
       
  1571             type = CIptvService::EBrowser;
       
  1572             iService->SetFlags( CIptvService::EMainService );
       
  1573             }
       
  1574         else if ( aServiceType.Compare( KIptvApplication ) == 0 )
       
  1575             {
       
  1576             type = CIptvService::EApplication;
       
  1577             iService->SetFlags( CIptvService::EMainService );
       
  1578             }
       
  1579         else if ( aServiceType.Compare( KIptvMobileTv ) == 0 )
       
  1580             {
       
  1581             type = CIptvService::EMobileTv;
       
  1582             iService->SetFlags( CIptvService::EMainService );
       
  1583             }
       
  1584         else if ( aServiceType.Compare( KIptvSecureProvisioningServer ) == 0 )
       
  1585             {
       
  1586             type = CIptvService::ESecureProvisioningServer;
       
  1587             iService->SetFlags( CIptvService::EMainService );
       
  1588             }
       
  1589         else if ( aServiceType.Compare( KIptvServiceGroup ) == 0 )
       
  1590             {
       
  1591             type = CIptvService::EServiceGroup;
       
  1592             iService->SetFlags( 0 ); // Not main service
       
  1593             }
       
  1594         else if ( aServiceType.Compare( KIptvSearch ) == 0 )
       
  1595             {
       
  1596             type = CIptvService::ESearch;
       
  1597             iService->SetFlags( 0 ); // Not main service
       
  1598             }
       
  1599         else if ( aServiceType.Compare( KIptvUpload ) == 0 )
       
  1600             {
       
  1601             type = CIptvService::EUpload;
       
  1602             iService->SetFlags( 0 ); // Not main service
       
  1603             }
       
  1604         else
       
  1605             {
       
  1606             // All other services go under other
       
  1607             iService->SetFlags( CIptvService::EMainService );
       
  1608             }
       
  1609 
       
  1610         iService->SetType( type );
       
  1611         }
       
  1612     }
       
  1613 
       
  1614 // ---------------------------------------------------------------------------
       
  1615 // CIptvPPContentHandler::SetProtocolL
       
  1616 //
       
  1617 // ---------------------------------------------------------------------------
       
  1618 //
       
  1619 void CIptvPPContentHandler::SetProtocolL( const TDesC& aProtocol )
       
  1620     {
       
  1621     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::SetProtocolL" );
       
  1622 
       
  1623     if ( iService )
       
  1624         {
       
  1625         if ( aProtocol.Compare( KIptvProtocolRss ) == 0 )
       
  1626             {
       
  1627             IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::SetProtocolL RSS" );
       
  1628 
       
  1629             iProtocol.Copy( KIptvProtocolRss );
       
  1630             TUid uid;
       
  1631             uid.iUid = KIptvRssPluginImplementationUid;
       
  1632             iService->SetEpgPluginUid( uid );
       
  1633             // No Live TV plugin in vodcast service
       
  1634             uid.iUid = 0;
       
  1635             iService->SetIptvPluginUid( uid );
       
  1636             // Set download plugin as http download plugin. RSS uses HTTP downloads
       
  1637             uid.iUid = IPTV_HTTP_VOD_DOWNLOAD_PLUGIN_IMPLEMENTATION_UID;
       
  1638             iService->SetVodPluginUid( uid );
       
  1639             }
       
  1640         else if ( aProtocol.Compare( KIptvProtocolDvbIpi ) == 0 )
       
  1641             {
       
  1642             IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::SetProtocolL DVB-IPI" );
       
  1643 
       
  1644             iProtocol.Copy( KIptvProtocolDvbIpi );
       
  1645             TUid uid;
       
  1646             uid.iUid = KIptvSmartvisionPluginUid;
       
  1647 
       
  1648             // Same plugin handles Live TV program guide and content quide
       
  1649             iService->SetEpgPluginUid( uid );
       
  1650             iService->SetIptvPluginUid( uid );
       
  1651 
       
  1652             // HTTP downloads used
       
  1653             uid.iUid = IPTV_HTTP_VOD_DOWNLOAD_PLUGIN_IMPLEMENTATION_UID;
       
  1654             iService->SetVodPluginUid( uid );
       
  1655             }
       
  1656         else if ( aProtocol.Compare( KIptvProtocolXMLTV ) == 0 )
       
  1657             {
       
  1658             iProtocol.Copy( KIptvProtocolXMLTV );
       
  1659             TUid uid;
       
  1660             uid.iUid = KIptvLiveTvXmlTvPluginUid;
       
  1661             iService->SetIptvPluginUid( uid );
       
  1662             iService->SetEpgPluginUid( uid );
       
  1663             uid.iUid = IPTV_HTTP_VOD_DOWNLOAD_PLUGIN_IMPLEMENTATION_UID;
       
  1664             iService->SetVodPluginUid( uid );
       
  1665             }
       
  1666         else if ( aProtocol.Compare( KIptvProtocolHTTP ) == 0 )
       
  1667             {
       
  1668             IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::SetProtocolL, HTTP" );
       
  1669 
       
  1670             iProtocol.Copy( KIptvProtocolHTTP );
       
  1671             }
       
  1672         else if ( aProtocol.Compare( KIptvProtocolHTTPProp ) == 0 )
       
  1673             {
       
  1674             IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::SetProtocolL, HTTP-PROP" );
       
  1675 
       
  1676             iProtocol.Copy( KIptvProtocolHTTPProp );
       
  1677             }
       
  1678         else
       
  1679             {
       
  1680             IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::SetProtocolL, Unknown protocol" );
       
  1681             // Not allowed, protocol must be something supported
       
  1682 
       
  1683             iProtocol.Zero();
       
  1684             }
       
  1685         }
       
  1686     }
       
  1687 
       
  1688 // ---------------------------------------------------------------------------
       
  1689 // CIptvPPContentHandler::CompleteAppUIDL
       
  1690 //
       
  1691 // ---------------------------------------------------------------------------
       
  1692 //
       
  1693 void CIptvPPContentHandler::CompleteAppUIDL()
       
  1694     {
       
  1695     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteAppUIDL" );
       
  1696 
       
  1697     if ( !iLocal )
       
  1698         {
       
  1699         IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteAppUIDL, Not allowed OTA" );
       
  1700         return;
       
  1701         }
       
  1702 
       
  1703     if ( iBuffer )
       
  1704         {
       
  1705         TUint32 appUid = 0;
       
  1706         TInt length = iBuffer->Length();
       
  1707         TInt dataToCopy = Min( length, KIptvAppUIDMaxSize );
       
  1708         TBuf<KIptvAppUIDMaxSize + KIptvDriveLetterSpace> temp;
       
  1709         temp.Copy( iBuffer->Mid( 0, dataToCopy ) );
       
  1710 
       
  1711         temp.ZeroTerminate();
       
  1712         // Number is always 8 digits long and in hexadecimal format
       
  1713         TLex16 converter( temp );
       
  1714         if ( converter.Val( appUid, EHex ) != KErrNone )
       
  1715             {
       
  1716             IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::CompleteAppUIDL, Invalid App UID" );
       
  1717             // implement cancel processing of this service
       
  1718             return;
       
  1719             }
       
  1720 
       
  1721         if ( iService )
       
  1722             {
       
  1723             iService->SetApplicationUid( appUid );
       
  1724             }
       
  1725         }
       
  1726     }
       
  1727 
       
  1728 // ---------------------------------------------------------------------------
       
  1729 // CIptvPPContentHandler::SetServicesArray
       
  1730 //
       
  1731 // ---------------------------------------------------------------------------
       
  1732 //
       
  1733 void CIptvPPContentHandler::SetServicesArray( CIptvServices* aServices )
       
  1734     {
       
  1735     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::SetServicesArray" );
       
  1736 
       
  1737     iServices = aServices;
       
  1738     }
       
  1739 
       
  1740 // ---------------------------------------------------------------------------
       
  1741 // CIptvPPContentHandler::GetLanguageCode
       
  1742 //
       
  1743 // ---------------------------------------------------------------------------
       
  1744 //
       
  1745 void CIptvPPContentHandler::GetLanguageCode( const RAttributeArray& aAttributes )
       
  1746     {
       
  1747     iCurrentLanguageCode.Zero();
       
  1748 
       
  1749     TInt count = aAttributes.Count();
       
  1750     for ( TInt i = 0; i < count; i++ )
       
  1751         {
       
  1752         const RTagInfo& tag = aAttributes[i].Attribute();
       
  1753         TPtrC8 attrLocalName = tag.LocalName().DesC();
       
  1754         TBuf<KIptvBufferMaxSize> localName;
       
  1755         localName.Copy( attrLocalName );
       
  1756         if ( localName.Compare( KIptvTextAttrLang ) == 0 )
       
  1757             {
       
  1758             iCurrentLanguageCode.Copy(
       
  1759                 aAttributes[i].Value().DesC().Left( KMaxLanguageCodeStringLength ) );
       
  1760             }
       
  1761         }
       
  1762     if ( iCurrentLanguageCode.Length() > 0 )
       
  1763         {
       
  1764         iCurrentlyParsedDetailLanguage =
       
  1765             CIptvUtil::GetLanguageByCountryCode( iCurrentLanguageCode );
       
  1766         }
       
  1767     }
       
  1768 
       
  1769 // ---------------------------------------------------------------------------
       
  1770 // CIptvPPContentHandler::SetIconPathL()
       
  1771 // ---------------------------------------------------------------------------
       
  1772 //
       
  1773 void CIptvPPContentHandler::SetIconPathL( const TDesC& aIconPath )
       
  1774     {
       
  1775     IPTVLOGSTRING_LOW_LEVEL( "CIptvPPContentHandler::SetIconPathL" );
       
  1776 
       
  1777     // Check for a file name without drive letter.
       
  1778     if ( ( aIconPath.Length() > 0 ) && ( aIconPath[0] == '\\' ) )
       
  1779         {
       
  1780         TBool accept( EFalse );
       
  1781         TDriveList driveList;
       
  1782         TDriveInfo driveInfo;
       
  1783 
       
  1784         if ( KErrNone == iFs.DriveList( driveList ) )
       
  1785             {
       
  1786             HBufC* tempName =
       
  1787                 HBufC::NewLC( aIconPath.Length() + KIptvDriveLetterSpace );
       
  1788             TChar character;
       
  1789 
       
  1790             for ( TInt i = EDriveA; i <= EDriveZ && !accept; i++ )
       
  1791                 {
       
  1792                 if ( driveList[i] &&
       
  1793                      ( KErrNone == iFs.Drive( driveInfo, i ) ) &&
       
  1794                      ( KErrNone == RFs::DriveToChar( i, character ) ) )
       
  1795                     {
       
  1796                     tempName->Des().Zero();
       
  1797                     tempName->Des().Append( character );
       
  1798                     tempName->Des().Append( ':' );
       
  1799                     tempName->Des().Append( aIconPath );
       
  1800 
       
  1801                     IPTVLOGSTRING2_LOW_LEVEL(
       
  1802                         "Scanning icon from %S", tempName );
       
  1803                     if ( BaflUtils::FileExists( iFs, *tempName ) )
       
  1804                         {
       
  1805                         IPTVLOGSTRING_LOW_LEVEL( " ---- Icon found" );
       
  1806                         accept = ETrue;
       
  1807                         }
       
  1808                     }
       
  1809                 }
       
  1810 
       
  1811             if ( accept && iService )
       
  1812                 {
       
  1813                 iService->SetIconPath( tempName->Des() );
       
  1814                 }
       
  1815 
       
  1816             CleanupStack::PopAndDestroy( tempName );
       
  1817             }
       
  1818         }
       
  1819     else if ( iService )
       
  1820         {
       
  1821         iService->SetIconPath( aIconPath );
       
  1822         }
       
  1823     }