mpxplugins/viewplugins/plugins/upnpbrowsedialogplugin/src/mpxupnpbrowsedialogplugin.cpp
changeset 0 ff3acec5bc43
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of UPnP browse dialog plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <StringLoader.h>
       
    22 #include "mpxupnpbrowsedialog.h"
       
    23 #include <mpxcustomcommandobserver.h>
       
    24 #include <mpxviewutilitycommanddef.h>
       
    25 #include <mpxmusicplayerviewplugin.hrh>
       
    26 
       
    27 #include "mpxupnpbrowsedialogplugin.h"
       
    28 
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CMPXUPnPBrowseDialogPlugin::CMPXUPnPBrowseDialogPlugin()
       
    38     {
       
    39     // Do nothing
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // Symbian 2nd phase constructor can leave.
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 void CMPXUPnPBrowseDialogPlugin::ConstructL()
       
    47     {
       
    48         // Get an instance of view utility
       
    49     iPlayerUid = 0;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // Two-phased constructor.
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CMPXUPnPBrowseDialogPlugin* CMPXUPnPBrowseDialogPlugin::NewL()
       
    57     {
       
    58     CMPXUPnPBrowseDialogPlugin* self = 
       
    59         new ( ELeave ) CMPXUPnPBrowseDialogPlugin();
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL();
       
    62     CleanupStack::Pop( self );
       
    63     return self;
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // Destructor
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 CMPXUPnPBrowseDialogPlugin::~CMPXUPnPBrowseDialogPlugin()
       
    71     {
       
    72     // Do nothing
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // From CMPXAknDialogPlugin
       
    77 // Construct Avkon dialog.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 CAknDialog* CMPXUPnPBrowseDialogPlugin::ConstructDialogL()
       
    81     {
       
    82     return CMPXUPnPBrowseDialog::NewL(0);
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // From CMPXViewPlugin
       
    87 // Interface method to activate view.
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 void CMPXUPnPBrowseDialogPlugin::ActivateViewL(
       
    91     const TDesC* aParam )
       
    92     {
       
    93     if ( !iDialog )
       
    94         {
       
    95         CreateViewL();
       
    96         }
       
    97 
       
    98     // Translate the desc param into a Uid int
       
    99     HBufC* buf = HBufC::NewLC(aParam->Length());
       
   100     (buf->Des()).Copy(*aParam);
       
   101 
       
   102     TLex resDT( *buf );
       
   103     resDT.Val( iPlayerUid );
       
   104     CleanupStack::PopAndDestroy(buf);
       
   105     
       
   106     // Launch the dialog
       
   107     TInt selectedSubPlayer = iDialog->ExecuteLD(iPlayerUid);
       
   108     if ( iCommandObserver )
       
   109         {
       
   110         TPckgC<TInt> selfPtr( reinterpret_cast<TInt>( this ) );    
       
   111         iCommandObserver->HandleCustomCommand( 
       
   112             TUid::Uid( KMPXViewUtilityCustomCommand ), 
       
   113             EMPXViewUtilCmdViewDeActivated,
       
   114             selfPtr );
       
   115         }
       
   116     delete iDialog;
       
   117     iDialog = NULL;
       
   118 
       
   119     // if selectedSubPlayer is KErrCancel, dialog was cancelled
       
   120     if ( selectedSubPlayer >= 0 )
       
   121         {
       
   122         HBufC* buf = HBufC::NewLC( 20 ); // magic number
       
   123         buf->Des().AppendNum( selectedSubPlayer );
       
   124         CleanupStack::PopAndDestroy( buf );
       
   125         }
       
   126     else
       
   127         {
       
   128         User::LeaveIfError(selectedSubPlayer);
       
   129         }
       
   130     }
       
   131     
       
   132 // ---------------------------------------------------------------------------
       
   133 // From CMPXAknDialogPlugin
       
   134 // Resource ID.
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 TInt CMPXUPnPBrowseDialogPlugin::ResourceId()
       
   138     {
       
   139     return 0;
       
   140     }    
       
   141 
       
   142 //  End of File