videoplayerapp/videoplayerengine/src/videoserviceurifetch.cpp
author hgs
Fri, 14 May 2010 15:14:51 +0300
changeset 38 ff53afa8ad05
parent 36 8aed59de29f9
child 66 adb51f74b890
permissions -rw-r--r--
201019
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
38
hgs
parents: 36
diff changeset
    18
// Version : %version: 5 %
36
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"
38
hgs
parents: 36
diff changeset
    26
#include <xqaiwdecl.h>
30
hgs
parents:
diff changeset
    27
hgs
parents:
diff changeset
    28
hgs
parents:
diff changeset
    29
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    30
// VideoServiceUriFetch()
hgs
parents:
diff changeset
    31
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    32
//
38
hgs
parents: 36
diff changeset
    33
VideoServiceUriFetch::VideoServiceUriFetch(VideoServices* parent, QLatin1String service)
hgs
parents: 36
diff changeset
    34
    : XQServiceProvider( service, parent )
36
hgs
parents: 30
diff changeset
    35
    , mRequestIndex( 0 )
hgs
parents: 30
diff changeset
    36
    , mServiceApp( parent )
30
hgs
parents:
diff changeset
    37
{
36
hgs
parents: 30
diff changeset
    38
    MPX_ENTER_EXIT(_L("VideoServiceUriFetch::VideoServiceUriFetch()"));
30
hgs
parents:
diff changeset
    39
	publishAll();
hgs
parents:
diff changeset
    40
}
hgs
parents:
diff changeset
    41
hgs
parents:
diff changeset
    42
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    43
// ~VideoServiceUriFetch()
hgs
parents:
diff changeset
    44
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    45
//
hgs
parents:
diff changeset
    46
VideoServiceUriFetch::~VideoServiceUriFetch()
hgs
parents:
diff changeset
    47
{
36
hgs
parents: 30
diff changeset
    48
    MPX_DEBUG(_L("VideoServiceUriFetch::~VideoServiceUriFetch()"));
30
hgs
parents:
diff changeset
    49
}
hgs
parents:
diff changeset
    50
hgs
parents:
diff changeset
    51
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    52
// fetchFailed()
hgs
parents:
diff changeset
    53
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    54
//
hgs
parents:
diff changeset
    55
void VideoServiceUriFetch::fetchFailed( int errorCode )
hgs
parents:
diff changeset
    56
{
36
hgs
parents: 30
diff changeset
    57
    MPX_ENTER_EXIT(_L("VideoServiceUriFetch::fetchFailed()"),
hgs
parents: 30
diff changeset
    58
                   _L("errorCode = %d"), errorCode );
hgs
parents: 30
diff changeset
    59
    
30
hgs
parents:
diff changeset
    60
    QStringList filesList;
36
hgs
parents: 30
diff changeset
    61
    filesList.insert( 0, QString::number( errorCode ) ); //result
hgs
parents: 30
diff changeset
    62
    doComplete( filesList );
30
hgs
parents:
diff changeset
    63
}
hgs
parents:
diff changeset
    64
hgs
parents:
diff changeset
    65
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    66
// complete()
hgs
parents:
diff changeset
    67
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    68
//
hgs
parents:
diff changeset
    69
void VideoServiceUriFetch::complete( QStringList filesList )
hgs
parents:
diff changeset
    70
{
36
hgs
parents: 30
diff changeset
    71
    MPX_ENTER_EXIT(_L("VideoServiceUriFetch::complete()"));
hgs
parents: 30
diff changeset
    72
	
hgs
parents: 30
diff changeset
    73
    doComplete( filesList );
30
hgs
parents:
diff changeset
    74
}
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    77
// doComplete()
hgs
parents:
diff changeset
    78
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
    79
//
hgs
parents:
diff changeset
    80
void VideoServiceUriFetch::doComplete( QStringList filesList)
hgs
parents:
diff changeset
    81
{
36
hgs
parents: 30
diff changeset
    82
    MPX_ENTER_EXIT(_L("VideoServiceUriFetch::doComplete()"));
hgs
parents: 30
diff changeset
    83
        
30
hgs
parents:
diff changeset
    84
    if ( isActive() )
hgs
parents:
diff changeset
    85
    {
hgs
parents:
diff changeset
    86
        connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
36
hgs
parents: 30
diff changeset
    87
        bool ok = completeRequest(mRequestIndex, filesList);
30
hgs
parents:
diff changeset
    88
        mRequestIndex = 0;
36
hgs
parents: 30
diff changeset
    89
        
hgs
parents: 30
diff changeset
    90
		//
hgs
parents: 30
diff changeset
    91
        // double check that request was completed succesfully, otherwise
hgs
parents: 30
diff changeset
    92
        // videos application cannot be exited at all
hgs
parents: 30
diff changeset
    93
		//
hgs
parents: 30
diff changeset
    94
        if ( ! ok )
hgs
parents: 30
diff changeset
    95
        {
hgs
parents: 30
diff changeset
    96
            MPX_DEBUG(_L("VideoServiceUriFetch::doComplete() : completeRequest FAILED !"));  
hgs
parents: 30
diff changeset
    97
			              
hgs
parents: 30
diff changeset
    98
            qApp->quit();
hgs
parents: 30
diff changeset
    99
        }
30
hgs
parents:
diff changeset
   100
    }
hgs
parents:
diff changeset
   101
}
hgs
parents:
diff changeset
   102
hgs
parents:
diff changeset
   103
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   104
// isActive()
hgs
parents:
diff changeset
   105
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   106
//
hgs
parents:
diff changeset
   107
