videoplayerapp/videoplayerengine/src/videoservicebrowse.cpp
author hgs
Thu, 24 Jun 2010 09:49:13 +0300
changeset 41 229f037ce963
parent 38 ff53afa8ad05
child 66 adb51f74b890
permissions -rw-r--r--
201025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36
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: 37
diff changeset
    18
// Version : %version: 4 %
36
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include <hbapplication.h>
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
#include "videoservices.h"
hgs
parents:
diff changeset
    23
#include "videoservicebrowse.h"
hgs
parents:
diff changeset
    24
#include "mpxhbvideocommondefs.h"
hgs
parents:
diff changeset
    25
#include "mpxvideo_debug.h"
38
hgs
parents: 37
diff changeset
    26
#include <xqaiwdecl.h>
36
hgs
parents:
diff changeset
    27
hgs
parents:
diff changeset
    28
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    29
// VideoServiceBrowse()
hgs
parents:
diff changeset
    30
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    31
//
38
hgs
parents: 37
diff changeset
    32
VideoServiceBrowse::VideoServiceBrowse(VideoServices* parent, QLatin1String service)
hgs
parents: 37
diff changeset
    33
    : XQServiceProvider( service, parent )
36
hgs
parents:
diff changeset
    34
    , mRequestIndex( 0 )
hgs
parents:
diff changeset
    35
    , mServiceApp( parent )
37
hgs
parents: 36
diff changeset
    36
    , mCategory( 0 )
hgs
parents: 36
diff changeset
    37
    , mTitle( "" )
hgs
parents: 36
diff changeset
    38
    , mSortRole( 0 )
36
hgs
parents:
diff changeset
    39
{
hgs
parents:
diff changeset
    40
    MPX_ENTER_EXIT(_L("VideoServiceBrowse::VideoServiceBrowse()"));
hgs
parents:
diff changeset
    41
hgs
parents:
diff changeset
    42
    publishAll();
hgs
parents:
diff changeset
    43
}
hgs
parents:
diff changeset
    44
hgs
parents:
diff changeset
    45
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    46
// ~VideoServiceBrowse()
hgs
parents:
diff changeset
    47
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    48
//
hgs
parents:
diff changeset
    49
VideoServiceBrowse::~VideoServiceBrowse()
hgs
parents:
diff changeset
    50
{
hgs
parents:
diff changeset
    51
    MPX_DEBUG(_L("VideoServiceBrowse::~VideoServiceBrowse()"));
hgs
parents:
diff changeset
    52
}
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    55
// complete()
hgs
parents:
diff changeset
    56
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    57
//
hgs
parents:
diff changeset
    58
void VideoServiceBrowse::complete()
hgs
parents:
diff changeset
    59
{
hgs
parents:
diff changeset
    60
    MPX_ENTER_EXIT(_L("VideoServiceBrowse::complete()"));	
hgs
parents:
diff changeset
    61
hgs
parents:
diff changeset
    62
    if ( mRequestIndex )
hgs
parents:
diff changeset
    63
    {
hgs
parents:
diff changeset
    64
        QStringList filesList;
hgs
parents:
diff changeset
    65
        connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
hgs
parents:
diff changeset
    66
        bool ok = completeRequest(mRequestIndex, filesList);
hgs
parents:
diff changeset
    67
        mRequestIndex = 0;
hgs
parents:
diff changeset
    68
        
hgs
parents:
diff changeset
    69
        //
hgs
parents:
diff changeset
    70
        // double check that request was completed succesfully, otherwise
hgs
parents:
diff changeset
    71
        // videos application cannot be exited at all
hgs
parents:
diff changeset
    72
        //
hgs
parents:
diff changeset
    73
        if ( ! ok )
hgs
parents:
diff changeset
    74
        {
hgs
parents:
diff changeset
    75
            MPX_DEBUG(_L("VideoServiceBrowse::complete() : completeRequest FAILED !"));
hgs
parents:
diff changeset
    76
            qApp->quit();
hgs
parents:
diff changeset
    77
        }
hgs
parents:
diff changeset
    78
    }
hgs
parents:
diff changeset
    79
}
hgs
parents:
diff changeset
    80
