cmmanager/cppacketdataapplugin/src/cppacketdataapplugin.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 packet data AP plugin implementation.  
       
    16 *
       
    17 */
       
    18 
       
    19 // System includes
       
    20 #include <QString>
       
    21 #include <QTranslator>
       
    22 #include <QCoreApplication>
       
    23 #include <cmmanager_shim.h>
       
    24 #include <cmconnectionmethod_shim.h>
       
    25 
       
    26 // User includes
       
    27 #include "cppacketdataapplugin.h"
       
    28 #include "cppacketdataapview.h"
       
    29 #include "OstTraceDefinitions.h"
       
    30 #ifdef OST_TRACE_COMPILER_IN_USE
       
    31 #include "cppacketdataappluginTraces.h"
       
    32 #endif
       
    33 
       
    34 /*!
       
    35     \class CpPacketDataApPlugin
       
    36     \brief Implements the packet data bearer AP (access point) Control Panel
       
    37            plugin.
       
    38 */
       
    39 
       
    40 // External function prototypes
       
    41 
       
    42 // Local constants
       
    43 
       
    44 // ======== LOCAL FUNCTIONS ========
       
    45 
       
    46 // ======== MEMBER FUNCTIONS ========
       
    47 
       
    48 /*!
       
    49     Constructor.
       
    50 */
       
    51 CpPacketDataApPlugin::CpPacketDataApPlugin() :
       
    52     mTranslator(0),
       
    53     mCmManager(0),
       
    54     mCmConnectionMethod(0)
       
    55 {
       
    56     OstTraceFunctionEntry0(CPPACKETDATAAPPLUGIN_CPPACKETDATAAPPLUGIN_ENTRY);
       
    57  
       
    58     // Install localization
       
    59     QString lang = QLocale::system().name();
       
    60     QString path = "z:/resource/qt/translations/";
       
    61     mTranslator = new QTranslator(this);
       
    62     mTranslator->load(path + "cpapplugin_" + lang);
       
    63     qApp->installTranslator(mTranslator);
       
    64     
       
    65     OstTraceFunctionExit0(CPPACKETDATAAPPLUGIN_CPPACKETDATAAPPLUGIN_EXIT);
       
    66 }
       
    67 
       
    68 /*!
       
    69     Destructor.
       
    70 */
       
    71 CpPacketDataApPlugin::~CpPacketDataApPlugin()
       
    72 {
       
    73     OstTraceFunctionEntry0(DUP1_CPPACKETDATAAPPLUGIN_CPPACKETDATAAPPLUGIN_ENTRY);
       
    74     
       
    75     delete mCmConnectionMethod;
       
    76     delete mCmManager;
       
    77     
       
    78     OstTraceFunctionExit0(DUP1_CPPACKETDATAAPPLUGIN_CPPACKETDATAAPPLUGIN_EXIT);
       
    79 }
       
    80 
       
    81 /*!
       
    82     Returns the bearer type handled by the plugin.
       
    83 */
       
    84 uint CpPacketDataApPlugin::bearerType() const
       
    85 {
       
    86     OstTraceFunctionEntry0(CPPACKETDATAAPPLUGIN_BEARERTYPE_ENTRY);
       
    87     
       
    88     OstTraceFunctionExit0(CPPACKETDATAAPPLUGIN_BEARERTYPE_EXIT);
       
    89     return CMManagerShim::BearerTypePacketData;
       
    90 }
       
    91 
       
    92 /*!
       
    93     Creates the packet data AP settings view.
       
    94 */
       
    95 CpBaseSettingView *CpPacketDataApPlugin::createSettingView(
       
    96     uint connectionMethod)
       
    97 {
       
    98     OstTraceFunctionEntry0(CPPACKETDATAAPPLUGIN_CREATESETTINGVIEW_ENTRY);
       
    99     
       
   100     // Find the connection method
       
   101     try {
       
   102         mCmManager = new CmManagerShim();
       
   103         mCmConnectionMethod = mCmManager->connectionMethod(connectionMethod);
       
   104     }
       
   105     catch (const std::exception&) {
       
   106         // Error, don't create settings view, just return
       
   107         OstTrace1(
       
   108             TRACE_ERROR,
       
   109             CPPACKETDATAAPPLUGIN_CREATESETTINGVIEW,
       
   110             "Connection method loading failed;connectionMethod=%u",
       
   111             connectionMethod);
       
   112 
       
   113         OstTraceFunctionExit0(DUP1_CPPACKETDATAAPPLUGIN_CREATESETTINGVIEW_EXIT);
       
   114         return NULL;
       
   115     }
       
   116 
       
   117     // Connection method found, create settings view
       
   118     OstTraceFunctionExit0(CPPACKETDATAAPPLUGIN_CREATESETTINGVIEW_EXIT);
       
   119     return new CpPacketDataApView(mCmConnectionMethod);
       
   120 }
       
   121 
       
   122 Q_EXPORT_PLUGIN2(cppacketdataapplugin, CpPacketDataApPlugin);