mpx/viewframework/viewutility/src/mpxviewplugininfo.cpp
changeset 0 a2952bb97e68
child 48 b7b49303d0c0
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     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 view plugin info
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <mpxviewplugin.hrh>
       
    22 
       
    23 #include "mpxviewutilityhelper.h"
       
    24 #include "mpxviewplugininfo.h"
       
    25 #include "mpxlog.h"
       
    26 
       
    27 
       
    28 // CONSTANTS
       
    29 _LIT8( KMPXPluginUidMarkerStart, "<p>" );
       
    30 _LIT8( KMPXPluginUidMarkerEnd, "</p>" );
       
    31 _LIT8( KMPXPluginTypeMarkerStart, "<t>" );
       
    32 _LIT8( KMPXPluginTypeMarkerEnd, "</t>" );
       
    33 _LIT8( KMPXPluginFlagMarkerStart, "<f>" );
       
    34 _LIT8( KMPXPluginFlagMarkerEnd, "</f>" );
       
    35 _LIT8( KMPXPluginPriorityMarkerStart, "<i>" );
       
    36 _LIT8( KMPXPluginPriorityMarkerEnd, "</i>" );
       
    37 
       
    38 // ======== MEMBER FUNCTIONS ========
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // C++ default constructor can NOT contain any code, that
       
    42 // might leave.
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CMPXViewPluginInfo::CMPXViewPluginInfo()
       
    46     {
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // By default Symbian 2nd phase constructor is private.
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 void CMPXViewPluginInfo::ConstructL( 
       
    54     const CImplementationInformation& aData )
       
    55     {
       
    56     iPluginName = aData.DisplayName().AllocL();
       
    57     iPluginUid = aData.ImplementationUid();
       
    58     iPluginTypeUid = ExtractPluginType( aData.OpaqueData() );
       
    59     iFlags = ExtractPluginFlags( aData.OpaqueData() );
       
    60     iPriority = ExtractPluginPriority( aData.OpaqueData() );
       
    61     ExtractPluginUidsL( aData.OpaqueData(), iSupportedUids );
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // Two-phased constructor.
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 CMPXViewPluginInfo* CMPXViewPluginInfo::NewL( 
       
    69     const CImplementationInformation& aData )
       
    70     {
       
    71     CMPXViewPluginInfo* self = CMPXViewPluginInfo::NewLC( aData );
       
    72     CleanupStack::Pop( self );
       
    73 
       
    74     return self;
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // Two-phased constructor.
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 CMPXViewPluginInfo* CMPXViewPluginInfo::NewLC( 
       
    82     const CImplementationInformation& aData )
       
    83     {
       
    84     CMPXViewPluginInfo* self = new ( ELeave ) CMPXViewPluginInfo();
       
    85     CleanupStack::PushL( self );
       
    86     self->ConstructL( aData );
       
    87 
       
    88     return self;
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // Destructor
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 CMPXViewPluginInfo::~CMPXViewPluginInfo()
       
    96     {
       
    97     delete iPluginName;
       
    98     iSupportedUids.Close();
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // Returns plugin's display name.
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 const TDesC& CMPXViewPluginInfo::DisplayName() const
       
   106     {
       
   107     return iPluginName ? static_cast<const TDesC&>( *iPluginName ) : KNullDesC;
       
   108     }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // Returns plugin's implementation uid.
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 const TUid& CMPXViewPluginInfo::ImplementationUid() const
       
   115     {
       
   116     return iPluginUid;
       
   117     }
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // Returns plugin's supported uids.
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 const RArray<TUid> CMPXViewPluginInfo::SupportedUids() const
       
   124     {
       
   125     return iSupportedUids;
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // Returns plugin's plugin type.
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 const TUid& CMPXViewPluginInfo::PluginType() const
       
   133     {
       
   134     return iPluginTypeUid;
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // Returns plugin's view priority.
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 TInt CMPXViewPluginInfo::Priority() const
       
   142     {
       
   143     return iPriority;
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // Test whether the plugin is user selectable.
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 TBool CMPXViewPluginInfo::IsUserSelectable() const
       
   151     {
       
   152     return iFlags & KMPXVpFeatureUserSelectable;
       
   153     }
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 // Test whether the plugin needs to be preloaded.
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 TBool CMPXViewPluginInfo::IsPreLoad() const
       
   160     {
       
   161     return iFlags & KMPXVpFeaturePreLoaded;
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // Extracts plugin priority from data.
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 TInt CMPXViewPluginInfo::ExtractPluginPriority( 
       
   169     const TDesC8& aData )
       
   170     {
       
   171     TInt ignore( 0 );
       
   172     TInt priority( 0 );
       
   173     TPtrC8 string =
       
   174         CMPXViewUtilityHelper::Extract( 
       
   175             aData, 
       
   176             KMPXPluginPriorityMarkerStart, 
       
   177             KMPXPluginPriorityMarkerEnd );
       
   178 
       
   179     CMPXViewUtilityHelper::ExtractNum( string, ignore, priority );
       
   180 
       
   181     return priority;
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // Extracts plugin supported Uids from data.
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 void CMPXViewPluginInfo::ExtractPluginUidsL( 
       
   189     const TDesC8& aData,
       
   190     RArray<TUid>& aArray )
       
   191     {
       
   192     aArray.Reset();
       
   193 
       
   194     TInt nextPos( 0 );
       
   195     TInt pluginUid( 0 );
       
   196     TPtrC8 string =
       
   197         CMPXViewUtilityHelper::Extract( 
       
   198             aData, KMPXPluginUidMarkerStart, KMPXPluginUidMarkerEnd );
       
   199 
       
   200     do
       
   201         {
       
   202         if ( KErrNone == 
       
   203             CMPXViewUtilityHelper::ExtractNum( string, nextPos, pluginUid ) )
       
   204             {
       
   205             aArray.AppendL( TUid::Uid( pluginUid ) );
       
   206             }
       
   207         } while ( KErrNotFound != nextPos );
       
   208     }
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // Extracts plugin type from data.
       
   212 // ---------------------------------------------------------------------------
       
   213 //
       
   214 TUid CMPXViewPluginInfo::ExtractPluginType( 
       
   215     const TDesC8& aData )
       
   216     {
       
   217     TInt ignore( 0 );
       
   218     TInt type( 0 );
       
   219     TPtrC8 string =
       
   220         CMPXViewUtilityHelper::Extract( 
       
   221             aData, KMPXPluginTypeMarkerStart, KMPXPluginTypeMarkerEnd );
       
   222 
       
   223     CMPXViewUtilityHelper::ExtractNum( string, ignore, type );
       
   224 
       
   225     return TUid::Uid( type );
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // Extracts plugin feature flags from data.
       
   230 // ---------------------------------------------------------------------------
       
   231 //
       
   232 TInt CMPXViewPluginInfo::ExtractPluginFlags( 
       
   233     const TDesC8& aData )
       
   234     {
       
   235     TInt ignore( 0 );
       
   236     TInt flags( 0 );
       
   237     TPtrC8 string =
       
   238         CMPXViewUtilityHelper::Extract( 
       
   239             aData, KMPXPluginFlagMarkerStart, KMPXPluginFlagMarkerEnd );
       
   240 
       
   241     CMPXViewUtilityHelper::ExtractNum( string, ignore, flags );
       
   242 
       
   243     return flags;
       
   244     }
       
   245 
       
   246 //  End of File