hgs
parents:
diff changeset
    81
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    82
// getBrowseCategory()
hgs
parents:
diff changeset
    83
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    84
//
hgs
parents:
diff changeset
    85
int VideoServiceBrowse::getBrowseCategory() const
hgs
parents:
diff changeset
    86
{
hgs
parents:
diff changeset
    87
    MPX_DEBUG(_L("VideoServiceBrowse::getBrowseCategory() ret %d"), mCategory);
hgs
parents:
diff changeset
    88
    return mCategory;
hgs
parents:
diff changeset
    89
}
hgs
parents:
diff changeset
    90
hgs
parents:
diff changeset
    91
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    92
// contextTitle()
hgs
parents:
diff changeset
    93
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    94
//
hgs
parents:
diff changeset
    95
QString VideoServiceBrowse::contextTitle() const
hgs
parents:
diff changeset
    96
{
hgs
parents:
diff changeset
    97
    MPX_DEBUG(_L("VideoServiceBrowse::contextTitle() ret %s"), mTitle.data() );
hgs
parents:
diff changeset
    98
    return mTitle;
hgs
parents:
diff changeset
    99
}
hgs
parents:
diff changeset
   100
hgs
parents:
diff changeset
   101
// -------------------------------------------------------------------------------------------------
37
hgs
parents: 36
diff changeset
   102
// sortRole()
hgs
parents: 36
diff changeset
   103
// -------------------------------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   104
//
hgs
parents: 36
diff changeset
   105
int VideoServiceBrowse::sortRole() const
hgs
parents: 36
diff changeset
   106
{
hgs
parents: 36
diff changeset
   107
    MPX_DEBUG(_L("VideoServiceBrowse::getBrowseCategory() ret %d"), mSortRole);
hgs
parents: 36
diff changeset
   108
    return mSortRole;
hgs
parents: 36
diff changeset
   109
}
hgs
parents: 36
diff changeset
   110
hgs
parents: 36
diff changeset
   111
// -------------------------------------------------------------------------------------------------
36
hgs
parents:
diff changeset
   112
// browseVideos()
hgs
parents:
diff changeset
   113
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   114
//
37
hgs
parents: 36
diff changeset
   115
void VideoServiceBrowse::browseVideos(const QString &title,
hgs
parents: 36
diff changeset
   116
    int category,
hgs
parents: 36
diff changeset
   117
    int sortRole)
36
hgs
parents:
diff changeset
   118
{    
hgs
parents:
diff changeset
   119
    MPX_ENTER_EXIT(_L("VideoServiceBrowse::browseVideos()"));	
hgs
parents:
diff changeset
   120
hgs
parents:
diff changeset
   121
    // set application title
hgs
parents:
diff changeset
   122
    QString appTitle(title);
hgs
parents:
diff changeset
   123
    if (appTitle.isEmpty())
hgs
parents:
diff changeset
   124
    {
hgs
parents:
diff changeset
   125
        appTitle = hbTrId("txt_videos_title_videos");
hgs
parents:
diff changeset
   126
    }
hgs
parents:
diff changeset
   127
    
hgs
parents:
diff changeset
   128
    mTitle = appTitle;
hgs
parents:
diff changeset
   129
    mCategory = category;
37
hgs
parents: 36
diff changeset
   130
    mSortRole = sortRole;
36
hgs
parents:
diff changeset
   131
38
hgs
parents: 37
diff changeset
   132
    // store async request id
hgs
parents: 37
diff changeset
   133
    mRequestIndex = setCurrentRequestAsync();
hgs
parents: 37
diff changeset
   134
36
hgs
parents:
diff changeset
   135
    // start service
hgs
parents:
diff changeset
   136
    mServiceApp->setCurrentService(VideoServices::EBrowse);
hgs
parents:
diff changeset
   137
    emit mServiceApp->titleReady(appTitle);
hgs
parents:
diff changeset
   138
    emit mServiceApp->activated(MpxHbVideoCommon::ActivateCollectionView);
hgs
parents:
diff changeset
   139
hgs
parents:
diff changeset
   140
    MPX_DEBUG(_L("VideoServiceBrowse::browseVideos() : mRequestIndex = %d"), mRequestIndex );
hgs
parents:
diff changeset
   141
}
hgs
parents:
diff changeset
   142
