videoplayerapp/videoplayerengine/src/videoserviceurifetch.cpp
author hgs
Fri, 30 Apr 2010 09:52:11 +0300
changeset 37 4eb2df7f7cbe
parent 36 8aed59de29f9
child 24 7d93ee07fb27
permissions -rw-r--r--
201017
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  Implementation of VideoServiceUriFetch
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
36
hgs
parents: 30
diff changeset
    18
// Version : %version: %
hgs
parents: 30
diff changeset
    19
30
hgs
parents:
diff changeset
    20
#include <hbapplication.h>
hgs
parents:
diff changeset
    21
36
hgs
parents: 30
diff changeset
    22
#include "videoservices.h"
hgs
parents: 30
diff changeset
    23
#include "videoserviceurifetch.h"
30
hgs
parents:
diff changeset
    24
#include "mpxhbvideocommondefs.h"
36
hgs
parents: 30
diff changeset
    25
#include "mpxvideo_debug.h"
30
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
hgs
parents:
diff changeset
    28
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    29
// VideoServiceUriFetch()
hgs
parents:
diff changeset
    30
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    31
//
hgs
parents:
diff changeset
    32
VideoServiceUriFetch::VideoServiceUriFetch(VideoServices* parent)
36
hgs
parents: 30
diff changeset
    33
    : XQServiceProvider( QLatin1String("com.nokia.Videos.IVideoFetch"), parent )
hgs
parents: 30
diff changeset
    34
    , mRequestIndex( 0 )
hgs
parents: 30
diff changeset
    35
    , mServiceApp( parent )
30
hgs
parents:
diff changeset
    36
{
36
hgs
parents: 30
diff changeset
    37
    MPX_ENTER_EXIT(_L("VideoServiceUriFetch::VideoServiceUriFetch()"));
30
hgs
parents:
diff changeset
    38
	publishAll();
hgs
parents:
diff changeset
    39
}
hgs
parents:
diff changeset
    40
hgs
parents:
diff changeset
    41
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    42
// ~VideoServiceUriFetch()
hgs
parents:
diff changeset
    43
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    44
//
hgs
parents:
diff changeset
    45
VideoServiceUriFetch::~VideoServiceUriFetch()
hgs
parents:
diff changeset
    46
{
36
hgs
parents: 30
diff changeset
    47
    MPX_DEBUG(_L("VideoServiceUriFetch::~VideoServiceUriFetch()"));
30
hgs
parents:
diff changeset
    48
}
hgs
parents:
diff changeset
    49
hgs
parents:
diff changeset
    50
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    51
// fetchFailed()
hgs
parents:
diff changeset
    52
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    53
//
hgs
parents:
diff changeset
    54
void VideoServiceUriFetch::fetchFailed( int errorCode )
hgs
parents:
diff changeset
    55
{
36
hgs
parents: 30
diff changeset
    56
    MPX_ENTER_EXIT(_L("VideoServiceUriFetch::fetchFailed()"),
hgs
parents: 30
diff changeset
    57
                   _L("errorCode = %d"), errorCode );
hgs
parents: 30
diff changeset
    58
    
30
hgs
parents:
diff changeset
    59
    QStringList filesList;
36
hgs
parents: 30
diff changeset
    60
    filesList.insert( 0, QString::number( errorCode ) ); //result
hgs
parents: 30
diff changeset
    61
    doComplete( filesList );
30
hgs
parents:
diff changeset
    62
}
hgs
parents:
diff changeset
    63
hgs
parents:
diff changeset
    64
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    65
// complete()
hgs
parents:
diff changeset
    66
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    67
//
hgs
parents:
diff changeset
    68
void VideoServiceUriFetch::complete( QStringList filesList )
hgs
parents:
diff changeset
    69
{
36
hgs
parents: 30
diff changeset
    70
    MPX_ENTER_EXIT(_L("VideoServiceUriFetch::complete()"));
hgs
parents: 30
diff changeset
    71
	
hgs
parents: 30
diff changeset
    72
    doComplete( filesList );
30
hgs
parents:
diff changeset
    73
}
hgs
parents:
diff changeset
    74
hgs
parents:
diff changeset
    75
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    76
// doComplete()
hgs
parents:
diff changeset
    77
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    78
//
hgs
parents:
diff changeset
    79
