usbuis/usbuinotif/src/usbuinmain.cpp
author William Roberts <williamr@symbian.org>
Thu, 22 Jul 2010 16:44:03 +0100
branchGCC_SURGE
changeset 63 ef2686f7597e
parent 25 8c311f9acc5e
parent 38 218231f2b3b3
permissions -rw-r--r--
Catchup to latest Symbian^4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
 *
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
 *
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
 * Contributors:
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
 *
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
 * Description:  Methods for USB UI notifiers
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
 *
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
 */
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
// INCLUDE FILES
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
#include <ecom/ecom.h>
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#include <ecom/implementationproxy.h>
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#include <eiknotapi.h>
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include "usbuincableconnectednotifier.h"
38
218231f2b3b3 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
    24
#include "usbuinqueriesnotifiermdrv.h"
35
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
#include "usbuinotifdebug.h"
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include "usbuinotifotgwarning.h"    
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
#include "usbuinotifotgerror.h"    
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
#include "usbuinotifmsmmerror.h" 
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
// CONSTANTS
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
const TInt KUSBUINotifierArrayIncrement = 5;
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
// ================= EXPORTED FUNCTIONS =======================================
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
// ----------------------------------------------------------------------------
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
//
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
// Instantiate notifiers
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
//
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
// ----------------------------------------------------------------------------
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
void CreateUSBUINotifiersL(CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers)
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
    {
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
    FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL"));
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
    CUSBUICableConnectedNotifier* cableConnectedNotifier =
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
        CUSBUICableConnectedNotifier::NewL();
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
    CleanupStack::PushL( cableConnectedNotifier );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
    aNotifiers->AppendL( cableConnectedNotifier );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
    CleanupStack::Pop( cableConnectedNotifier );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
    CUSBUIQueriesNotifier* queriesNotifier = CUSBUIQueriesNotifier::NewL();
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
    CleanupStack::PushL( queriesNotifier );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
    aNotifiers->AppendL( queriesNotifier );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
    CleanupStack::Pop( queriesNotifier );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
    CUsbUiNotifOtgWarning* generalNote = CUsbUiNotifOtgWarning::NewL();
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
    CleanupStack::PushL( generalNote );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
    aNotifiers->AppendL( generalNote );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
    CleanupStack::Pop( generalNote );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
    CUsbUiNotifOtgError* generalQuery = CUsbUiNotifOtgError::NewL();
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
    CleanupStack::PushL( generalQuery );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
    aNotifiers->AppendL( generalQuery );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
    CleanupStack::Pop( generalQuery );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
    
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
    CUsbUiNotifMSMMError* msmmerrorQuery = CUsbUiNotifMSMMError::NewL();
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
    CleanupStack::PushL( msmmerrorQuery );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
    aNotifiers->AppendL( msmmerrorQuery );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
    CleanupStack::Pop( msmmerrorQuery );
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
    FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL completed"));
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
    }
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
// ----------------------------------------------------------------------------
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
// Creates a notifiers array.
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
// ----------------------------------------------------------------------------
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
    {
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
    FLOG(_L("[USBUINOTIF]\t NotifierArray"));
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
    CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers = NULL;
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
    TRAPD( err, notifiers =
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
            new (ELeave)CArrayPtrFlat<MEikSrvNotifierBase2>(
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
                    KUSBUINotifierArrayIncrement ));
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
    if (err == KErrNone)
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
        {
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
        if (notifiers)
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
            {
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
            TRAPD( errCreate, CreateUSBUINotifiersL( notifiers ));
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
            if (errCreate)
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
                {
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
                TInt count = notifiers->Count();
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
                while (count--)
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
                    {
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
                    (*notifiers)[count]->Release();
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
                    }
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
                delete notifiers;
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
                notifiers = NULL;
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
                }
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
            FLOG(_L("[USBUINOTIF]\t NotifierArray completed"));
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
            }
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
        }
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
    else
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
        {
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
        FLOG(_L("[USBUINOTIF]\t NotifierArray Failed!!!"));
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
        }
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
    return notifiers;
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
    }
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
// ----------------------------------------------------------------------------
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
// ECOM 
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
// ----------------------------------------------------------------------------
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
const TImplementationProxy ImplementationTable[] =
38
218231f2b3b3 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   117
{
35
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
    IMPLEMENTATION_PROXY_ENTRY( 0x10281F23, NotifierArray )
38
218231f2b3b3 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 35
diff changeset
   119
};
35
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
        TInt& aTableCount)
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
    {
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
    FLOG(_L("[USBUINOTIF]\t ImplementationGroupProxy"));
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
    return ImplementationTable;
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
    }
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
9d8b04ca6939 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
//  End of File