qtinternetradio/irhswidgetplugin/inc/irserviceclient.h
changeset 11 f683e24efca3
child 12 608f67c22514
equal deleted inserted replaced
8:3b03c28289e6 11:f683e24efca3
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: internet radio hs widget service client
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef IRSERVICECLIENT_H_
       
    19 #define IRSERVICECLIENT_H_
       
    20 
       
    21 // System includes
       
    22 #include <QObject>
       
    23 #include <xqappmgr.h>
       
    24 
       
    25 // User includes
       
    26 #include "irservicedef.h"
       
    27 #include "irappinspector.h"
       
    28 
       
    29 // Forward declarations
       
    30 class XQAiwRequest;
       
    31 class IrServiceData;
       
    32 class QString;
       
    33 class QVariant;
       
    34 
       
    35 class IrServiceClient : public QObject
       
    36 {
       
    37 Q_OBJECT
       
    38 
       
    39 public:
       
    40     explicit IrServiceClient(QObject *aParent = 0);
       
    41     virtual ~IrServiceClient();
       
    42 
       
    43 public:
       
    44     bool startMonitoringIrState();
       
    45     void stopMonitoringIrState();
       
    46 
       
    47     bool isStationPlayed();
       
    48     bool loadStationName(QString &aStationName);
       
    49     bool loadStationLogoFlag();    
       
    50     
       
    51     bool bringIrForeground();
       
    52     bool launchIrNormally();
       
    53     bool launchIrNowPlaying();
       
    54 
       
    55     bool startPlaying();
       
    56     bool stopPlaying();
       
    57     bool cancelLoading();
       
    58 
       
    59 signals:
       
    60     void stationNameUpdated(const QString &aStationName);
       
    61     void stationLogoUpdated(bool aIsLogoAvailable);
       
    62     void metaDataUpdated(const QString &aMetaData);
       
    63     void irStateChanged(IrAppState::Type aNewState);
       
    64     
       
    65     void controlFailed();
       
    66 
       
    67 private slots:
       
    68     // used for return value from Monitor Service via Qt HighWay
       
    69     void handleMonitorRequestOk(const QVariant &aRetValue);
       
    70     void handleMonitorRequestError(int aErrCode, const QString &aErrMessage);
       
    71 
       
    72     // used for return value from Control Service via Qt HighWay
       
    73     void handleControlRequestOk(const QVariant &aRetValue);
       
    74     void handleControlRequestError(int aErrCode, const QString &aErrMessage);
       
    75     
       
    76     // used for signals from IrAppInspector
       
    77     void handleIrRunningStatusChanged(IrAppInspector::IrRunningStatus aNewStatus);
       
    78 
       
    79 private:
       
    80     bool createControlServiceRequest();
       
    81     bool createMonitorServiceRequest();
       
    82     bool createRefreshServiceRequest();
       
    83 
       
    84     enum IrAppVisibilty
       
    85     {
       
    86         DoNotChange,
       
    87         ToForeground,
       
    88         ToBackground
       
    89     };
       
    90     
       
    91     bool doSendMonitorRequest();
       
    92     bool doSendRefreshRequest();
       
    93     bool doSendControlRequest(const QVariant &aArgument, bool aIsSync, IrAppVisibilty aVisibility);
       
    94     void prepareRequestInfo(XQAiwRequest *aRequest, IrAppVisibilty aVisibility);
       
    95     
       
    96     void processNotificationData(const IrServiceData &aServiceData);
       
    97     
       
    98     void initHsWidgetNoRunStopped();
       
    99     void resetHsWidgetExitStopped();
       
   100     
       
   101 private:    
       
   102     IrAppInspector   *mIrAppInspector;
       
   103     
       
   104     bool  mMonitorReqOngoing;
       
   105     bool  mControlReqOngoing;
       
   106     
       
   107     XQApplicationManager mApplicationManager;
       
   108     XQAiwRequest        *mMonitorRequest;
       
   109     XQAiwRequest        *mRefreshRequest;
       
   110     XQAiwRequest        *mControlRequest;
       
   111     
       
   112     Q_DISABLE_COPY(IrServiceClient)    
       
   113 };
       
   114 
       
   115 #endif /* IRSERVICECLIENT_H_ */