sdkcreationmw/sdkruntimes/MIDP/DebugAgent/src/JavaDebugAgentSettingsApItem.cpp
author rajpuroh
Mon, 08 Mar 2010 12:09:11 +0530
changeset 0 b26acd06ea60
permissions -rw-r--r--
First Contribution of SDK components
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     1
/*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     2
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     3
* All rights reserved.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     8
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     9
* Initial Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    11
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    12
* Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    13
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    14
* Description: 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    15
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    16
*/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    17
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    18
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    19
#include <stringloader.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
#include <aknsettingitemlist.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
#include <aknradiobuttonsettingpage.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
#include <ApSettingsHandlerUI.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
#include <ApUtils.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
#include "JavaDebugAgentRes.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
#include "JavaDebugAgentSettings.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
#include "JavaDebugAgentSettingsApItem.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
#define SUPER CAknSettingItem
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
CJavaDebugAgentSettingsApItem::
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
CJavaDebugAgentSettingsApItem(TInt aId, TInt* aApId) : SUPER(aId), iApId(aApId)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
CJavaDebugAgentSettingsApItem::~CJavaDebugAgentSettingsApItem()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
    delete iCommsDb;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
    delete iAlwaysAskText;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
    delete iUserDefinedText;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
const TDesC& CJavaDebugAgentSettingsApItem::SettingTextL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
    if (*iApId != KNoAccessPoint && !iApNameValid)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
        if (UpdateApName() == KErrNone)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
            iApNameValid = ETrue;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
        else
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
            *iApId = KNoAccessPoint;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
    if (*iApId == KNoAccessPoint) 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
        return *AlwaysAskTextL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
    } 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
    else 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
        return iApName;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    64
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    65
void CJavaDebugAgentSettingsApItem::EditItemL(TBool /*aCalledFromMenu*/)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    66
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
    UpdateApName();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
    TBool aUserDefinedAp = ((*iApId) != KNoAccessPoint);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
    while (AlwaysAskOrSelectApL(&aUserDefinedAp))
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
        if (aUserDefinedAp)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
            // The primary purpose of this tool is to support
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
            // on-device-debugging over WLAN. We could filter out WLAN
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
            // access points here. The way it's done now, this tool can
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
            // be used for remote on-device debugging over GPRS. Why not?
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
            CApSettingsHandler *apUi = CApSettingsHandler::NewLC(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
                ETrue, 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
                EApSettingsSelListIsPopUp,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
                EApSettingsSelMenuSelectNormal,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
                KEApIspTypeAll,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
                EApBearerTypeAllBearers,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
                KEApSortNameAscending,
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
                EIPv4 | EIPv6);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
        
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
            // Override prompt
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
            apUi->SetTextOverrideL(EPopupPromptText, SettingName());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
            // Let the user select the access point
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
            TUint32 id = *iApId;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
            TInt ret = apUi->RunSettingsL(id, id);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
            CleanupStack::PopAndDestroy(apUi);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
            // Access point selection menu has "Exit" menu item
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
            if (ret & KApUiEventExitRequested)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
                CEikonEnv::Static()->EikAppUi()->HandleCommandL(EEikCmdExit);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    98
                break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    99
            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   100
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
            // Store the settings
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
            if (ret & KApUiEventSelected)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   103
            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   104
                *iApId = id;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   105
                iApNameValid = EFalse;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   106
                UpdateListBoxTextL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   107
                break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   108
            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   109
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   110
        else 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   111
        {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   112
            if (*iApId != KNoAccessPoint)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   113
            {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   114
                *iApId = KNoAccessPoint;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   115
                UpdateListBoxTextL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   116
            }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   117
            break;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   118
        }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   119
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   120
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   121
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   122
TBool CJavaDebugAgentSettingsApItem::AlwaysAskOrSelectApL(TInt* aUserDefinedAp)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   123
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   124
    // options array
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   125
    CDesCArrayFlat* values = new(ELeave)CDesCArrayFlat(1);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   126
    CleanupStack::PushL(values);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   127
    values->AppendL(*AlwaysAskTextL());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   128
    values->AppendL(*UserDefinedTextL());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   129
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   130
    // Create dialog
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   131
    CAknRadioButtonSettingPage* dlg = new(ELeave)CAknRadioButtonSettingPage(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   132
        R_JAVA_DEBUG_AGENT_RADIO_BUTTON_SETTING_PAGE, *aUserDefinedAp, values);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   133
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   134
    // Show the dialog
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   135
    CleanupStack::PushL(dlg);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   136
    dlg->SetSettingTextL(SettingName()); 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   137
    CleanupStack::Pop(dlg);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   138
    TBool ok = dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   139
    CleanupStack::PopAndDestroy(values);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   140
    return ok;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   141
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   142
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   143
TInt CJavaDebugAgentSettingsApItem::UpdateApName()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   144
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   145
    TRAPD(err, UpdateApNameL());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   146
    return err;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   147
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   148
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   149
void CJavaDebugAgentSettingsApItem::UpdateApNameL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   150
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   151
    CApUtils* apUtils = CApUtils::NewLC(*CommsDbL());
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   152
    apUtils->NameL(*iApId, iApName);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   153
    CleanupStack::PopAndDestroy(apUtils);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   154
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   155
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   156
CCommsDatabase* CJavaDebugAgentSettingsApItem::CommsDbL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   157
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   158
    if (!iCommsDb)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   159
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   160
        iCommsDb = CCommsDatabase::NewL();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   161
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   162
    return iCommsDb;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   163
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   164
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   165
const TDesC* CJavaDebugAgentSettingsApItem::AlwaysAskTextL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   166
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   167
    if (!iAlwaysAskText)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   168
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   169
        iAlwaysAskText = StringLoader::LoadL(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   170
            R_JAVA_DEBUG_AGENT_ACCESS_POINT_ALWAYS_ASK);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   171
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   172
    return iAlwaysAskText;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   173
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   174
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   175
const TDesC* CJavaDebugAgentSettingsApItem::UserDefinedTextL()
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   176
{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   177
    if (!iUserDefinedText)
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   178
    {
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   179
        iUserDefinedText = StringLoader::LoadL(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   180
            R_JAVA_DEBUG_AGENT_ACCESS_POINT_USER_DEFINED);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   181
    }
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   182
    return iUserDefinedText;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   183
}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   184
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   185
/**
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   186
 * Local Variables:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   187
 * c-basic-offset: 4
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   188
 * indent-tabs-mode: nil
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   189
 * End:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   190
 */