38
hgs
parents: 37
diff changeset
   143
// ----------------------------------------------------------------------------
hgs
parents: 37
diff changeset
   144
// isActive()
hgs
parents: 37
diff changeset
   145
// ----------------------------------------------------------------------------
hgs
parents: 37
diff changeset
   146
//
hgs
parents: 37
diff changeset
   147
bool VideoServiceBrowse::isActive()
hgs
parents: 37
diff changeset
   148
{
hgs
parents: 37
diff changeset
   149
    MPX_DEBUG(_L("VideoServiceBrowse::isActive() ret %d"), mRequestIndex );
hgs
parents: 37
diff changeset
   150
	
hgs
parents: 37
diff changeset
   151
    return (mRequestIndex > 0);
hgs
parents: 37
diff changeset
   152
}
hgs
parents: 37
diff changeset
   153
hgs
parents: 37
diff changeset
   154
// -------------------------------------------------------------------------------------------------
hgs
parents: 37
diff changeset
   155
// browseVideos()
hgs
parents: 37
diff changeset
   156
// -------------------------------------------------------------------------------------------------
hgs
parents: 37
diff changeset
   157
//
hgs
parents: 37
diff changeset
   158
void VideoServiceBrowse::browseVideos(int category, int sortRole)
hgs
parents: 37
diff changeset
   159
{    
hgs
parents: 37
diff changeset
   160
    MPX_ENTER_EXIT(_L("VideoServiceBrowse::browseVideos()"));	
hgs
parents: 37
diff changeset
   161
hgs
parents: 37
diff changeset
   162
    // set application title
hgs
parents: 37
diff changeset
   163
    XQRequestInfo info = requestInfo();
hgs
parents: 37
diff changeset
   164
    
hgs
parents: 37
diff changeset
   165
    QVariant variant = info.info("WindowTitle");
hgs
parents: 37
diff changeset
   166
    
hgs
parents: 37
diff changeset
   167
    QString appTitle;
hgs
parents: 37
diff changeset
   168
    
hgs
parents: 37
diff changeset
   169
    if(variant.isValid())
hgs
parents: 37
diff changeset
   170
    {
hgs
parents: 37
diff changeset
   171
    	appTitle = variant.toString();
hgs
parents: 37
diff changeset
   172
    }
hgs
parents: 37
diff changeset
   173
    
hgs
parents: 37
diff changeset
   174
    if (appTitle.isEmpty())
hgs
parents: 37
diff changeset
   175
    {
hgs
parents: 37
diff changeset
   176
        appTitle = hbTrId("txt_videos_title_videos");
hgs
parents: 37
diff changeset
   177
    }
hgs
parents: 37
diff changeset
   178
    
hgs
parents: 37
diff changeset
   179
    mTitle = appTitle;
hgs
parents: 37
diff changeset
   180
    mCategory = category;
hgs
parents: 37
diff changeset
   181
    mSortRole = sortRole;
hgs
parents: 37
diff changeset
   182
hgs
parents: 37
diff changeset
   183
    // store async request id
hgs
parents: 37
diff changeset
   184
    mRequestIndex = setCurrentRequestAsync();
hgs
parents: 37
diff changeset
   185
hgs
parents: 37
diff changeset
   186
    // start service
hgs
parents: 37
diff changeset
   187
    mServiceApp->setCurrentService(VideoServices::EBrowse);
hgs
parents: 37
diff changeset
   188
    emit mServiceApp->titleReady(appTitle);
hgs
parents: 37
diff changeset
   189
    emit mServiceApp->activated(MpxHbVideoCommon::ActivateCollectionView);
hgs
parents: 37
diff changeset
   190
hgs
parents: 37
diff changeset
   191
    MPX_DEBUG(_L("VideoServiceBrowse::browseVideos() : mRequestIndex = %d"), mRequestIndex );
hgs
parents: 37
diff changeset
   192
}
hgs
parents: 37
diff changeset
   193
hgs
parents: 37
diff changeset
   194
36
hgs
parents:
diff changeset
   195
// End of file