mediasettings/videosettingsplugin/src/videosettingsaccesspointentry.cpp
branchRCL_3
changeset 56 839377eedc2b
child 67 72c709219fcd
equal deleted inserted replaced
54:315810614048 56:839377eedc2b
       
     1 /*
       
     2  * Copyright (c) 2009 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  *
       
    16  */
       
    17 
       
    18 #include "mpxvideo_debug.h"
       
    19 #include "videosettingsaccesspointentry.h"
       
    20 #include "videosettingsgroup.h"
       
    21 #include <cmmanager_shim.h>
       
    22 #include <cmconnectionmethod_shim.h>
       
    23 #include <cpitemdatahelper.h>
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // Constructor
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 VideoSettingsAccessPointEntry::VideoSettingsAccessPointEntry(
       
    30     CpItemDataHelper &itemDataHelper,
       
    31     const QString& text,
       
    32     VideoSettingsGroup *parent) :
       
    33     CpSettingFormEntryItemData(CpSettingFormEntryItemData::ButtonEntryItem, 
       
    34         itemDataHelper, text, QString(), QString(), parent),
       
    35     mParent(parent)
       
    36 {
       
    37     MPX_ENTER_EXIT(_L("VideoSettingsAccessPointEntry::VideoSettingsAccessPointEntry()"));
       
    38     
       
    39     itemDataHelper.addConnection(this,SIGNAL(clicked()),this,SLOT(openSelectionDialogSlot()));
       
    40     mApplSettings = new CmApplSettingsUi(this);
       
    41     connect(mApplSettings, SIGNAL(finished(uint)), this, SLOT(accessPointDialogFinished(uint)));
       
    42     mSelection.result = CmApplSettingsUi::SelectionTypeConnectionMethod;
       
    43     mSelection.id = 0;
       
    44     mCmManager = new CmManagerShim();
       
    45 }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // Destructor
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 VideoSettingsAccessPointEntry::~VideoSettingsAccessPointEntry()
       
    52 {
       
    53     MPX_ENTER_EXIT(_L("VideoSettingsAccessPointEntry::~VideoSettingsAccessPointEntry()"));
       
    54     
       
    55     delete mCmManager;
       
    56 }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // accessPointNameFromIapId
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 void VideoSettingsAccessPointEntry::setIapId(const uint& apId)
       
    63 {
       
    64     MPX_ENTER_EXIT(_L("VideoSettingsAccessPointEntry::accessPointNameFromIapId()"), 
       
    65         _L("apId = %i"), apId);
       
    66     
       
    67     QList<uint> cmArray;
       
    68     mCmManager->connectionMethod(cmArray, false);
       
    69     
       
    70     bool found = false;
       
    71     foreach(uint id, cmArray)
       
    72     {
       
    73         CmConnectionMethodShim* connMethod = getConnectionMethod(id);
       
    74         if(connMethod && connMethod->getIntAttribute(CMManagerShim::CmIapId) == apId)
       
    75         {
       
    76             mSelection.id = connMethod->getIntAttribute(CMManagerShim::CmId);
       
    77             setAccessPointName(connMethod);
       
    78             found = true;
       
    79             break;
       
    80         }
       
    81     }
       
    82     
       
    83     if(!found)
       
    84     {
       
    85         this->setDescription(hbTrId("txt_videos_dblist_none"));
       
    86     }
       
    87 }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // createSettingView
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 CpBaseSettingView* VideoSettingsAccessPointEntry::createSettingView() const
       
    94 {
       
    95     MPX_ENTER_EXIT(_L("VideoSettingsAccessPointEntry::createSettingView()"));
       
    96     
       
    97     // does not create a new view.
       
    98     return 0;
       
    99 }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // getConnectionMethod
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 CmConnectionMethodShim* VideoSettingsAccessPointEntry::getConnectionMethod(const uint& id)
       
   106 {
       
   107     MPX_ENTER_EXIT(_L("VideoSettingsAccessPointEntry::getConnectionMethod()"));
       
   108     
       
   109     CmConnectionMethodShim* connMethod = 0;
       
   110     try {
       
   111         connMethod = mCmManager->connectionMethod(id);
       
   112     } catch (const std::exception& exc) {
       
   113         MPX_DEBUG(_L("Caught exception while fetching connection method. Exception: %s"), exc.what());
       
   114         return 0;
       
   115     }
       
   116     
       
   117     return connMethod;
       
   118 }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // setName
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 void VideoSettingsAccessPointEntry::setAccessPointName(CmConnectionMethodShim* connMethod)
       
   125 {
       
   126     MPX_ENTER_EXIT(_L("VideoSettingsAccessPointEntry::setAccessPointName()"));
       
   127     
       
   128     QString name = connMethod->getStringAttribute(CMManagerShim::CmName);
       
   129     this->setDescription(name);
       
   130 }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // openSelectionDialogSlot
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 void VideoSettingsAccessPointEntry::openSelectionDialogSlot()
       
   137 {
       
   138     MPX_ENTER_EXIT(_L("VideoSettingsAccessPointEntry::openSelectionDialogSlot()"));
       
   139     
       
   140     QFlags<CmApplSettingsUi::SelectionDialogItems> listItems;
       
   141     QSet<CmApplSettingsUi::BearerTypeFilter> filter;
       
   142     
       
   143     listItems |= CmApplSettingsUi::ShowConnectionMethods;
       
   144     
       
   145     mApplSettings->setOptions(listItems, filter);
       
   146     mApplSettings->setSelection(mSelection);
       
   147     
       
   148     mApplSettings->open();
       
   149 }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // accessPointDialogFinished
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 void VideoSettingsAccessPointEntry::accessPointDialogFinished(uint error)
       
   156 {
       
   157     MPX_ENTER_EXIT(_L("VideoSettingsAccessPointEntry::accessPointDialogFinished()"), 
       
   158         _L("error = %i"), error);
       
   159     
       
   160     if(error == CmApplSettingsUi::ApplSettingsErrorNone)
       
   161     {
       
   162         CmApplSettingsUi::SettingSelection selection =
       
   163             mApplSettings->selection();
       
   164         MPX_DEBUG(_L("New access point connection method id = %i"), selection.id);
       
   165         CmConnectionMethodShim* connMethod = getConnectionMethod(selection.id);
       
   166         if(connMethod)
       
   167         {
       
   168             mSelection.id = selection.id;
       
   169             mParent->setAccessPointId(connMethod->getIntAttribute(CMManagerShim::CmIapId));
       
   170             setAccessPointName(connMethod);
       
   171         }
       
   172         else
       
   173         {
       
   174             MPX_DEBUG(_L("FATAL: Could not find connection method with id %i"), selection.id);
       
   175         }
       
   176     }
       
   177 }