bool VideoServiceUriFetch::isActive()
hgs
parents:
diff changeset
   108
{
36
hgs
parents: 30
diff changeset
   109
    MPX_DEBUG(_L("VideoServiceUriFetch::isActive() ret %d"), mRequestIndex );
hgs
parents: 30
diff changeset
   110
	
30
hgs
parents:
diff changeset
   111
    return (mRequestIndex > 0);
hgs
parents:
diff changeset
   112
}
hgs
parents:
diff changeset
   113
hgs
parents:
diff changeset
   114
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   115
// VideoServiceUriFetch()
hgs
parents:
diff changeset
   116
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   117
//
hgs
parents:
diff changeset
   118
QString VideoServiceUriFetch::contextTitle() const
hgs
parents:
diff changeset
   119
{
36
hgs
parents: 30
diff changeset
   120
    MPX_DEBUG(_L("VideoServiceUriFetch::contextTitle() ret %s"), mTitle.data() );
hgs
parents: 30
diff changeset
   121
	
30
hgs
parents:
diff changeset
   122
    return mTitle;
hgs
parents:
diff changeset
   123
}
hgs
parents:
diff changeset
   124
hgs
parents:
diff changeset
   125
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   126
// fetch()
hgs
parents:
diff changeset
   127
// ----------------------------------------------------------------------------
hgs
parents:
diff changeset
   128
//
38
hgs
parents: 36
diff changeset
   129
void VideoServiceUriFetch::fetch()
hgs
parents: 36
diff changeset
   130
{
hgs
parents: 36
diff changeset
   131
	MPX_ENTER_EXIT(_L("VideoServiceUriFetch::fetch()"));
hgs
parents: 36
diff changeset
   132
hgs
parents: 36
diff changeset
   133
	emit mServiceApp->activated(MpxHbVideoCommon::ActivateCollectionView);
hgs
parents: 36
diff changeset
   134
    
hgs
parents: 36
diff changeset
   135
    XQRequestInfo info = requestInfo();
hgs
parents: 36
diff changeset
   136
    
hgs
parents: 36
diff changeset
   137
    QVariant variant = info.info("WindowTitle");
hgs
parents: 36
diff changeset
   138
    
hgs
parents: 36
diff changeset
   139
    if(variant.isValid())
hgs
parents: 36
diff changeset
   140
    {
hgs
parents: 36
diff changeset
   141
    	mTitle = variant.toString();
hgs
parents: 36
diff changeset
   142
    }
hgs
parents: 36
diff changeset
   143
    
hgs
parents: 36
diff changeset
   144
    if (mTitle.isEmpty())
hgs
parents: 36
diff changeset
   145
    {
hgs
parents: 36
diff changeset
   146
    	mTitle = hbTrId("txt_videos_title_videos");
hgs
parents: 36
diff changeset
   147
    }
hgs
parents: 36
diff changeset
   148
hgs
parents: 36
diff changeset
   149
	emit mServiceApp->titleReady(mTitle);
hgs
parents: 36
diff changeset
   150
    mServiceApp->setCurrentService(VideoServices::EUriFetcher);
hgs
parents: 36
diff changeset
   151
hgs
parents: 36
diff changeset
   152
    mRequestIndex = setCurrentRequestAsync();
hgs
parents: 36
diff changeset
   153
    MPX_DEBUG(_L("VideoServiceUriFetch::fetch() : mRequestIndex(%d)"), mRequestIndex );
hgs
parents: 36
diff changeset
   154
}
hgs
parents: 36
diff changeset
   155
hgs
parents: 36
diff changeset
   156
// ----------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   157
// fetch()
hgs
parents: 36
diff changeset
   158
// ----------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   159
//
30
hgs
parents:
diff changeset
   160
void VideoServiceUriFetch::fetch(const QString& title)
hgs
parents:
diff changeset
   161
{
38
hgs
parents: 36
diff changeset
   162
	MPX_ENTER_EXIT(_L("VideoServiceUriFetch::fetch()"),
36
hgs
parents: 30
diff changeset
   163
                   _L("title = %s"), title.data() );
hgs
parents: 30
diff changeset
   164
    
38
hgs
parents: 36
diff changeset
   165
    emit mServiceApp->activated(MpxHbVideoCommon::ActivateCollectionView);
hgs
parents: 36
diff changeset
   166
30
hgs
parents:
diff changeset
   167
    mTitle = title;
38
hgs
parents: 36
diff changeset
   168
hgs
parents: 36
diff changeset
   169
    if (mTitle.isEmpty())
hgs
parents: 36
diff changeset
   170
    {
hgs
parents: 36
diff changeset
   171
    	mTitle = hbTrId("txt_videos_title_videos");
hgs
parents: 36
diff changeset
   172
    }
hgs
parents: 36
diff changeset
   173
hgs
parents: 36
diff changeset
   174
   	emit mServiceApp->titleReady(mTitle);
30
hgs
parents:
diff changeset
   175
hgs
parents:
diff changeset
   176
    mServiceApp->setCurrentService(VideoServices::EUriFetcher);
hgs
parents:
diff changeset
   177
hgs
parents:
diff changeset
   178
    mRequestIndex = setCurrentRequestAsync();
36
hgs
parents: 30
diff changeset
   179
    MPX_DEBUG(_L("VideoServiceUriFetch::fetch() : mRequestIndex(%d)"), mRequestIndex );
30
hgs
parents:
diff changeset
   180
}
hgs
parents:
diff changeset
   181