cmmanager/cpwlanapplugin/src/cpwlanapplugin.cpp
changeset 20 9c97ad6591ae
child 27 489cf6208544
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Control Panel WLAN AP plugin implementation.
       
    16 *
       
    17 */
       
    18 
       
    19 // System includes
       
    20 #include <QtCore>
       
    21 #include <cmmanager_shim.h>
       
    22 #include <cmconnectionmethod_shim.h>
       
    23 
       
    24 // User includes
       
    25 #include "cpwlanapplugin.h"
       
    26 #include "cpwlanapview.h"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "cpwlanappluginTraces.h"
       
    30 #endif
       
    31 
       
    32 /*!
       
    33     \class CpWlanApPlugin
       
    34     \brief Implements the WLAN bearer AP (access point) Control Panel plugin.
       
    35 */
       
    36 
       
    37 // External function prototypes
       
    38 
       
    39 // Local constants
       
    40 
       
    41 // ======== LOCAL FUNCTIONS ========
       
    42 
       
    43 // ======== MEMBER FUNCTIONS ========
       
    44 
       
    45 /*!
       
    46     Constructor.
       
    47 */
       
    48 CpWlanApPlugin::CpWlanApPlugin() :
       
    49     mTranslator(0),
       
    50     mCmManager(0),
       
    51     mCmConnectionMethod(0)
       
    52 {
       
    53     OstTraceFunctionEntry0(CPWLANAPPLUGIN_CPWLANAPPLUGIN_ENTRY);
       
    54 
       
    55     // Install localization
       
    56     QString lang = QLocale::system().name();
       
    57     QString path = "z:/resource/qt/translations/";
       
    58     mTranslator = new QTranslator(this);
       
    59     mTranslator->load(path + "cpapplugin_" + lang);
       
    60     qApp->installTranslator(mTranslator);
       
    61     
       
    62     OstTraceFunctionExit0(CPWLANAPPLUGIN_CPWLANAPPLUGIN_EXIT);
       
    63 }
       
    64 
       
    65 /*!
       
    66     Destructor.
       
    67 */
       
    68 CpWlanApPlugin::~CpWlanApPlugin()
       
    69 {
       
    70     OstTraceFunctionEntry0(DUP1_CPWLANAPPLUGIN_CPWLANAPPLUGIN_ENTRY);
       
    71     
       
    72     delete mCmConnectionMethod;
       
    73     delete mCmManager;
       
    74 
       
    75     OstTraceFunctionExit0(DUP1_CPWLANAPPLUGIN_CPWLANAPPLUGIN_EXIT);
       
    76 }
       
    77 
       
    78 /*!
       
    79     Returns the bearer type handled by the plugin.
       
    80 */
       
    81 uint CpWlanApPlugin::bearerType() const
       
    82 {
       
    83     OstTraceFunctionEntry0(CPWLANAPPLUGIN_BEARERTYPE_ENTRY);
       
    84     
       
    85     OstTraceFunctionExit0(CPWLANAPPLUGIN_BEARERTYPE_EXIT);
       
    86     return CMManagerShim::BearerTypeWlan;
       
    87 }
       
    88 
       
    89 /*!
       
    90     Creates the WLAN AP settings view.
       
    91 */
       
    92 CpBaseSettingView *CpWlanApPlugin::createSettingView(uint connectionMethod)
       
    93 {
       
    94     OstTraceFunctionEntry0(CPWLANAPPLUGIN_CREATESETTINGVIEW_ENTRY);
       
    95 
       
    96     // Find the connection method
       
    97     try {
       
    98         mCmManager = new CmManagerShim();
       
    99         mCmConnectionMethod = mCmManager->connectionMethod(connectionMethod);
       
   100     }
       
   101     catch (const std::exception&) {
       
   102         // Error, don't create settings view, just return
       
   103         OstTrace1(
       
   104             TRACE_ERROR,
       
   105             CPWLANAPPLUGIN_CREATESETTINGVIEW,
       
   106             "Connection method loading failed;connectionMethod=%u",
       
   107             connectionMethod);
       
   108 
       
   109         OstTraceFunctionExit0(DUP1_CPWLANAPPLUGIN_CREATESETTINGVIEW_EXIT);
       
   110         return NULL;
       
   111     }
       
   112     
       
   113     // Connection method found, create settings view
       
   114     OstTraceFunctionExit0(CPWLANAPPLUGIN_CREATESETTINGVIEW_EXIT);
       
   115     return new CpWlanApView(mCmConnectionMethod);
       
   116 }
       
   117 
       
   118 Q_EXPORT_PLUGIN2(cpwlanapplugin, CpWlanApPlugin);