void VideoServiceUriFetch::doComplete( QStringList filesList)
hgs
parents:
diff changeset
    80
{
36
hgs
parents: 30
diff changeset
    81
    MPX_ENTER_EXIT(_L("VideoServiceUriFetch::doComplete()"));
hgs
parents: 30
diff changeset
    82
        
30
hgs
parents:
diff changeset
    83
    if ( isActive() )
hgs
parents:
diff changeset
    84
    {
hgs
parents:
diff changeset
    85
        connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
36
hgs
parents: 30
diff changeset
    86
        bool ok = completeRequest(mRequestIndex, filesList);
30
hgs
parents:
diff changeset
    87
        mRequestIndex = 0;
36
hgs
parents: 30
diff changeset
    88
        
hgs
parents: 30
diff changeset
    89
		//
hgs
parents: 30
diff changeset
    90
        // double check that request was completed succesfully, otherwise
hgs
parents: 30
diff changeset
    91
        // videos application cannot be exited at all
hgs
parents: 30
diff changeset
    92
		//
hgs
parents: 30
diff changeset
    93
        if ( ! ok )
hgs
parents: 30
diff changeset
    94
        {
hgs
parents: 30
diff changeset
    95
            MPX_DEBUG(_L("VideoServiceUriFetch::doComplete() : completeRequest FAILED !"));  
hgs
parents: 30
diff changeset
    96
			              
hgs
parents: 30
diff changeset
    97
            qApp->quit();
hgs
parents: 30
diff changeset
    98
        }
30
hgs
parents:
diff changeset
    99
    }
hgs
parents:
diff changeset
   100
}
hgs
parents:
diff changeset
   101
hgs
parents:
diff changeset
   102
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   103
// isActive()
hgs
parents:
diff changeset
   104
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   105
//
hgs
parents:
diff changeset
   106
bool VideoServiceUriFetch::isActive()
hgs
parents:
diff changeset
   107
{
36
hgs
parents: 30
diff changeset
   108
    MPX_DEBUG(_L("VideoServiceUriFetch::isActive() ret %d"), mRequestIndex );
hgs
parents: 30
diff changeset
   109
	
30
hgs
parents:
diff changeset
   110
    return (mRequestIndex > 0);
hgs
parents:
diff changeset
   111
}
hgs
parents:
diff changeset
   112
hgs
parents:
diff changeset
   113
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   114
// VideoServiceUriFetch()
hgs
parents:
diff changeset
   115
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   116
//
hgs
parents:
diff changeset
   117
QString VideoServiceUriFetch::contextTitle() const
hgs
parents:
diff changeset
   118
{
36
hgs
parents: 30
diff changeset
   119
    MPX_DEBUG(_L("VideoServiceUriFetch::contextTitle() ret %s"), mTitle.data() );
hgs
parents: 30
diff changeset
   120
	
30
hgs
parents:
diff changeset
   121
    return mTitle;
hgs
parents:
diff changeset
   122
}
hgs
parents:
diff changeset
   123
hgs
parents:
diff changeset
   124
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   125
// fetch()
hgs
parents:
diff changeset
   126
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   127
//
hgs
parents:
diff changeset
   128
void VideoServiceUriFetch::fetch(const QString& title)
hgs
parents:
diff changeset
   129
{
36
hgs
parents: 30
diff changeset
   130
    MPX_ENTER_EXIT(_L("VideoServiceUriFetch::fetch()"),
hgs
parents: 30
diff changeset
   131
                   _L("title = %s"), title.data() );
hgs
parents: 30
diff changeset
   132
    
30
hgs
parents:
diff changeset
   133
    mTitle = title;
hgs
parents:
diff changeset
   134
    emit mServiceApp->activated(MpxHbVideoCommon::ActivateCollectionView);
hgs
parents:
diff changeset
   135
    emit mServiceApp->titleReady(title);
hgs
parents:
diff changeset
   136
hgs
parents:
diff changeset
   137
    mServiceApp->setCurrentService(VideoServices::EUriFetcher);
hgs
parents:
diff changeset
   138
hgs
parents:
diff changeset
   139
    mRequestIndex = setCurrentRequestAsync();
36
hgs
parents: 30
diff changeset
   140
    MPX_DEBUG(_L("VideoServiceUriFetch::fetch() : mRequestIndex(%d)"), mRequestIndex );
30
hgs
parents:
diff changeset
   141
}
hgs
parents:
diff changeset
   142