idlehomescreen/nativeuicontroller/src/ainativerenderer.cpp
branchRCL_3
changeset 9 f966699dea19
parent 0 f72a12da539e
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
    13 *
    13 *
    14 * Description:  
    14 * Description:  
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 // System includes
    19 #include <aipropertyextension.h>
    19 
       
    20 // User includes
       
    21 #include <hscontentpublisher.h>
       
    22 #include <hspublisherinfo.h>
       
    23 
    20 #include "ainativerenderer.h"
    24 #include "ainativerenderer.h"
    21 #include "ainativeuiplugins.h"
    25 #include "ainativeuiplugins.h"
    22 
    26 
    23 using namespace AiNativeUiController;
    27 using namespace AiNativeUiController;
    24 
    28 
    25 
    29 // ======== MEMBER FUNCTIONS ========
       
    30 // ----------------------------------------------------------------------------
       
    31 // CAiNativeRenderer::CAiNativeRenderer()
       
    32 //
       
    33 // ----------------------------------------------------------------------------
       
    34 //
    26 CAiNativeRenderer::~CAiNativeRenderer()
    35 CAiNativeRenderer::~CAiNativeRenderer()
    27     {
    36     {
    28     }
    37     }
    29 
    38 
    30     
    39 // ----------------------------------------------------------------------------
    31 TInt CAiNativeRenderer::Publish( MAiPropertyExtension& aPlugin, TInt aContent, 
    40 // CAiNativeRenderer::Publish()
    32 									TInt aResource, TInt aIndex )
    41 //
       
    42 // ----------------------------------------------------------------------------
       
    43 //    
       
    44 TInt CAiNativeRenderer::Publish( CHsContentPublisher& aPlugin, TInt aContent, 
       
    45     TInt aResource, TInt aIndex )
    33     {
    46     {
    34     TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) );
    47     TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) );
    35     
    48     
    36     if( err != KErrNone )
    49     if( err != KErrNone )
    37         {
    50         {
    38         return err;
    51         return err;
    39         }
    52         }
    40         
    53         
    41     TRAP( err, DoPublishL( aPlugin, aContent, aResource, aIndex ) );
    54     TRAP( err, DoPublishL( aPlugin, aContent, aResource, aIndex ) );
    42     return err;
    55     
    43     }
    56     return err;
    44     
    57     }
    45     
    58     
    46 TInt CAiNativeRenderer::Publish( MAiPropertyExtension& aPlugin, TInt aContent,
    59 // ----------------------------------------------------------------------------
    47 									const TDesC16& aText, TInt aIndex )
    60 // CAiNativeRenderer::Publish()
       
    61 //
       
    62 // ----------------------------------------------------------------------------
       
    63 //    
       
    64 TInt CAiNativeRenderer::Publish( CHsContentPublisher& aPlugin, TInt aContent,
       
    65 	const TDesC16& aText, TInt aIndex )
    48     {    
    66     {    
    49     TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) );
    67     TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) );
    50     
    68     
    51     if( err != KErrNone )
    69     if( err != KErrNone )
    52         {
    70         {
    53         return err;
    71         return err;
    54         }
    72         }
    55         
    73         
    56     TRAP( err, DoPublishL( aPlugin, aContent, aText, aIndex ) );
    74     TRAP( err, DoPublishL( aPlugin, aContent, aText, aIndex ) );
    57     return err;
    75     
    58     }
    76     return err;
    59     
    77     }
    60     
    78     
    61 TInt CAiNativeRenderer::Publish( MAiPropertyExtension& aPlugin, TInt aContent, 
    79 // ----------------------------------------------------------------------------
    62 									const TDesC8& aBuf, TInt aIndex )
    80 // CAiNativeRenderer::Publish()
       
    81 //
       
    82 // ----------------------------------------------------------------------------
       
    83 //
       
    84 TInt CAiNativeRenderer::Publish( CHsContentPublisher& aPlugin, TInt aContent, 
       
    85 	const TDesC8& aBuf, TInt aIndex )
    63     {    
    86     {    
    64     TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) );
    87     TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) );
    65     
    88     
    66     if( err != KErrNone )
    89     if( err != KErrNone )
    67         {
    90         {
    68         return err;
    91         return err;
    69         }
    92         }
    70         
    93         
    71     TRAP( err, DoPublishL( aPlugin, aContent, aBuf, aIndex ) );
    94     TRAP( err, DoPublishL( aPlugin, aContent, aBuf, aIndex ) );
    72     return err;
    95     
    73     }
    96     return err;
    74     
    97     }
    75     
    98     
    76 TInt CAiNativeRenderer::Publish( MAiPropertyExtension& aPlugin, TInt aContent, 
    99 // ----------------------------------------------------------------------------
    77 									RFile& aFile, TInt aIndex )
   100 // CAiNativeRenderer::Publish()
       
   101 //
       
   102 // ----------------------------------------------------------------------------
       
   103 //    
       
   104 TInt CAiNativeRenderer::Publish( CHsContentPublisher& aPlugin, TInt aContent, 
       
   105 	RFile& aFile, TInt aIndex )
    78     {    
   106     {    
    79     TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) );
   107     TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) );
    80     
   108     
    81     if( err != KErrNone )
   109     if( err != KErrNone )
    82         {
   110         {
    83         return err;
   111         return err;
    84         }
   112         }
    85         
   113         
    86     TRAP( err, DoPublishL( aPlugin, aContent, aFile, aIndex ) );
   114     TRAP( err, DoPublishL( aPlugin, aContent, aFile, aIndex ) );
    87     return err;
   115     
    88     }
   116     return err;
    89     
   117     }
    90     
   118     
    91 TInt CAiNativeRenderer::Clean( MAiPropertyExtension& aPlugin, TInt aContent )
   119 // ----------------------------------------------------------------------------
       
   120 // CAiNativeRenderer::Clean()
       
   121 //
       
   122 // ----------------------------------------------------------------------------
       
   123 //    
       
   124 TInt CAiNativeRenderer::Clean( CHsContentPublisher& aPlugin, TInt aContent )
    92     {    
   125     {    
    93     TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) );
   126     TRAPD( err, DoMimeTypeCheckL( aPlugin, aContent ) );
    94     
   127     
    95     if( err != KErrNone )
   128     if( err != KErrNone )
    96         {
   129         {
    97         return err;
   130         return err;
    98         }
   131         }
    99         
   132         
   100     TRAP( err, DoCleanL( aPlugin, aContent ) );
   133     TRAP( err, DoCleanL( aPlugin, aContent ) );
   101     return err;
   134     
   102     }
   135     return err;
   103     
   136     }
   104     
   137     
   105 void CAiNativeRenderer::DoPublishL
   138 // ----------------------------------------------------------------------------
   106         ( MAiPropertyExtension& /*aPlugin*/, TInt /*aContent*/, TInt /*aResource*/, TInt /*aIndex*/ )
   139 // CAiNativeRenderer::DoPublishL()
       
   140 //
       
   141 // ----------------------------------------------------------------------------
       
   142 //    
       
   143 void CAiNativeRenderer::DoPublishL( CHsContentPublisher& /*aPlugin*/, 
       
   144     TInt /*aContent*/, TInt /*aResource*/, TInt /*aIndex*/ )
   107     { 
   145     { 
   108 	// Default implementation, overridden in subclass if needed.
   146 	// Default implementation, overridden in subclass if needed.
   109     User::Leave( KErrNotFound );   
   147     User::Leave( KErrNotFound );   
   110     }
   148     }
   111     
   149     
   112     
   150 // ----------------------------------------------------------------------------
   113 void CAiNativeRenderer::DoPublishL
   151 // CAiNativeRenderer::DoPublishL()
   114         ( MAiPropertyExtension& /*aPlugin*/, TInt /*aContent*/, const TDesC16& /*aText*/, TInt /*aIndex*/ )
   152 //
   115     {    
   153 // ----------------------------------------------------------------------------
   116     // Default implementation, overridden in subclass if needed. 
   154 //    
   117     User::Leave( KErrNotFound );   
   155 void CAiNativeRenderer::DoPublishL( CHsContentPublisher& /*aPlugin*/, 
   118     }
   156     TInt /*aContent*/, const TDesC16& /*aText*/, TInt /*aIndex*/ )
   119     
   157     {    
   120     
   158     // Default implementation, overridden in subclass if needed. 
   121 void CAiNativeRenderer::DoPublishL
   159     User::Leave( KErrNotFound );   
   122         ( MAiPropertyExtension& /*aPlugin*/, TInt /*aContent*/, const TDesC8& /*aBuf*/, TInt /*aIndex*/ )
   160     }
   123     {    
   161     
   124     // Default implementation, overridden in subclass if needed. 
   162 // ----------------------------------------------------------------------------
   125     User::Leave( KErrNotFound );   
   163 // CAiNativeRenderer::DoPublishL()
   126     }
   164 //
   127     
   165 // ----------------------------------------------------------------------------
   128     
   166 //    
   129 void CAiNativeRenderer::DoPublishL
   167 void CAiNativeRenderer::DoPublishL( CHsContentPublisher& /*aPlugin*/, 
   130         ( MAiPropertyExtension& /*aPlugin*/, TInt /*aContent*/, RFile& /*aFile*/, TInt /*aIndex*/ )
   168     TInt /*aContent*/, const TDesC8& /*aBuf*/, TInt /*aIndex*/ )
   131     {    
   169     {    
   132     // Default implementation, overridden in subclass if needed. 
   170     // Default implementation, overridden in subclass if needed. 
   133     User::Leave( KErrNotFound );   
   171     User::Leave( KErrNotFound );   
   134     }
   172     }
   135     
   173     
   136     
   174 // ----------------------------------------------------------------------------
   137 void CAiNativeRenderer::DoCleanL
   175 // CAiNativeRenderer::DoPublishL()
   138         ( MAiPropertyExtension& /*aPlugin*/, TInt /*aContent*/ )
   176 //
   139     {    
   177 // ----------------------------------------------------------------------------
   140     // Default implementation, overridden in subclass if needed. 
   178 //    
   141     User::Leave( KErrNotFound );   
   179 void CAiNativeRenderer::DoPublishL( CHsContentPublisher& /*aPlugin*/, 
   142     }
   180     TInt /*aContent*/, RFile& /*aFile*/, TInt /*aIndex*/ )
   143 
   181     {    
   144 
   182     // Default implementation, overridden in subclass if needed. 
       
   183     User::Leave( KErrNotFound );   
       
   184     }
       
   185     
       
   186 // ----------------------------------------------------------------------------
       
   187 // CAiNativeRenderer::DoCleanL()
       
   188 //
       
   189 // ----------------------------------------------------------------------------
       
   190 //    
       
   191 void CAiNativeRenderer::DoCleanL( CHsContentPublisher& /*aPlugin*/, 
       
   192     TInt /*aContent*/ )
       
   193     {    
       
   194     // Default implementation, overridden in subclass if needed. 
       
   195     User::Leave( KErrNotFound );   
       
   196     }
       
   197 
       
   198 // ----------------------------------------------------------------------------
       
   199 // CAiNativeRenderer::GetIntContentId()
       
   200 //
       
   201 // ----------------------------------------------------------------------------
       
   202 //
   145 TInt CAiNativeRenderer::GetIntContentId( const TDesC& aCid ) const
   203 TInt CAiNativeRenderer::GetIntContentId( const TDesC& aCid ) const
   146     {
   204     {
   147     for( TInt i( 0 ); i < KAiDeviceStatusContentCount; i++ )
   205     for( TInt i( 0 ); i < KAiDeviceStatusContentCount; i++ )
   148         {
   206         {
   149         const TAiContentItem& item = KAiDeviceStatusContent[i];
   207         const TAiContentItem& item = KAiDeviceStatusContent[i];
   152             //match
   210             //match
   153             return item.id;            
   211             return item.id;            
   154             }
   212             }
   155         }
   213         }
   156 
   214 
   157     for( TInt i( 0 ); i < KAiScutContentCount; i++ )
       
   158         {
       
   159         const TAiContentItem& item = KAiScutContent[i];
       
   160         if( ContentCid(item) == aCid )
       
   161             {
       
   162             //match
       
   163             return item.id;            
       
   164             }
       
   165         }
       
   166 
       
   167     return KErrNotFound;
   215     return KErrNotFound;
   168     }
   216     }
   169     
   217     
   170 
   218 // ----------------------------------------------------------------------------
   171 TBool CAiNativeRenderer::MatchMimeType( MAiPropertyExtension& aPlugin, 
   219 // CAiNativeRenderer::MatchMimeType()
   172                                         TInt aContentId, 
   220 //
   173                                         const TDesC8& aMimeType ) const
   221 // ----------------------------------------------------------------------------
       
   222 //
       
   223 TBool CAiNativeRenderer::MatchMimeType( CHsContentPublisher& aPlugin, 
       
   224     TInt aContentId, const TDesC8& aMimeType ) const                                        
   174     {      
   225     {      
   175     TUid pluginUid;
   226     TUid pluginUid( aPlugin.PublisherInfo().Uid() );
   176     TRAPD( err, pluginUid = aPlugin.PublisherInfoL()->iUid );
   227            
   177     if ( err != KErrNone )
       
   178         {
       
   179         return EFalse;
       
   180         }
       
   181     // loop through Device Status content items
   228     // loop through Device Status content items
   182     if ( pluginUid == KDeviceStatusPluginUid )
   229     if ( pluginUid == KDeviceStatusPluginUid )
   183         {
   230         {
   184         for( TInt i( 0 ); i < KAiDeviceStatusContentCount; i++ )
   231         for( TInt i( 0 ); i < KAiDeviceStatusContentCount; i++ )
   185             {
   232             {
   193             TBuf8<KAiContentTypeMaxLength> mimeType((TText8*) item.type);
   240             TBuf8<KAiContentTypeMaxLength> mimeType((TText8*) item.type);
   194                 
   241                 
   195             return ( mimeType.Match( aMimeType ) != KErrNotFound );
   242             return ( mimeType.Match( aMimeType ) != KErrNotFound );
   196             }        
   243             }        
   197         }
   244         }
   198     else if ( pluginUid == KShortcutPluginUid )
   245     else if ( pluginUid == KProfilePluginUid )
   199     { 
   246     { 
   200     // if match not found, loop through Shortcut content items
   247     // if match not found, loop through Profile content items
   201     for( TInt i( 0 ); i < KAiScutContentCount; i++ )
   248     for( TInt i( 0 ); i < KAiProfileContentCount; i++ )
   202         {
   249         {
   203         const TAiContentItem& item = KAiScutContent[i];
   250         const TAiContentItem& item = KAiProfileContent[i];
   204         
   251         
   205         if( item.id != aContentId )
   252         if( item.id != aContentId )
   206             {
   253             {
   207             continue;
   254             continue;
   208             }            
   255             }            
   210         TBuf8<KAiContentTypeMaxLength> mimeType((TText8*) item.type);
   257         TBuf8<KAiContentTypeMaxLength> mimeType((TText8*) item.type);
   211             
   258             
   212         return ( mimeType.Match( aMimeType ) != KErrNotFound );
   259         return ( mimeType.Match( aMimeType ) != KErrNotFound );
   213         }        
   260         }        
   214     }
   261     }
   215     else if ( pluginUid == KProfilePluginUid )
       
   216     { 
       
   217     // if match not found, loop through Profile content items
       
   218     for( TInt i( 0 ); i < KAiProfileContentCount; i++ )
       
   219         {
       
   220         const TAiContentItem& item = KAiProfileContent[i];
       
   221         
       
   222         if( item.id != aContentId )
       
   223             {
       
   224             continue;
       
   225             }            
       
   226         
       
   227         TBuf8<KAiContentTypeMaxLength> mimeType((TText8*) item.type);
       
   228             
       
   229         return ( mimeType.Match( aMimeType ) != KErrNotFound );
       
   230         }        
       
   231     }
       
   232     
   262     
   233     return EFalse;    
   263     return EFalse;    
   234     }
   264     }
   235 
   265 
   236 
   266 // ----------------------------------------------------------------------------
   237 void CAiNativeRenderer::DoMimeTypeCheckL( MAiPropertyExtension& aPlugin, TInt aContentId )
   267 // CAiNativeRenderer::DoMimeTypeCheckL()
   238     {
   268 //
   239     MAiContentItemIterator* iter = 
   269 // ----------------------------------------------------------------------------
   240         (MAiContentItemIterator*)aPlugin.GetPropertyL( EAiPublisherContent );
   270 //
       
   271 void CAiNativeRenderer::DoMimeTypeCheckL( CHsContentPublisher& aPlugin, 
       
   272     TInt aContentId )
       
   273     {
       
   274     MAiContentItemIterator* iter( static_cast< MAiContentItemIterator* >(         
       
   275         aPlugin.GetProperty( CHsContentPublisher::EPublisherContent ) ) );
       
   276         
       
   277     if ( !iter )
       
   278         {
       
   279         User::Leave( KErrNotSupported );
       
   280         }
       
   281     
   241     const TAiContentItem& item = iter->ItemL( aContentId );
   282     const TAiContentItem& item = iter->ItemL( aContentId );
   242 
   283 
   243     aContentId = GetIntContentId( ContentCid(item) );
   284     aContentId = GetIntContentId( ContentCid(item) );
   244 
   285 
   245     if( !MatchMimeType( aPlugin, aContentId, ContentType(item) ) )
   286     if( !MatchMimeType( aPlugin, aContentId, ContentType(item) ) )
   246         {
   287         {
   247         User::Leave( KErrNotSupported );
   288         User::Leave( KErrNotSupported );
   248         }
   289         }
   249 
   290     }
   250     }
   291 
   251     
   292 // End of file
       
   293