tvout/tvoutengine/src/glxtvconnectionmonitor.cpp
author hgs
Fri, 28 May 2010 21:11:54 +0530
changeset 43 72396548277c
parent 42 5e1df1b52eb3
child 52 a3a4c0de738e
permissions -rw-r--r--
201021
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:    Monitors the Tv Out Connection
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
//  CLASS HEADER
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include "glxtvconnectionmonitor.h"
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
//  EXTERNAL INCLUDES
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
//  INTERNAL INCLUDES
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <glxlog.h>
40
hgs
parents: 26
diff changeset
    28
#include <glxtracer.h>
hgs
parents: 26
diff changeset
    29
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include <glxpanic.h>
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "glxtv.h"
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include <AccPolGenericIdDefinitions.h>
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include <AccPolSubblockNameArray.h>
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
// Return new object
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
//
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
CGlxTvConnectionMonitor* CGlxTvConnectionMonitor::NewL(
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
                               MGlxTvConnectionObserver& aConnectionObserver ) 
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
    {
40
hgs
parents: 26
diff changeset
    41
    TRACER("CGlxTvConnectionMonitor::NewL");
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
    CGlxTvConnectionMonitor* self = new (ELeave) 
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
                CGlxTvConnectionMonitor( aConnectionObserver );
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
    CleanupStack::PushL( self );
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
    self->ConstructL();
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
    CleanupStack::Pop( self );
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
    return self;
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
    }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
    
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
// Destructor
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
//
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
CGlxTvConnectionMonitor::~CGlxTvConnectionMonitor()
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
    {
40
hgs
parents: 26
diff changeset
    57
    TRACER("~CGlxTvConnectionMonitor");
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
    Cancel();
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
    iTvAccCon.CloseSubSession();
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
    iTvAccServer.Disconnect();
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
    }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
// Default C++ constructor
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
//
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    68
CGlxTvConnectionMonitor::CGlxTvConnectionMonitor(
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    69
		MGlxTvConnectionObserver& aConnectionObserver) :
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    70
	CActive(EPriorityStandard), iConnectionObserver(aConnectionObserver),
43
hgs
parents: 42
diff changeset
    71
			iIsTvOutConnected(EFalse), iIsHDMIConnected(EFalse),
hgs
parents: 42
diff changeset
    72
			iIsHeadSetConnected(EFalse)
