diff -r 87476091b3f5 -r 1db7cc813a4e homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibstateutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibstateutils.cpp Fri Aug 06 13:36:36 2010 +0300 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2009 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: Utils for application library state plugin. + * + */ + +#include + +#include "hsapplibstateutils.h" +#include "hscontentservice.h" +#include "hsapp_defs.h" + +/*! + \class HsAppLibStateUtils + \ingroup group_hsmenustateplugin + \brief Utils. + Utils for application library state plugin. + */ + +/*! + Return true if given entry is cwrt widget and already on homescreen + */ +bool HsAppLibStateUtils::isCWRTWidgetOnHomeScreen(const CaEntry *entry) +{ + bool result = false; + if (entry->entryTypeName() == applicationTypeName() && + entry->attribute(swTypeKey()) == HS_CWRT_APP_TYPE && + entry->attribute(widgetUriAttributeName()) == + HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE) { + QVariantHash preferences; + QMap attributes = entry->attributes(); + QMapIterator i(attributes); + while (i.hasNext()) { + i.next(); + QString key(i.key()); + QString value(i.value()); + if (key.contains(widgetParam())) { + preferences.insert(key.remove(widgetParam()),value); + } + } + int count(0); + HsContentService::instance()->widgets(HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE,preferences,count); + result = count > 0; + } + return result; +}