phonesettings/cpphonesettingsplugins/cpnetworkplugin/src/cpnetworkplugin.cpp
author hgs
Fri, 09 Jul 2010 15:40:55 +0300
changeset 50 377c906a8701
parent 46 bc5a64e5bc3c
child 76 cfea66083b62
permissions -rw-r--r--
201027

/*
 * 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:  
 *
 */
#include <cpsettingformentryitemdataimpl.h>
#include "cpnetworkplugin.h"
#include "cpnetworkpluginview.h"
#include "cppluginlogging.h"


/*!
  CpNetworkPlugin::CpNetworkPlugin
 */
CpNetworkPlugin::CpNetworkPlugin() : 
    QObject(NULL),
    m_localisation(NULL),
    m_networkStatus(NULL)
{
    INSTALL_TRACE_MSG_HANDLER;
    DPRINT << ": IN";
    
    // Create guarded objects
    m_localisation.reset(new CpPhoneLocalisation); 
    m_networkStatus.reset(new CpNetworkStatus); 
    
    // Install required translations
    m_localisation->installTranslator(
            CpPhoneLocalisation::
            TranslationFileCommon);
    
    DPRINT << ": OUT";
}


/*!
  CpNetworkPlugin::~CpNetworkPlugin
 */
CpNetworkPlugin::~CpNetworkPlugin()
{
    DPRINT;
    UNINSTALL_TRACE_MSG_HANDLER;
}


/*!
  CpNetworkPlugin::createSettingFormItemData
 */
QList<CpSettingFormItemData*> CpNetworkPlugin::createSettingFormItemData(
        CpItemDataHelper &itemDataHelper) const
{   
    DPRINT << ": IN";
    QList<CpSettingFormItemData*> ret;
    ret.append(new CpSettingFormEntryItemDataImpl<CpNetworkPluginView>(
            itemDataHelper,
            hbTrId("txt_cp_dblist_mobile_network"),
            m_networkStatus->statusText(),
            m_networkStatus->statusIcon()));
    
    m_networkStatus->setSettingFormItemData(ret.first());
        
    DPRINT << ": OUT";
    return ret;
}

/*!
  CpNetworkPlugin::createSettingView
 */
CpBaseSettingView *CpNetworkPlugin::createSettingView(const QVariant &hint) const 
    {
    DPRINT << ": IN";
    
    CpItemDataHelper *itemDataHelper(NULL);
    QScopedPointer<CpSettingFormEntryItemDataImpl<CpNetworkPluginView> > 
        data(new CpSettingFormEntryItemDataImpl<CpNetworkPluginView>(
                    *itemDataHelper,
                    hbTrId("txt_cp_dblist_mobile_network"),
                    m_networkStatus->statusText()));
    CpBaseSettingView *view = data->createSettingView();
    
    CpNetworkPluginView *networkPluginView = qobject_cast<CpNetworkPluginView*>(view);
    QVariantHash hash = hint.value<QVariantHash>();
    if ((hash.value("command").toString().compare("searchAvailableNetworks",Qt::CaseInsensitive) == 0) &&
        networkPluginView){
        networkPluginView->searchAvailableNetworks();
    }
    
    DPRINT << ": OUT";
    return view;
    }
    
Q_EXPORT_PLUGIN2(CpNetworkPlugin, CpNetworkPlugin);