40
hgs
parents: 26
diff changeset
    73
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    74
	{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    75
	TRACER("CGlxTvConnectionMonitor");
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    76
	CActiveScheduler::Add(this);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    77
	}
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
// Symbian second phase constructor
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
//
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
void CGlxTvConnectionMonitor::ConstructL()
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
    {
40
hgs
parents: 26
diff changeset
    86
    TRACER("CGlxTvConnectionMonitor::ConstructL");
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    User::LeaveIfError(iTvAccServer.Connect());
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
	User::LeaveIfError(iTvAccCon.CreateSubSession(iTvAccServer));
40
hgs
parents: 26
diff changeset
    89
hgs
parents: 26
diff changeset
    90
	UpdateConnectionStatusL();
hgs
parents: 26
diff changeset
    91
	IssueRequest();  
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
// From class CActive.
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
// Receive notification of change in the connection state
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
//
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
void CGlxTvConnectionMonitor::RunL()
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
    {
40
hgs
parents: 26
diff changeset
   101
    TRACER("CGlxTvConnectionMonitor::RunL");
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
    // Check for errors
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
    User::LeaveIfError( iStatus.Int() );
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
    // Notify observers
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
    IssueNotificationL();
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
    // Request the next event
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    IssueRequest();  
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
// From class CActive.
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
// DoCancel
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
//
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
void CGlxTvConnectionMonitor::DoCancel()
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    {
40
hgs
parents: 26
diff changeset
   118
    TRACER("CGlxTvConnectionMonitor::DoCancel");
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    iTvAccCon.CancelGetAccessoryConnectionStatus();
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    iTvAccCon.CancelNotifyAccessoryConnectionStatusChanged();
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
// From class CActive.
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
// RunError
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
//
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
TInt CGlxTvConnectionMonitor::RunError(TInt aError)
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
    {
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
    GLX_LOG_INFO1("CGlxTvConnectionMonitor::RunError - %d", aError);
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    return KErrNone;
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
    }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
// Is the TV out cable connected
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
// IsConnected
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
//
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
TBool CGlxTvConnectionMonitor::IsConnected() const
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
    {
40
hgs
parents: 26
diff changeset
   143
    TRACER("CGlxTvConnectionMonitor::IsConnected");
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   144
    GLX_LOG_INFO1("CGlxTvConnectionMonitor::IsConnected iIsTvOutConnected=%d",iIsTvOutConnected);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   145
    return iIsTvOutConnected;
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
// Is the TV out cable connected
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
// IsConnected
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
//
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
TBool CGlxTvConnectionMonitor::IsHDMIConnected() const
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    {
40
hgs
parents: 26
diff changeset
   155
    TRACER("CGlxTvConnectionMonitor::IsHDMIConnected");
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   156
    GLX_LOG_INFO1("CGlxTvConnectionMonitor::IsHDMIConnected iIsHDMIConnected=%d",iIsHDMIConnected);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   157
    return iIsHDMIConnected;
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
// Request accessory server events
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
//
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
void CGlxTvConnectionMonitor::IssueRequest()
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    {
40
hgs
parents: 26
diff changeset
   166
    TRACER("CGlxTvConnectionMonitor::IssueRequest");
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    if (!IsActive()) // required for testing
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
        {
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
        iTvAccCon.NotifyAccessoryConnectionStatusChanged(iStatus,iCurrentAccArray);
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
        SetActive(); 
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
        }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
    }
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
// Sends notification to observers if TV Out is connected
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
//-----------------------------------------------------------------------------
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
//
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
void CGlxTvConnectionMonitor::IssueNotificationL()
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   179
	{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   180
	TRACER("CGlxTvConnectionMonitor::IssueNotificationL");
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   181
	TBool previousTvState = iIsTvOutConnected;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   182
	TBool previousHDMIState = iIsHDMIConnected;
43
hgs
parents: 42
diff changeset
   183
	TBool previousHeadSetState = iIsHeadSetConnected;
hgs
parents: 42
diff changeset
   184
	TTvChangeType changeType = EDisconnected;
hgs
parents: 42
diff changeset
   185
	
40
hgs
parents: 26
diff changeset
   186
	// Update the connection status
hgs
parents: 26
diff changeset
   187
	UpdateConnectionStatusL();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   188
40
hgs
parents: 26
diff changeset
   189
	// trigger tvstatus change only when there is actually a change the in the connection and not 
hgs
parents: 26
diff changeset
   190
	// for spurious events
43
hgs
parents: 42
diff changeset
   191
	if (previousTvState != iIsTvOutConnected)
hgs
parents: 42
diff changeset
   192
		{
hgs
parents: 42
diff changeset
   193
		changeType = iIsTvOutConnected == EFalse ? EDisconnected : ETvConnectionChanged;
hgs
parents: 42
diff changeset
   194
		GLX_LOG_INFO1("CGlxTvConnectionMonitor::IssueNotificationL - TVOut Connection Changed %d", changeType);
hgs
parents: 42
diff changeset
   195
		iConnectionObserver.HandleTvConnectionStatusChangedL(changeType);	
hgs
parents: 42
diff changeset
   196
		}
hgs
parents: 42
diff changeset
   197
	else if (previousHDMIState != iIsHDMIConnected)
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   198
		{
43
hgs
parents: 42
diff changeset
   199
		changeType = iIsHDMIConnected == EFalse ? EDisconnected : ETvConnectionChanged;
hgs
parents: 42
diff changeset
   200
		GLX_LOG_INFO1("CGlxTvConnectionMonitor::IssueNotificationL - HDMI Connection Changed %d", changeType);
hgs
parents: 42
diff changeset
   201
		iConnectionObserver.HandleTvConnectionStatusChangedL(changeType);	
hgs
parents: 42
diff changeset
   202
		}
hgs
parents: 42
diff changeset
   203
	else if (previousHeadSetState != iIsHeadSetConnected)
hgs
parents: 42
diff changeset
   204
		{
hgs
parents: 42
diff changeset
   205
		changeType = iIsHeadSetConnected == EFalse ? EDisconnected : ETvConnectionChanged;
hgs
parents: 42
diff changeset
   206
		GLX_LOG_INFO1("CGlxTvConnectionMonitor::IssueNotificationL - Headset Connection Changed %d", changeType);
hgs
parents: 42
diff changeset
   207
		iConnectionObserver.HandleTvConnectionStatusChangedL(changeType);	
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   208
		}
40
hgs
parents: 26
diff changeset
   209
	}
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
40
hgs
parents: 26
diff changeset
   211
//-----------------------------------------------------------------------------
hgs
parents: 26
diff changeset
   212
// UpdateConnectionStatusL()
hgs
parents: 26
diff changeset
   213
//-----------------------------------------------------------------------------
hgs
parents: 26
diff changeset
   214
//
hgs
parents: 26
diff changeset
   215
void CGlxTvConnectionMonitor::UpdateConnectionStatusL()
hgs
parents: 26
diff changeset
   216
    {
hgs
parents: 26
diff changeset
   217
    TRACER("CGlxTvConnectionMonitor::UpdateConnectionStatusL()");
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
43
hgs
parents: 42
diff changeset
   219
    GLX_LOG_INFO3("CGlxTvConnectionMonitor::UpdateConnectionStatusL previousTvState = %d , previousHDMIState = %d iIsHeadSetConnected=%d",
hgs
parents: 42
diff changeset
   220
            iIsTvOutConnected,iIsHDMIConnected,iIsHeadSetConnected);
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   221
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   222
    // reset the states
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   223
    iIsHDMIConnected = EFalse;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   224
    iIsTvOutConnected = EFalse;
43
hgs
parents: 42
diff changeset
   225
    iIsHeadSetConnected = EFalse;
40
hgs
parents: 26
diff changeset
   226
hgs
parents: 26
diff changeset
   227
    //gets the TV status in to the iCurrentAccArray and haves the Latest Accesory in 0-index
hgs
parents: 26
diff changeset
   228
    User::LeaveIfError(iTvAccCon.GetAccessoryConnectionStatus(iCurrentAccArray));
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
40
hgs
parents: 26
diff changeset
   230
    CAccPolSubblockNameArray* nameArray = CAccPolSubblockNameArray::NewL();
hgs
parents: 26
diff changeset
   231
    CleanupStack::PushL(nameArray);
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   232
40
hgs
parents: 26
diff changeset
   233
    //  Get the number of currently connected accessories
hgs
parents: 26
diff changeset
   234
    //  Loop through each connected accessory looking for
hgs
parents: 26
diff changeset
   235
    //  the desired capabilities
hgs
parents: 26
diff changeset
   236
    //
hgs
parents: 26
diff changeset
   237
    const TInt count = iCurrentAccArray.Count();
hgs
parents: 26
diff changeset
   238
    GLX_LOG_INFO1("CGlxTvConnectionMonitor::UpdateConnectionStatusL current count value is %d",count);
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   239
    for (TInt index = 0; index < count; index++)
40
hgs
parents: 26
diff changeset
   240
        {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   241
        const TAccPolGenericID genId = iCurrentAccArray.GetGenericIDL(index);
40
hgs
parents: 26
diff changeset
   242
        //  Check if this connected accessory supports TV-Out capabality.
hgs
parents: 26
diff changeset
   243
        GLX_LOG_INFO1("CGlxTvConnectionMonitor::UpdateConnectionStatusL current index value is %d",index);
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   244
        GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL Video Accessory Supported");
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   245
        TAccPolNameRecord nameRecord;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   246
        nameRecord.SetNameL(KAccVideoOut);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   247
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   248
        if (genId.DeviceTypeCaps( KDTAVDevice ) &&
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   249
                genId.PhysicalConnectionCaps( KPCHDMI ))
40
hgs
parents: 26
diff changeset
   250
            {
hgs
parents: 26
diff changeset
   251
            TAccValueTypeTInt value;
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   252
            TInt err = iTvAccCon.GetValueL(genId, nameRecord, value);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   253
            if (err ==KErrNone)
40
hgs
parents: 26
diff changeset
   254
                {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   255
                if (value.iValue == EAccVideoOutEHDMI)
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   256
                    {
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   257
                    GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL HDMI is connected");
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   258
                    iIsHDMIConnected = ETrue;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   259
                    }
40
hgs
parents: 26
diff changeset
   260
                }
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   261
            }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   262
        else if (genId.DeviceTypeCaps( KDTAVDevice ) &&
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   263
                genId.PhysicalConnectionCaps( KPCWired ))
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   264
            {
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   265
            TAccValueTypeTInt value;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   266
            TInt err = iTvAccCon.GetValueL(genId, nameRecord, value);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   267
            if (err ==KErrNone)
40
hgs
parents: 26
diff changeset
   268
                {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   269
                if (value.iValue == EAccVideoOutCVideo)
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   270
                    {
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   271
                    GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL Tv is connected");
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   272
                    iIsTvOutConnected = ETrue;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   273
                    }
40
hgs
parents: 26
diff changeset
   274
                }
hgs
parents: 26
diff changeset
   275
            }
43
hgs
parents: 42
diff changeset
   276
		else if (genId.DeviceTypeCaps(KDTHeadset)
hgs
parents: 42
diff changeset
   277
				&& genId.PhysicalConnectionCaps(KPCWired))
hgs
parents: 42
diff changeset
   278
			{
hgs
parents: 42
diff changeset
   279
			GLX_LOG_INFO("CGlxTvConnectionMonitor::UpdateConnectionStatusL HeadSet connect");
hgs
parents: 42
diff changeset
   280
			iIsHeadSetConnected = ETrue;
hgs
parents: 42
diff changeset
   281
			}
hgs
parents: 42
diff changeset
   282
		}
40
hgs
parents: 26
diff changeset
   283
    CleanupStack::PopAndDestroy(nameArray);
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
43
hgs
parents: 42
diff changeset
   285
    GLX_LOG_INFO3("CGlxTvConnectionMonitor::UpdateConnectionStatusL CurrentTvState = %d , CurrentHDMIState = %d, iIsHeadSetConnected=%d",
hgs
parents: 42
diff changeset
   286
            iIsTvOutConnected,iIsHDMIConnected,iIsHeadSetConnected);
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
    }