contentstorage/srvsrc/casrvengutils.cpp
changeset 85 7feec50967db
child 86 e492551a0d54
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/srvsrc/casrvengutils.cpp	Tue Mar 23 23:17:02 2010 +0200
@@ -0,0 +1,153 @@
+/*
+ * 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 item information that is not supported by
+ *                the content arsenal server itself
+ *
+ */
+#include <akniconutils.h>
+#include <avkon.mbg>
+#include <e32property.h>
+#include <AknTaskList.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+#include "casrvengutils.h"
+#include "cautils.h"
+#include "cadef.h"
+#include "castorage.h"
+#include "cainnerentry.h"
+
+// ================= LOCAL FUNCTIONS ========================
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CMenuSrvEngUtils::~CMenuSrvEngUtils
+// ---------------------------------------------------------
+//
+CCaSrvEngUtils::~CCaSrvEngUtils()
+    {
+    iApaLsSession.Close();
+    }
+
+// ---------------------------------------------------------
+// CCaSrvEngUtils::NewL
+// ---------------------------------------------------------
+//
+CCaSrvEngUtils* CCaSrvEngUtils::NewL()
+    {
+    CCaSrvEngUtils* utils = new ( ELeave ) CCaSrvEngUtils();
+    CleanupStack::PushL( utils );
+    utils->ConstructL();
+    CleanupStack::Pop( utils );
+    return utils;
+    }
+
+// ---------------------------------------------------------
+// GetAppUid
+// ---------------------------------------------------------
+//
+TInt CCaSrvEngUtils::GetAppUid( const CCaInnerEntry& aEntry, TUid& aAppUid )
+    {
+    TInt err( 0 );
+    TInt32 attrVal = aEntry.GetUid();
+    if( attrVal )
+        {
+        aAppUid = TUid::Uid( attrVal );
+        }
+    else
+        {
+        err = KErrNotFound;
+        }
+    return err;
+    }
+
+// ---------------------------------------------------------
+// GetApaAppInfo
+// ---------------------------------------------------------
+//
+EXPORT_C TInt CCaSrvEngUtils::GetApaAppInfo( TUid aUid, TApaAppInfo& aInfo ) const
+    {
+    return iApaLsSession.GetAppInfo( aInfo, aUid );
+    }
+
+// ---------------------------------------------------------
+// CMenuSrvEngUtils::CMenuSrvEngUtils
+// ---------------------------------------------------------
+//
+CCaSrvEngUtils::CCaSrvEngUtils()
+    {
+    }
+
+// ---------------------------------------------------------
+// CMenuSrvEngUtils::ConstructL
+// ---------------------------------------------------------
+//
+void CCaSrvEngUtils::ConstructL()
+    {
+    User::LeaveIfError( iApaLsSession.Connect() );
+    }
+
+// ---------------------------------------------------------
+// CMenuSrvEngUtils::GetAppInfo
+// ---------------------------------------------------------
+//
+EXPORT_C TInt CCaSrvEngUtils::GetAppInfo( const CCaInnerEntry& aEntry,
+        TApaAppInfo& aAppInfo ) const
+    {
+    TUid appUid;
+    TInt err = GetAppUid( aEntry, appUid );
+    if( !err )
+        {
+        err = iApaLsSession.GetAppInfo( aAppInfo, appUid );
+        }
+    return err;
+    }
+
+// ---------------------------------------------------------
+// CMenuSrvEngUtils::IsNative
+// ---------------------------------------------------------
+//
+TBool CCaSrvEngUtils::IsNative( const CCaInnerEntry& aEntry )
+    {
+    TBool native( EFalse );
+    if( aEntry.GetEntryTypeName().CompareF( KCaTypeApp ) == KErrNone )
+        {
+        TUid uid;
+        if( GetAppUid( aEntry, uid ) == KErrNone )
+            {
+            IsNative( uid, native );
+            }
+        }
+    return native;
+    }
+
+// ---------------------------------------------------------
+// CMenuSrvEngUtils::IsNativeL
+// ---------------------------------------------------------
+//
+
+void CCaSrvEngUtils::IsNative( TUid aAppUid, TBool& aIsNative )
+    {
+    TApaAppInfo appInfo;
+    aIsNative = EFalse;
+    TInt error = iApaLsSession.GetAppInfo( appInfo, aAppUid );
+    if( error == KErrNone )
+        {
+        error = iApaLsSession.IsProgram( appInfo.iFullName, aIsNative );
+        if( error != KErrNone )
+            {
+            aIsNative = EFalse;
+            }
+        }
+    }