Add a version of the MCS SAT Handler ready for stemming
authorTom Pritchard <tomp@symbian.org>
Wed, 03 Nov 2010 16:17:59 +0000
changeset 109 fddd8ce1f29d
parent 108 04364b20a2b8
child 110 3aa4235c5e9b
Add a version of the MCS SAT Handler ready for stemming
breakdeps/MCSSatHandler/mcssathandler.cpp
breakdeps/MCSSatHandler/mcssathandler.h
breakdeps/MCSSatHandler/mcssathandler.mmp
group/bld.inf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/breakdeps/MCSSatHandler/mcssathandler.cpp	Wed Nov 03 16:17:59 2010 +0000
@@ -0,0 +1,199 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Used for receive SIM Application name, icon or 
+*                visibility information.
+*
+*/
+
+
+
+// INCLUDE FILES
+
+#include <e32property.h>
+// From SatClient
+#include "mcsdef.h"
+#include <bitdev.h>
+
+#include "mcssathandler.h"
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// CMcsSatHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CMcsSatHandler* CMcsSatHandler::NewL()
+    {
+    CMcsSatHandler* self = new( ELeave ) CMcsSatHandler( );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------    
+// Destructor
+// -----------------------------------------------------------------------------
+CMcsSatHandler::~CMcsSatHandler()
+    {
+    iSatIcon.Close(); 
+    iSatSession.Close();
+    }
+
+// -----------------------------------------------------------------------------    
+// Destructor
+// -----------------------------------------------------------------------------
+EXPORT_C CAknIcon* CMcsSatHandler::LoadIconL()
+    {
+    TInt iconId( KErrNone );
+    User::LeaveIfError( RProperty::Get( KCRUidMenu, KMenuSatUIIconId, iconId ) );
+    CAknIcon* icon = CAknIcon::NewL(); 
+    CleanupStack::PushL(icon);
+    if( iconId != KErrNone )
+        {
+        RIconEf iIconEf;
+        iSatIcon.GetIconInfoL( TUint8( iconId ), iIconEf ); 
+        CleanupClosePushL( iIconEf );
+        CFbsBitmap* bitmap = GetBitmapL( iIconEf );
+            if( !bitmap )
+                {
+                CFbsBitmap* mask( NULL );
+                CleanupStack::PushL( mask );    
+                
+                icon->SetBitmap( bitmap );
+                // create and set mask
+                User::LeaveIfError( mask->Create( bitmap->SizeInPixels(), EGray256 ) );
+                
+                CFbsBitmapDevice* maskDevice = CFbsBitmapDevice::NewL( mask );
+                CleanupStack::PushL( maskDevice ); 
+                CFbsBitGc* maskGc;
+                User::LeaveIfError( maskDevice->CreateContext( maskGc ) );
+                CleanupStack::PushL( maskGc );
+                maskGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
+                maskGc->SetDrawMode( CGraphicsContext::EDrawModePEN );
+                maskGc->SetBrushColor( KRgbBlack );
+                maskGc->Clear();            
+                maskGc->SetBrushColor( KRgbWhite );             
+                maskGc->DrawRect( TRect( TPoint( ), bitmap->SizeInPixels() ) );                
+                icon->SetMask( mask );
+                
+                CleanupStack::PopAndDestroy( maskGc );
+                CleanupStack::PopAndDestroy( maskDevice );
+                CleanupStack::Pop( mask );
+                }
+        CleanupStack::PopAndDestroy( &iIconEf ); // iIconEf
+        CleanupStack::Pop( icon );
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy( icon );
+        icon = NULL;
+        }
+    return icon;    
+    }
+
+// ---------------------------------------------------------------------------
+// CMenuSATHandler::GetName
+// ---------------------------------------------------------------------------
+//    
+EXPORT_C TInt CMcsSatHandler::GetName( TDes& aName )
+    {
+    return RProperty::Get( KCRUidMenu, KMenuSatUIName, aName );
+    }
+
+// ---------------------------------------------------------------------------
+// CMenuSATHandler::GetVisibility
+// ---------------------------------------------------------------------------
+//        
+EXPORT_C TBool CMcsSatHandler::CheckVisibility() 
+    {
+    TInt visibility( KErrNone );
+    TInt err = RProperty::Get( KCRUidMenu, KMenuShowSatUI, visibility );
+    if( err == KErrNone && visibility )
+        return ETrue;
+    else
+        return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CMcsSatHandler::CMcsSatHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CMcsSatHandler::CMcsSatHandler()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CMcsSatHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CMcsSatHandler::ConstructL()
+    {
+    iSatSession.ConnectL();
+    iSatIcon.OpenL( iSatSession ); 
+    }
+
+// ---------------------------------------------------------------------------
+// CMenuSATHandler::GetVisibility
+// ---------------------------------------------------------------------------
+// 
+CFbsBitmap* CMcsSatHandler::GetBitmapL( const RIconEf& aIconEF )
+    {
+    TInt selectedIconIndex( KErrNotFound );
+    TSize selectedIconSize( 0, 0 );
+    CFbsBitmap* bitmap( NULL );
+    for ( TInt i = 0; i < aIconEF.Count(); ++i )
+        {
+        if( ( aIconEF[i].IconSize().iHeight * aIconEF[i].IconSize().iWidth ) >= 
+            ( selectedIconSize.iHeight * selectedIconSize.iWidth ) )
+            if( bitmap )
+                {
+                delete bitmap;
+                bitmap = NULL;
+                }
+            // test and select index of iIcon which is not too big
+            TRAPD( bitmapErr, bitmap = iSatIcon.GetIconL( aIconEF[ i ] ) );
+            if( !bitmapErr && bitmap ) //!iBitmap if iIcon is too big
+                {
+                selectedIconSize = aIconEF[i].IconSize();
+                selectedIconIndex = i;
+                }
+            else if( bitmapErr )
+                {
+                User::Leave( bitmapErr );
+                }
+            }
+    if( selectedIconIndex != KErrNotFound )
+        {
+        if( bitmap )
+            {
+            delete bitmap;
+            bitmap = NULL;
+            }
+        TRAPD( bitmapErr, bitmap = iSatIcon.GetIconL( aIconEF[ selectedIconIndex ] ) );
+        User::LeaveIfError( bitmapErr );    
+        return bitmap;
+        }
+    else 
+        {
+        return NULL;
+        }    
+    }    
+    
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/breakdeps/MCSSatHandler/mcssathandler.h	Wed Nov 03 16:17:59 2010 +0000
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The API supports attributes not present in MCS from SAT Api
+*
+*/
+
+
+#ifndef __MCSSATHANDLER_H__
+#define __MCSSATHANDLER_H__
+
+#include <AknIconUtils.h>
+
+#include <rsatsession.h>
+#include <tsaticoninfo.h>
+#ifdef SIM_ATK_SERVICE_API_V1 
+#include <rsatservice.h>// MCL 
+#else 
+#include <RSatIcon.h> // 5.0 
+#endif 
+/**
+ *  SAT Handler.
+ *  @lib mcssathandler.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CMcsSatHandler ): public CBase
+    {
+public:
+    
+    /**
+    * Two-phased constructor. Leaves on failure.
+    * @return The constructed object.
+    */
+    IMPORT_C static CMcsSatHandler* NewL();
+    
+    /**
+    * Destructor.
+    * @since S60 v5.0
+    * @capability None.
+    * @throws None.
+    * @panic None.
+    */
+    virtual ~CMcsSatHandler();
+    
+    IMPORT_C CAknIcon* LoadIconL();
+    
+    IMPORT_C TInt GetName( TDes& aName );
+    
+    IMPORT_C static TBool CheckVisibility() ;
+    
+private:
+
+    /**
+    * Constructor.
+    */
+    CMcsSatHandler();
+
+    /**
+    * 2nd phase constructor.
+    */
+    void ConstructL();
+
+    /**
+    * Gets best icon from aIconEF.
+    */
+    CFbsBitmap* GetBitmapL( const RIconEf& aIconEF );
+    
+private:    // data
+    
+    RSatSession iSatSession;
+    
+#ifdef SIM_ATK_SERVICE_API_V1
+    RSatService iSatIcon;
+#else
+    RSatIcon iSatIcon;
+#endif 
+    };
+
+#endif // __MCSSATHANDLER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/breakdeps/MCSSatHandler/mcssathandler.mmp	Wed Nov 03 16:17:59 2010 +0000
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+
+TARGET          stem_mcssathandler.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x2001CB7B
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+NOEXPORTLIBRARY
+
+#ifdef WINSCW
+#error We're not going to build for WINSCW
+#else
+DEFFILE			/sf/mw/homescreensrv/menucontentsrv/eabi/mcssathandler.def
+#endif
+
+SOURCEPATH      ./
+SOURCE          mcssathandler.cpp
+
+SOURCEPATH		/sf/mw/homescreensrv/menucontentsrv/extsrc
+SOURCE          mcssatnotifier.cpp
+
+
+USERINCLUDE     /sf/mw/homescreensrv/menucontentsrv/extinc
+USERINCLUDE		./
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         aknicon.lib 
+LIBRARY         SatClient.lib
+LIBRARY         fbscli.lib 
+LIBRARY         bitgdi.lib 
+
+
--- a/group/bld.inf	Tue Nov 02 22:37:34 2010 +0000
+++ b/group/bld.inf	Wed Nov 03 16:17:59 2010 +0000
@@ -52,3 +52,6 @@
 ../breakdeps/DRMEngine/RightsServer.mmp
 ../breakdeps/DRMEngine/DrmStdKeyStorage.mmp
 
+// based on /sf/mw/homescreensrv
+../breakdeps/MCSSatHandler/mcssathandler.mmp
+