cmmanager/cmmgr/Plugins/cmpluginpacketdata/src/cmpluginpacketdata.cpp
changeset 0 5a93021fdf25
child 4 77415202bfc8
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Dialog for editing settings for a packet data connection 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 // System
       
    22 #include <AknsUtils.h>
       
    23 #include <data_caging_path_literals.hrh>
       
    24 #include <cmpluginpacketdata.mbg>           // icons
       
    25 #include <cmpacketdataui.rsg>
       
    26 #include <AknQueryDialog.h>
       
    27 #include <StringLoader.h>
       
    28 #include <cmmanager.rsg>
       
    29 // User
       
    30 #include "cmpluginpacketdata.h"
       
    31 #include <cmpluginpacketdatadef.h>
       
    32 #include "cmpacketdatacommonconstants.h"
       
    33 #include "cmlogger.h"
       
    34 #include "cmppacketdatasettingsdlg.h"
       
    35 #include <cmpsettingsconsts.h>
       
    36 #include "datamobilitycommsdattypes.h"
       
    37 #include <cmcommonconstants.h>
       
    38 #include <cmmanagerdef.h>
       
    39 
       
    40 using namespace CMManager;
       
    41 using namespace CommsDat;
       
    42 
       
    43 // ================= CONSTANTS =======================
       
    44 
       
    45 const TUint32 KDefaultPriorityPacketData = 1;
       
    46 
       
    47 /// Modem bearer names for GPRS/WCDMA Access Points
       
    48 _LIT( KModemBearerPacketData, "GPRS Modem" );
       
    49 _LIT( KPacketDataFileIcons, "z:cmpluginpacketdata.mbm" );
       
    50 _LIT( KDefaultQosDataRecordName, "PRIMARY1" );
       
    51 _LIT( KDefaultQosDataRecordNamewithSpace, "PRIMARY1 " );
       
    52 
       
    53 // ================= LOCAL PROTOTYPES =======================
       
    54 
       
    55 /**
       
    56 * Function to check and set PDP type and IfNetwork.
       
    57 * @param aThis 'this' pointer of the plugin instance
       
    58 * @param aAttribute attribute client wants to set
       
    59 * @param aValue TInt* IPv4 address buffer to be checked
       
    60 */
       
    61 static TBool SetPDPTypeL( CCmPluginBaseEng* aThis, 
       
    62                    TUint32 aAttribute, 
       
    63                    const TAny* aValue );
       
    64 
       
    65 static const TCmAttribConvTable SPacketDataConvTbl[] = 
       
    66     {
       
    67     // iAttribId, iCommsDatId, iValidFuncL, 
       
    68     // iTitleId, 
       
    69     // iMaxLength, iAttribFlags, iDefValueResId, iEditorResId, iNotUsed1, iNotUsed2
       
    70     { EPacketDataAPName, EGPRSReqTrafficClass-1, NULL,
       
    71       0,
       
    72       0, 0, 0, NULL, NULL },
       
    73     { EPacketDataAPName, KCDTIdAPN, NULL,
       
    74       R_GPRS_PLUGIN_VIEW_AP_NAME,
       
    75       KMaxGprsApNameLength, 0, R_GPRS_PLUGIN_SETT_VAL_FIELD_NONE, R_TEXT_SETTING_PAGE_GPRSAP_NAME, NULL, NULL },
       
    76     { EPacketDataPDPType, KCDTIdWCDMPDPType, &SetPDPTypeL,
       
    77       R_GPRS_PLUGIN_VIEW_PDP_TYPE,
       
    78       0, 0, 0, NULL, NULL },
       
    79     { EPacketDataPDPAddress, KCDTIdWCDMAPDPAddress, NULL },
       
    80     { EPacketDataReqPrecedence, KCDTIdReqPrecedence, NULL },
       
    81     { EPacketDataReqDelay, KCDTIdReqDelay, NULL },
       
    82     { EPacketDataReliability, KCDTIdReqReliability, NULL },
       
    83     { EPacketDataPeakThroughput, KCDTIdReqPeakThroughput, NULL },
       
    84     { EPacketDataMeanThroughput, KCDTIdReqMeanThroughput, NULL },
       
    85     { EPacketDataMinPrecedence, KCDTIdMinPrecedence, NULL },
       
    86     { EPacketDataMinDelay, KCDTIdMinDelay, NULL },
       
    87     { EPacketDataMinReliability, KCDTIdMinReliability, NULL },
       
    88     { EPacketDataMinPeakThroughput, KCDTIdMinPeakThroughput, NULL },
       
    89     { EPacketDataMinMeanThroughput, KCDTIdMinMeanThroughput, NULL },
       
    90     { EPacketDataDataCompression, KCDTIdWCDMADataCompression, NULL },
       
    91     { EPacketDataHeaderCompression, KCDTIdWCDMAHeaderCompression, NULL },
       
    92     { EPacketDataUseEdge, KCDTIdWCDMAUseEdge, NULL },
       
    93     { EPacketDataAnonymousAccess, KCDTIdWCDMAAnonymousAccess, NULL },
       
    94     { EPacketDataIFParams, KCDTIdWCDMAIfParams, NULL },
       
    95     { EPacketDataIFNetworks, KCDTIdWCDMAIfNetworks, NULL },
       
    96     { EPacketDataIFPromptForAuth, KCDTIdWCDMAIfPromptForAuth, NULL,
       
    97       R_QTN_SET_PROMPT_PASSWD,
       
    98       0, 0, 0, NULL, NULL },
       
    99     { EPacketDataIFAuthName, KCDTIdWCDMAIfAuthName, NULL,
       
   100       R_QTN_SET_AP_USERNAME,
       
   101       KMaxLoginNameLength, 0, R_QTN_SET_AP_USERNAME_NONE, R_TEXT_SETTING_PAGE_LOGIN_NAME, NULL, NULL },
       
   102     { EPacketDataIFAuthPass, KCDTIdWCDMAIfAuthPass, NULL,
       
   103       R_QTN_SET_AP_PASSWD,
       
   104       KCmMaxPasswordLength, EConvPassword, R_AVKON_NUMERIC_PASSWORD_BLANKING_TEXT, NULL, NULL },
       
   105     { EPacketDataIFAuthRetries, KCDTIdWCDMAIfAuthRetries, NULL },
       
   106     { EPacketDataIPNetmask, KCDTIdWCDMAIPNetMask, &CheckIPv4ValidityL },
       
   107     { EPacketDataIPGateway, KCDTIdWCDMAIPGateway, &CheckIPv4ValidityL },
       
   108     { EPacketDataIPAddrFromServer, KCDTIdWCDMAIPAddrFromServer, NULL },
       
   109     { EPacketDataIPAddr, KCDTIdWCDMAIPAddr, &CheckIPv4ValidityL,
       
   110       R_QTN_SET_IP_ADDRESS,
       
   111       KIpAddressWidth, EConvIPv4, R_QTN_SET_IP_ADDRESS_DYNAMIC, 0, NULL, NULL },
       
   112     { EPacketDataIPDNSAddrFromServer, KCDTIdWCDMAIPDNSAddrFromServer, NULL,
       
   113       R_QTN_SET_DNS_SERVERS_IP,
       
   114       0, 0, 0, 0, NULL, NULL },
       
   115     { EPacketDataIPNameServer1, KCDTIdWCDMAIPNameServer1, &CheckIPv4ValidityL,
       
   116       R_QTN_SET_PRIMARY_DNS,
       
   117       KMaxIPv4NameServerLength, EConvIPv4, R_QTN_SET_DNS_SERVERS_AUTOMATIC, 0, NULL, NULL },
       
   118     { EPacketDataIPNameServer2, KCDTIdWCDMAIPNameServer2, &CheckIPv4ValidityL,
       
   119       R_QTN_SET_SECONDARY_DNS,
       
   120       KMaxIPv4NameServerLength, EConvIPv4, R_QTN_SET_DNS_SERVERS_AUTOMATIC, 0, NULL, NULL },
       
   121     { EPacketDataIPIP6DNSAddrFromServer, KCDTIdWCDMAIP6DNSAddrFromServer, NULL,
       
   122       R_QTN_SET_DNS_SERVERS_IP,
       
   123       0, 0, 0, NULL, NULL },
       
   124     { EPacketDataIPIP6NameServer1, KCDTIdWCDMAIP6NameServer1, &CheckIPv6ValidityL },
       
   125     { EPacketDataIPIP6NameServer2, KCDTIdWCDMAIP6NameServer2, &CheckIPv6ValidityL },
       
   126     { EPacketDataIPAddrLeaseValidFrom, KCDTIdWCDMAIPAddrLeaseValidFrom, NULL },
       
   127     { EPacketDataIPAddrLeaseValidTo, KCDTIdWCDMAIPAddrLeaseValidTo, NULL },
       
   128     { EPacketDataConfigDaemonManagerName, KCDTIdWCDMAConfigDaemonManagerName, NULL },
       
   129     { EPacketDataConfigDaemonName, KCDTIdWCDMAConfigDaemonName, NULL },
       
   130     { EPacketDataEnableLcpExtension, KCDTIdWCDMAEnableLCPExtensions, NULL },
       
   131     { EPacketDataDisablePlainTextAuth, KCDTIdWCDMADisablePlainTextAuth, NULL,
       
   132       R_QTN_SET_PASSWD_AUT,
       
   133       0, 0, 0, NULL, NULL },
       
   134     { EPacketDataApType, KCDTIdAPType, NULL },
       
   135     { EPacketDataQoSWarningTimeOut, KCDTIdQOSWarningTimeOut, NULL },
       
   136     { EPacketDataServiceEnableLLMNR, KCDTIdServiceEnableLlmnr, NULL },
       
   137     { 0, 0, NULL }
       
   138 };
       
   139 
       
   140 static const TCmAttribConvTable SQoSDataConvTbl[] =
       
   141     {
       
   142     // iAttribId, iCommsDatId, iValidFuncL, 
       
   143     // iTitleId, 
       
   144     // iMaxLength, iAttribFlags, iDefValueResId, iEditorResId, iNotUsed1, iNotUsed2
       
   145     { EGPRSReqTrafficClass, EPacketDataRangeMax, NULL },
       
   146     { EGPRSReqTrafficClass, KCDTIdWCDMAReqTrafficClass, NULL },
       
   147     { EGPRSMinTrafficClass, KCDTIdWCDMAMinTrafficClass, NULL },
       
   148     { EGPRSReqDeliveryOrder, KCDTIdWCDMAReqDeliveryOrder, NULL },
       
   149     { GPRSMinDeliveryOrder, KCDTIdWCDMAMinDeliveryOrder, NULL },
       
   150     { EGPRSReqDeliverErroneousSDU, KCDTIdWCDMAReqDeliverErroneousSDU, NULL },
       
   151     { EGPRSMinDeliverErroneousSDU, KCDTIdWCDMAMinDeliverErroneousSDU, NULL },
       
   152     { EGPRSReqMaxSDUSize, KCDTIdWCDMAReqMaxSDUSize, NULL },
       
   153     { EGPRSMinAcceptableMaxSDUSize, KCDTIdWCDMAMinAcceptableMaxSDUSize, NULL },
       
   154     { EGPRSReqMaxUplinkRate, KCDTIdWCDMAReqMaxUplinkRate, NULL },
       
   155     { EGPRSReqMinUplinkRate, KCDTIdWCDMAReqMinUplinkRate, NULL },
       
   156     { EGPRSReqMaxDownlinkRate, KCDTIdWCDMAReqMaxDownlinkRate, NULL },
       
   157     { EGPRSReqMinDownlinkRate, KCDTIdWCDMAReqMinDownlinkRate, NULL },
       
   158     { EGPRSReqBER, KCDTIdWCDMAReqBER, NULL },
       
   159     { EGPRSMaxBER, KCDTIdWCDMAMaxBER, NULL },
       
   160     { EGPRSReqSDUErrorRatio, KCDTIdWCDMAReqSDUErrorRatio, NULL },
       
   161     { EGPRSMaxSDUErrorRatio, KCDTIdWCDMAMaxSDUErrorRatio, NULL },
       
   162     { EGPRSReqTrafficHandlingPriority, KCDTIdWCDMAReqTrafficHandlingPriority, NULL },
       
   163     { EGPRSMinTrafficHandlingPriority, KCDTIdWCDMAMinTrafficHandlingPriority, NULL },
       
   164     { EGPRSReqTransferDelay, KCDTIdWCDMAReqTransferDelay, NULL },
       
   165     { EGPRSMaxTransferDelay, KCDTIdWCDMAMaxTransferDelay, NULL },
       
   166     { EGPRSReqGuaranteedUplinkRate, KCDTIdWCDMAReqGuaranteedUplinkRate, NULL },
       
   167     { EGPRSMinGuaranteedUplinkRate, KCDTIdWCDMAMinGuaranteedUplinkRate, NULL },
       
   168     { EGPRSReqGuaranteedDownlinkRate, KCDTIdWCDMAReqGuaranteedDownlinkRate, NULL },
       
   169     { EGPRSMinGuaranteedDownlinkRate, KCDTIdWCDMAMinGuaranteedDownlinkRate, NULL },
       
   170     { EGPRSSignallingIndication, KCDTIdWCDMASignallingIndication, NULL },
       
   171     { EGPRS_ImCnSignallingIndication, KCDTIdWCDMAImCmSignallingIndication, NULL },
       
   172     { EGPRSSourceStatisticsDescriptor, KCDTIdWCDMASourceStatisticsDescriptor, NULL },
       
   173     { 0, 0, NULL }
       
   174     };
       
   175 
       
   176 static const TCmCommonAttrConvArrayItem SCommonConvTbl[] =
       
   177 {
       
   178     { EPacketDataIFParams, ECmIFParams },
       
   179     { EPacketDataIFNetworks, ECmIFNetworks },
       
   180     { EPacketDataIFPromptForAuth, ECmIFPromptForAuth },
       
   181     { EPacketDataIFAuthName, ECmIFAuthName },
       
   182     { EPacketDataIFAuthPass, ECmIFAuthPass },
       
   183     { EPacketDataIFAuthRetries, ECmIFAuthRetries },
       
   184     { EPacketDataIPNetmask, ECmIPNetmask },
       
   185     { EPacketDataIPGateway, ECmIPGateway },
       
   186     { EPacketDataIPAddrFromServer, ECmIPAddFromServer },
       
   187     { EPacketDataIPAddr, ECmIPAddress },
       
   188     { EPacketDataIPDNSAddrFromServer, ECmIPDNSAddrFromServer },
       
   189     { EPacketDataIPNameServer1, ECmIPNameServer1 },
       
   190     { EPacketDataIPNameServer2, ECmIPNameServer2 },
       
   191     { EPacketDataIPIP6DNSAddrFromServer, ECmIP6DNSAddrFromServer },
       
   192     { EPacketDataIPIP6NameServer1, ECmIP6NameServer1 },
       
   193     { EPacketDataIPIP6NameServer2, ECmIP6NameServer2 },
       
   194     { EPacketDataIPAddrLeaseValidFrom, ECmIPAddrLeaseValidFrom },
       
   195     { EPacketDataIPAddrLeaseValidTo, ECmIPAddrLeaseValidTo },
       
   196     { EPacketDataConfigDaemonManagerName, ECmConfigDaemonManagerName },
       
   197     { EPacketDataConfigDaemonName, ECmConfigDaemonName },
       
   198     { EPacketDataEnableLcpExtension, ECmEnableLPCExtension },
       
   199     { EPacketDataDisablePlainTextAuth, ECmDisablePlainTextAuth },
       
   200     { 0, 0 }
       
   201     };
       
   202     
       
   203 // ======== LOCAL FUNCTIONS ========
       
   204     
       
   205 static TBool SetPDPTypeL( CCmPluginBaseEng* aThis, 
       
   206                           TUint32 aAttribute, 
       
   207                           const TAny* aValue )
       
   208     {
       
   209     (void)aAttribute;
       
   210     CCmPluginPacketData* myThis = static_cast<CCmPluginPacketData*>( aThis );
       
   211     
       
   212     myThis->SetPDPTypeL( (RPacketContext::TProtocolType)(TInt)aValue );
       
   213     
       
   214     return ETrue;
       
   215     }
       
   216 
       
   217 // ======== MEMBER FUNCTIONS ========
       
   218 
       
   219 class CCmPDCoverageCheck : public CActive
       
   220     {
       
   221     enum EPacketCoverageState
       
   222         {
       
   223         EServiceStatus,
       
   224         EPDPAttach,
       
   225         EPDPDetach,                        
       
   226         };
       
   227         
       
   228     public:
       
   229     
       
   230         CCmPDCoverageCheck();
       
   231         ~CCmPDCoverageCheck();
       
   232         
       
   233         TBool IsThereCoverageL();
       
   234         
       
   235     protected:  // from CActive
       
   236     
       
   237         virtual void DoCancel();
       
   238         virtual void RunL();
       
   239 
       
   240     private:
       
   241 
       
   242         TUint32                 iProgState;
       
   243         TBool                   iCoverage;
       
   244         CActiveSchedulerWait    iWait;    
       
   245         RTelServer              iServer;
       
   246         RPhone                  iPhone;
       
   247         RPacketService          iService;        
       
   248     };
       
   249 
       
   250 // ----------------------------------------------------------------------------
       
   251 // CCmPDCoverageCheck::CCmPDCoverageCheck()
       
   252 // ----------------------------------------------------------------------------
       
   253 //
       
   254 CCmPDCoverageCheck::CCmPDCoverageCheck() : CActive( EPriorityStandard )
       
   255     {
       
   256     CActiveScheduler::Add( this );
       
   257     }
       
   258     
       
   259 // ----------------------------------------------------------------------------
       
   260 // CCmPDCoverageCheck::~CCmPDCoverageCheck()
       
   261 // ----------------------------------------------------------------------------
       
   262 //
       
   263 CCmPDCoverageCheck::~CCmPDCoverageCheck()
       
   264     {
       
   265     Cancel();
       
   266 
       
   267     iService.Close();
       
   268     iPhone.Close();
       
   269     iServer.Close();
       
   270     }
       
   271     
       
   272 // ----------------------------------------------------------------------------
       
   273 // CCmPDCoverageCheck::DoCancel
       
   274 // ----------------------------------------------------------------------------
       
   275 //
       
   276 void CCmPDCoverageCheck::DoCancel()
       
   277     {
       
   278     iWait.AsyncStop();
       
   279     }
       
   280     
       
   281 // ----------------------------------------------------------------------------
       
   282 // CCmPDCoverageCheck::RunL
       
   283 // ----------------------------------------------------------------------------
       
   284 //
       
   285 void CCmPDCoverageCheck::RunL()
       
   286     {
       
   287     switch( iProgState )
       
   288         {
       
   289         case EPDPAttach:
       
   290             {
       
   291             if( !iStatus.Int() )
       
   292                 // PDP context created -> there's a usable PD coverage.
       
   293                 {
       
   294                 iService.Detach( iStatus );
       
   295                 SetActive();
       
   296 
       
   297                 iCoverage = ETrue;
       
   298                 iProgState = EPDPDetach;
       
   299                 }
       
   300             else
       
   301                 // something went wrong -> no coverage.
       
   302                 {
       
   303                 iWait.AsyncStop();
       
   304                 }
       
   305             }
       
   306             break;
       
   307             
       
   308         case EPDPDetach:
       
   309             {
       
   310             iWait.AsyncStop();
       
   311             }
       
   312             break;
       
   313             
       
   314         default:
       
   315             {
       
   316             User::Leave( KErrCorrupt );
       
   317             }
       
   318         }
       
   319     }
       
   320     
       
   321 // ----------------------------------------------------------------------------
       
   322 // CCmPDCoverageCheck::IsThereCoverageL
       
   323 // ----------------------------------------------------------------------------
       
   324 //
       
   325 TBool CCmPDCoverageCheck::IsThereCoverageL()
       
   326     {
       
   327     iProgState = EServiceStatus;
       
   328     iCoverage = EFalse;
       
   329     
       
   330     User::LeaveIfError( iServer.Connect() );
       
   331     CLOG_WRITE( "Server open" );
       
   332     
       
   333     RTelServer::TPhoneInfo info;
       
   334     User::LeaveIfError( iServer.GetPhoneInfo( 0, info ) );
       
   335     CLOG_WRITE( "Phone info ok" );
       
   336     
       
   337     User::LeaveIfError( iPhone.Open(iServer, info.iName ) );
       
   338     CLOG_WRITE( "Phone open" );
       
   339 
       
   340     User::LeaveIfError( iService.Open( iPhone ) );
       
   341     CLOG_WRITE( "service ok" );
       
   342 
       
   343     RPacketService::TStatus status;
       
   344     User::LeaveIfError( iService.GetStatus( status ) );
       
   345     if( status == RPacketService::EStatusAttached ||
       
   346         status == RPacketService::EStatusActive || 
       
   347         status == RPacketService::EStatusSuspended )
       
   348         // Attached/active/suspened, so there's a coverage
       
   349         {
       
   350         iCoverage = ETrue;
       
   351         }
       
   352     else if( status == RPacketService::EStatusUnattached )
       
   353         {
       
   354         iProgState = EPDPAttach;
       
   355         iService.Attach( iStatus );
       
   356         SetActive();
       
   357         iWait.Start();
       
   358         }
       
   359     else
       
   360         {
       
   361         CLOG_WRITE( "Unknown state" );
       
   362         }
       
   363         
       
   364 
       
   365     User::LeaveIfError( iStatus.Int() );
       
   366     
       
   367     return iCoverage;
       
   368     }
       
   369 
       
   370 // ----------------------------------------------------------------------------
       
   371 // CCmPluginPacketData::NewOutgoingL
       
   372 // ----------------------------------------------------------------------------
       
   373 //
       
   374 CCmPluginPacketData* CCmPluginPacketData::NewL(
       
   375                                             TCmPluginInitParam* aInitParam )
       
   376 	{
       
   377 	CCmPluginPacketData* self = new ( ELeave ) CCmPluginPacketData( 
       
   378 	                                                    aInitParam, ETrue );
       
   379 	CleanupStack::PushL( self );
       
   380 	self->ConstructL();
       
   381 	CleanupStack::Pop( self );
       
   382 	return self;
       
   383 	}
       
   384 
       
   385 // ----------------------------------------------------------------------------
       
   386 // CCmPluginPacketData::~CCmPluginPacketData
       
   387 // ----------------------------------------------------------------------------
       
   388 //
       
   389 CCmPluginPacketData::~CCmPluginPacketData()
       
   390 	{
       
   391 	CCmPluginPacketData::AdditionalReset();	
       
   392 	RemoveResourceFile( KPluginPacketDataResDirAndFileName );	
       
   393 	CLOG_CLOSE;
       
   394 	}
       
   395 
       
   396 // ----------------------------------------------------------------------------
       
   397 // CCmPluginPacketData::CreateInstanceL
       
   398 // ----------------------------------------------------------------------------
       
   399 //
       
   400 CCmPluginBaseEng* CCmPluginPacketData::CreateInstanceL( TCmPluginInitParam& aInitParam ) const
       
   401     {
       
   402     CCmPluginPacketData* self = new( ELeave ) CCmPluginPacketData( &aInitParam, ETrue );
       
   403     CleanupStack::PushL( self );
       
   404     self->ConstructL();
       
   405     CleanupStack::Pop( self );
       
   406 
       
   407     return self;
       
   408     }
       
   409     
       
   410 // ----------------------------------------------------------------------------
       
   411 // CCmPluginPacketData::CCmPluginPacketData
       
   412 // ----------------------------------------------------------------------------
       
   413 //
       
   414 CCmPluginPacketData::CCmPluginPacketData( TCmPluginInitParam* aInitParam,
       
   415                                           TBool aOutgoing )
       
   416     : CCmPluginBaseEng( aInitParam )
       
   417     , iOutgoing( aOutgoing )
       
   418 	{
       
   419 	CLOG_CREATE;
       
   420 	
       
   421 	iBearerType = KUidPacketDataBearerType;
       
   422 	}
       
   423 
       
   424 // ----------------------------------------------------------------------------
       
   425 // CCmPluginPacketData::ConstructL
       
   426 // ----------------------------------------------------------------------------
       
   427 //
       
   428 void CCmPluginPacketData::ConstructL()
       
   429 	{
       
   430 	CCmPluginBaseEng::ConstructL();
       
   431 
       
   432     AddResourceFileL( KPluginPacketDataResDirAndFileName );
       
   433 	AddConverstionTableL( (CCDRecordBase**)&iServiceRecord, NULL, SPacketDataConvTbl );
       
   434     AddConverstionTableL( (CCDRecordBase**)&iPacketDataQoSRecord, NULL, SQoSDataConvTbl );
       
   435 	AddCommonConversionTableL( SCommonConvTbl );
       
   436 	}
       
   437 	
       
   438 // ----------------------------------------------------------------------------
       
   439 // CCmPluginPacketData::GetIntAttributeL()
       
   440 // ----------------------------------------------------------------------------
       
   441 //
       
   442 TUint32 CCmPluginPacketData::GetIntAttributeL( const TUint32 aAttribute ) const
       
   443 	{
       
   444     LOGGER_ENTERFN( "CCmPluginPacketData::GetIntAttributeL" );
       
   445 
       
   446     TUint32 retVal( 0 );
       
   447     
       
   448     switch( aAttribute )
       
   449         {
       
   450         case ECmBearerIcon:
       
   451             {
       
   452             TAknsItemID id;
       
   453             MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   454                    
       
   455             TParse mbmFile;
       
   456             User::LeaveIfError( mbmFile.Set( KPacketDataFileIcons, 
       
   457                                                     &KDC_BITMAP_DIR, NULL ) );
       
   458 
       
   459                    
       
   460             retVal = (TUint32)AknsUtils::CreateGulIconL( 
       
   461                                     skinInstance, 
       
   462                                     id,
       
   463                                     mbmFile.FullName(), 
       
   464                                     EMbmCmpluginpacketdataQgn_prop_wml_gprs, 
       
   465                                     EMbmCmpluginpacketdataQgn_prop_wml_gprs_mask );
       
   466             }
       
   467             break;
       
   468                
       
   469         case ECmBearerAvailableIcon:
       
   470             {
       
   471             TAknsItemID id;
       
   472             MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   473                    
       
   474             TParse mbmFile;
       
   475             User::LeaveIfError( mbmFile.Set( KPacketDataFileIcons, &KDC_BITMAP_DIR, NULL ) );
       
   476                    
       
   477             retVal = (TUint32)AknsUtils::CreateGulIconL( 
       
   478                     skinInstance, 
       
   479                     id,
       
   480                     mbmFile.FullName(), 
       
   481                     EMbmCmpluginpacketdataQgn_prop_set_conn_bearer_avail_packetdata, 
       
   482                     EMbmCmpluginpacketdataQgn_prop_set_conn_bearer_avail_packetdata_mask );
       
   483             }
       
   484             break;
       
   485             
       
   486         case ECmCommsDBBearerType:
       
   487             {
       
   488             retVal = KCommDbBearerWcdma;
       
   489             }
       
   490             break;
       
   491             
       
   492         case ECmDefaultUiPriority:
       
   493         case ECmDefaultPriority:
       
   494             {
       
   495             TPtrC buf;
       
   496             
       
   497             if( iOutgoing )
       
   498                 {
       
   499                 buf.Set( KCDTypeNameOutgoingWCDMA );
       
   500                 }
       
   501             else
       
   502                 {
       
   503                 buf.Set( KCDTypeNameIncomingWCDMA );
       
   504                 }
       
   505 
       
   506             retVal = aAttribute == ECmDefaultPriority ?
       
   507                      GlobalBearerPriority( buf ) :
       
   508                      GlobalUiBearerPriority( buf );
       
   509             
       
   510             if( retVal == KDataMobilitySelectionPolicyPriorityWildCard )
       
   511                 {
       
   512                 retVal = KDefaultPriorityPacketData;
       
   513                 }
       
   514             }
       
   515             break;
       
   516             
       
   517         default:
       
   518             {
       
   519             retVal = CCmPluginBaseEng::GetIntAttributeL( aAttribute );
       
   520             }
       
   521             break;
       
   522         }
       
   523         
       
   524     return retVal;
       
   525 	}
       
   526 
       
   527 // ----------------------------------------------------------------------------
       
   528 // CCmPluginPacketData::GetBoolAttributeL()
       
   529 // ----------------------------------------------------------------------------
       
   530 //
       
   531 TBool CCmPluginPacketData::GetBoolAttributeL( const TUint32 aAttribute ) const
       
   532 	{
       
   533     LOGGER_ENTERFN( "CCmPluginPacketData::GetBoolAttributeL" );
       
   534 
       
   535     TBool retVal( EFalse );
       
   536 
       
   537     switch( aAttribute )
       
   538         {
       
   539         case EPacketDataOutGoing:
       
   540             {
       
   541             retVal = iOutgoing;
       
   542             }
       
   543             break;
       
   544             
       
   545         case ECmCoverage:
       
   546             // In default the plugin has no network coverage
       
   547             {
       
   548             retVal = CheckNetworkCoverageL();
       
   549             }
       
   550             break;
       
   551             
       
   552         case ECmAddToAvailableList:
       
   553             {
       
   554             retVal = ETrue;
       
   555             }
       
   556             break;
       
   557             
       
   558         case ECmBearerHasUi:
       
   559             {
       
   560             retVal = ETrue;
       
   561             }
       
   562             break;
       
   563             
       
   564         default:
       
   565             {
       
   566             retVal = CCmPluginBaseEng::GetBoolAttributeL( aAttribute );
       
   567             }
       
   568         }
       
   569         
       
   570     return retVal;
       
   571 	}
       
   572 
       
   573 // ----------------------------------------------------------------------------
       
   574 // CCmPluginPacketData::GetStringAttributeL()
       
   575 // ----------------------------------------------------------------------------
       
   576 //
       
   577 HBufC* CCmPluginPacketData::GetStringAttributeL( const TUint32 aAttribute ) const
       
   578 	{
       
   579     LOGGER_ENTERFN( "CCmPluginPacketData::GetStringAttributeL" );
       
   580 
       
   581 	HBufC* retVal = NULL;
       
   582 	
       
   583 	switch( aAttribute )
       
   584 	    {
       
   585 	    case ECmBearerAvailableName:
       
   586 	        {
       
   587 	        retVal = AllocReadL( R_QTN_NETW_CONSET_BEARER_AVAILABLE_PACKET_DATA );
       
   588 	        }
       
   589 	        break;
       
   590 	        
       
   591 	    case ECmBearerSupportedName:
       
   592 	        {
       
   593 	        retVal = AllocReadL( R_QTN_NETW_CONSET_BEARER_SUPPORTED_PACKET_DATA );
       
   594 	        }
       
   595 	        break;
       
   596 	        
       
   597         case ECmBearerAvailableText:
       
   598             {
       
   599             retVal = AllocReadL( R_QTN_NETW_CONSET_PACKET_DATA_AVAILABLE );
       
   600             }
       
   601             break;
       
   602             
       
   603 	    case ECmBearerNamePopupNote:
       
   604 	        {
       
   605 	        retVal = AllocReadL( R_QTN_NETW_CONSET_POPUP_BEARER_PACKET_DATA );
       
   606 	        }
       
   607 	        break;
       
   608 
       
   609 	    case ECmBearerSettingName:
       
   610 	        {
       
   611 	        retVal = AllocReadL( R_QTN_SET_BEARER_PACKET_DATA );
       
   612 	        }
       
   613 	        break;
       
   614 	        
       
   615 	    default:
       
   616 	        {
       
   617 	        retVal = CCmPluginBaseEng::GetStringAttributeL( aAttribute );
       
   618 	        }
       
   619 	        break;
       
   620 	    }
       
   621 	    
       
   622     return retVal;
       
   623 	}
       
   624 
       
   625 // ----------------------------------------------------------------------------
       
   626 // CCmPluginPacketData::SetIntAttributeL()
       
   627 // ----------------------------------------------------------------------------
       
   628 //
       
   629 void CCmPluginPacketData::SetIntAttributeL( const TUint32 aAttribute, 
       
   630                                             TUint32 aValue )
       
   631 	{
       
   632     LOGGER_ENTERFN( "CCmPluginPacketData::SetIntAttributeL" );
       
   633 
       
   634     switch( aAttribute )
       
   635         {
       
   636         default:
       
   637             {
       
   638             CCmPluginBaseEng::SetIntAttributeL( aAttribute, aValue );
       
   639             }
       
   640         }
       
   641 	}
       
   642 
       
   643 // ----------------------------------------------------------------------------
       
   644 // CCmPluginPacketData::SetBoolAttributeL()
       
   645 // ----------------------------------------------------------------------------
       
   646 //
       
   647 void CCmPluginPacketData::SetBoolAttributeL( const TUint32 aAttribute, 
       
   648                                              TBool aValue )
       
   649 	{
       
   650     LOGGER_ENTERFN( "CCmPluginPacketData::SetBoolAttributeL" );
       
   651 
       
   652     switch( aAttribute )
       
   653         {
       
   654         case EPacketDataOutGoing:
       
   655             {
       
   656             iOutgoing = aValue;
       
   657             CreateNewServiceRecordL();
       
   658             }
       
   659             break;
       
   660         
       
   661         default:
       
   662             {
       
   663             CCmPluginBaseEng::SetBoolAttributeL( aAttribute, aValue );
       
   664             }
       
   665         }
       
   666 	}
       
   667 
       
   668 // ----------------------------------------------------------------------------
       
   669 // CCmPluginPacketData::SetStringAttributeL()
       
   670 // ----------------------------------------------------------------------------
       
   671 //
       
   672 void CCmPluginPacketData::SetStringAttributeL( const TUint32 aAttribute, 
       
   673                                                const TDesC16& aValue )
       
   674 	{
       
   675     LOGGER_ENTERFN( "CCmPluginPacketData::SetStringAttributeL" );
       
   676 
       
   677     switch( aAttribute )
       
   678         {
       
   679         default:
       
   680             {
       
   681             CCmPluginBaseEng::SetStringAttributeL( aAttribute, aValue );
       
   682             }
       
   683         }
       
   684 	}
       
   685 
       
   686 // ----------------------------------------------------------------------------
       
   687 // CCmPluginPacketData::PrepareToUpdateRecordsL()
       
   688 // ----------------------------------------------------------------------------
       
   689 //
       
   690 void CCmPluginPacketData::PrepareToUpdateRecordsL()
       
   691     {
       
   692     LOGGER_ENTERFN( "CCmPluginPacketData::PrepareToUpdateRecordsL" );
       
   693 
       
   694     CheckDNSServerAddressL( ETrue, 
       
   695                             ServiceRecord().iGPRSIP6NameServer1,
       
   696                             ServiceRecord().iGPRSIP6NameServer2,
       
   697                             ServiceRecord().iGPRSIP6DNSAddrFromServer );
       
   698                             
       
   699     CheckDNSServerAddressL( EFalse,
       
   700                             ServiceRecord().iGPRSIPNameServer1,
       
   701                             ServiceRecord().iGPRSIPNameServer2,
       
   702                             ServiceRecord().iGPRSIPDNSAddrFromServer );
       
   703     SetDaemonNameL();
       
   704     }
       
   705     
       
   706 // ----------------------------------------------------------------------------
       
   707 // CCmPluginPacketData::CanHandleIapIdL()
       
   708 // ----------------------------------------------------------------------------
       
   709 //
       
   710 TBool CCmPluginPacketData::CanHandleIapIdL( TUint32 aIapId ) const
       
   711     {
       
   712     LOGGER_ENTERFN( "CCmPluginPacketData::CanHandleIapIdL1" );
       
   713     CLOG_WRITE_1( "IapId: [%d]", aIapId );
       
   714     
       
   715     TBool retVal( EFalse );
       
   716     
       
   717     CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *>
       
   718                             (CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord));
       
   719         
       
   720     CleanupStack::PushL( iapRecord );
       
   721     iapRecord->SetRecordId( aIapId );
       
   722     
       
   723     TRAPD( err, iapRecord->LoadL( Session() ));
       
   724 
       
   725     if( !err )
       
   726         {
       
   727         CanHandleIapIdL( iapRecord );
       
   728         }
       
   729     
       
   730     CleanupStack::PopAndDestroy( iapRecord );
       
   731     return retVal;
       
   732     }
       
   733 
       
   734 // ----------------------------------------------------------------------------
       
   735 // CCmPluginPacketData::CanHandleIapIdL()
       
   736 // ----------------------------------------------------------------------------
       
   737 //
       
   738 TBool CCmPluginPacketData::CanHandleIapIdL( CCDIAPRecord *aIapRecord ) const
       
   739     {
       
   740     LOGGER_ENTERFN( "CCmPluginPacketData::CanHandleIapIdL2" );
       
   741     CLOG_WRITE_1( "IapId: [%d]", aIapRecord->RecordId() );
       
   742     
       
   743     TBool retVal( EFalse );
       
   744     
       
   745     CLOG_WRITE_2( "IAP record: [%S][%S]",
       
   746                     &FIELD_TO_TDESC(aIapRecord->iServiceType), 
       
   747                     &FIELD_TO_TDESC(aIapRecord->iBearerType)
       
   748                 );
       
   749     
       
   750     if( (TPtrC(aIapRecord->iServiceType) == TPtrC(KCDTypeNameOutgoingWCDMA) ||
       
   751         TPtrC(aIapRecord->iServiceType) == TPtrC(KCDTypeNameIncomingWCDMA)) &&
       
   752         TPtrC(aIapRecord->iBearerType) == TPtrC(KCDTypeNameModemBearer) )
       
   753         {
       
   754         CLOG_WRITE( "I can." );
       
   755         retVal = ETrue;
       
   756         }
       
   757 
       
   758     return retVal;
       
   759     }
       
   760 
       
   761 // ----------------------------------------------------------------------------
       
   762 // CCmPluginPacketData::RunSettingsL()
       
   763 // ----------------------------------------------------------------------------
       
   764 //        
       
   765 TInt CCmPluginPacketData::RunSettingsL()
       
   766 	{
       
   767     CmPluginPacketDataSettingsDlg* settingsDlg = 
       
   768                                 CmPluginPacketDataSettingsDlg::NewL( *this );
       
   769     return settingsDlg->ConstructAndRunLD( );       
       
   770     }        
       
   771 
       
   772 // ----------------------------------------------------------------------------
       
   773 // CCmPluginPacketData::LoadServiceSettingL()
       
   774 // ----------------------------------------------------------------------------
       
   775 //        
       
   776 void CCmPluginPacketData::LoadServiceSettingL()
       
   777     {
       
   778     LOGGER_ENTERFN( "CCmPluginPacketData::LoadServiceSettingL" );
       
   779     
       
   780     if( TPtrC(KCDTypeNameOutgoingWCDMA) == iIapRecord->iServiceType  )
       
   781         {
       
   782         iServiceRecord = static_cast<CCDServiceRecordBase *>
       
   783                     (CCDRecordBase::RecordFactoryL(KCDTIdOutgoingGprsRecord));
       
   784         iOutgoing = ETrue;
       
   785         }
       
   786     else if( TPtrC(KCDTypeNameIncomingWCDMA) == iIapRecord->iServiceType )
       
   787         {
       
   788         iServiceRecord = static_cast<CCDServiceRecordBase *>
       
   789                     (CCDRecordBase::RecordFactoryL(KCDTIdIncomingGprsRecord));
       
   790         iOutgoing = EFalse;
       
   791         }
       
   792     else
       
   793         // this IAP service is not supported by this plugin.
       
   794         {
       
   795         User::Leave( KErrNotSupported );
       
   796         }
       
   797 
       
   798     CCmPluginBaseEng::LoadServiceSettingL();
       
   799 
       
   800     CLOG_WRITE_1( "APName: [%S]", &FIELD_TO_TDESC( ServiceRecord().iGPRSAPN ) );
       
   801     }
       
   802 
       
   803 // ----------------------------------------------------------------------------
       
   804 // CCmPluginPacketData::InitializeWithUiL()
       
   805 // ----------------------------------------------------------------------------
       
   806 //        
       
   807 TBool CCmPluginPacketData::InitializeWithUiL( TBool /*aManuallyConfigure*/ )
       
   808     {
       
   809     LOGGER_ENTERFN( "CCmPluginPacketData::InitializeWithUiL" );    
       
   810     TBool retval = ETrue;   // meaning that everything was fine.
       
   811 
       
   812     // Add resource file for the duration of this method only.
       
   813     TParse parser;
       
   814     User::LeaveIfError( parser.Set( KPluginPacketDataResDirAndFileName, 
       
   815                                     &KDC_RESOURCE_FILES_DIR, 
       
   816                                     NULL ) );
       
   817 
       
   818     TFileName resourceFileNameBuf = parser.FullName();
       
   819 
       
   820     RConeResourceLoader resLoader( *CEikonEnv::Static() ) ;
       
   821     resLoader.OpenL( resourceFileNameBuf );
       
   822     CleanupClosePushL( resLoader );
       
   823 
       
   824     // Show dialog
       
   825     TBuf<KMaxGprsApNameLength> buf;
       
   826     CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog( buf );
       
   827 
       
   828     // Must use PrepareLC instead of ExecuteLD in order for
       
   829     // MakeLeftSoftkeyVisible() call to work.
       
   830     dlg->PrepareLC( R_APN_NAME_QUERY );
       
   831 
       
   832     dlg->SetMaxLength( KMaxGprsApNameLength );
       
   833     dlg->MakeLeftSoftkeyVisible( ETrue );   // Empty input accepted.
       
   834 
       
   835     HBufC* prompt = StringLoader::LoadLC( R_GPRS_PLUGIN_APN_PROMPT );
       
   836     dlg->SetPromptL( *prompt );
       
   837     CleanupStack::PopAndDestroy( prompt );
       
   838 
       
   839     // Strange, but true: RunLD returns 0 (instead of the actual command id)
       
   840     // if Cancel button was pressed, thus we have to check against zero here.
       
   841     if ( dlg->RunLD() )
       
   842         {
       
   843         // Change APN attribute in connection method
       
   844         SetStringAttributeL( EPacketDataAPName, buf );
       
   845         
       
   846         if( buf.Length() )
       
   847             {
       
   848             SetStringAttributeL( ECmName, buf );
       
   849             }
       
   850         }
       
   851     else
       
   852         {
       
   853         retval = EFalse;    // indicating cancellation.
       
   854         }
       
   855 
       
   856     // Clean-up
       
   857     CleanupStack::PopAndDestroy( &resLoader );
       
   858 
       
   859     return retval;
       
   860     }
       
   861 
       
   862 
       
   863 // ----------------------------------------------------------------------------
       
   864 // CCmPluginPacketData::ServiceRecord()
       
   865 // ----------------------------------------------------------------------------
       
   866 //        
       
   867 CCDWCDMAPacketServiceRecord& CCmPluginPacketData::ServiceRecord() const
       
   868     {
       
   869     LOGGER_ENTERFN( "CCmPluginPacketData::ServiceRecord" );
       
   870 
       
   871     return *static_cast<CCDWCDMAPacketServiceRecord*>(iServiceRecord);
       
   872     }
       
   873     
       
   874 // ----------------------------------------------------------------------------
       
   875 // CCmPluginPacketData::CreateNewServiceRecordL()
       
   876 // ----------------------------------------------------------------------------
       
   877 //        
       
   878 void CCmPluginPacketData::CreateNewServiceRecordL()
       
   879     {
       
   880     LOGGER_ENTERFN( "CCmPluginPacketData::CreateNewServiceRecordL" );
       
   881 
       
   882     delete iServiceRecord; iServiceRecord = NULL;
       
   883     
       
   884     if( iOutgoing )
       
   885         {
       
   886         iServiceRecord = static_cast<CCDServiceRecordBase *>
       
   887                     (CCDRecordBase::RecordFactoryL(KCDTIdOutgoingGprsRecord));
       
   888         }
       
   889     else
       
   890         {
       
   891         iServiceRecord = static_cast<CCDServiceRecordBase *>
       
   892                     (CCDRecordBase::RecordFactoryL(KCDTIdIncomingGprsRecord));
       
   893         }
       
   894 
       
   895     ServiceRecord().iGPRSAPN.SetL( KNullDesC );
       
   896     ServiceRecord().iGPRSPDPType.SetL( RPacketContext::EPdpTypeIPv4 );
       
   897     ServiceRecord().iGPRSReqPrecedence = 0;
       
   898 	ServiceRecord().iGPRSReqDelay = 0;
       
   899 	ServiceRecord().iGPRSReqReliability = 0;
       
   900 	ServiceRecord().iGPRSReqPeakThroughput = 0;
       
   901 	ServiceRecord().iGPRSReqMeanThroughput = 0;
       
   902 	ServiceRecord().iGPRSMinPrecedence = 0;
       
   903 	ServiceRecord().iGPRSMinDelay = 0;
       
   904 	ServiceRecord().iGPRSMinReliability = 0;
       
   905 	ServiceRecord().iGPRSMinPeakThroughput = 0;
       
   906 	ServiceRecord().iGPRSMinMeanThroughput = 0;
       
   907 	ServiceRecord().iGPRSDataCompression = 0;
       
   908 	ServiceRecord().iGPRSHeaderCompression = 0;
       
   909 	ServiceRecord().iGPRSAnonymousAccess = 0;
       
   910     ServiceRecord().iGPRSIfNetworks.SetL( KDefIspIfNetworksIPv4 );
       
   911     ServiceRecord().iGPRSIfPromptForAuth = EFalse;
       
   912     ServiceRecord().iGPRSIfAuthRetries = 0;
       
   913     ServiceRecord().iGPRSIPGateway.SetL( KUnspecifiedIPv4 );
       
   914     ServiceRecord().iGPRSIPAddrFromServer = ETrue;
       
   915     ServiceRecord().iGPRSIPAddr.SetL( KUnspecifiedIPv4 );
       
   916     ServiceRecord().iGPRSIPDNSAddrFromServer = ETrue;
       
   917     ServiceRecord().iGPRSIPNameServer1.SetL( KUnspecifiedIPv4 );
       
   918     ServiceRecord().iGPRSIPNameServer2.SetL( KUnspecifiedIPv4 );
       
   919     ServiceRecord().iGPRSIP6DNSAddrFromServer = ETrue;
       
   920     ServiceRecord().iGPRSIP6NameServer1.SetL( KDynamicIpv6Address );
       
   921     ServiceRecord().iGPRSIP6NameServer2.SetL( KDynamicIpv6Address );
       
   922     ServiceRecord().iGPRSEnableLCPExtension = EFalse;
       
   923     ServiceRecord().iGPRSDisablePlainTextAuth = ETrue;
       
   924     ServiceRecord().iGPRSAPType = EPacketDataBoth;
       
   925     ServiceRecord().iGPRSQOSWarningTimeOut = TUint32(-1);
       
   926     }
       
   927 
       
   928 // ----------------------------------------------------------------------------
       
   929 // CCmPluginPacketData::ServiceRecordIdLC
       
   930 // ----------------------------------------------------------------------------
       
   931 //
       
   932 void CCmPluginPacketData::ServiceRecordIdLC( HBufC* &aName, 
       
   933                                              TUint32& aRecordId )
       
   934     {
       
   935     LOGGER_ENTERFN( "CCmPluginPacketData::ServiceRecordIdLC" );
       
   936 
       
   937     if( iOutgoing )
       
   938         {
       
   939         aName = TPtrC( KCDTypeNameOutgoingWCDMA ).AllocLC();
       
   940         }
       
   941     else
       
   942         {
       
   943         aName = TPtrC( KCDTypeNameIncomingWCDMA ).AllocLC();
       
   944         }
       
   945         
       
   946     aRecordId = iServiceRecord->RecordId();
       
   947     }
       
   948 
       
   949 // ----------------------------------------------------------------------------
       
   950 // CCmPluginPacketData::BearerRecordIdLC()
       
   951 // ----------------------------------------------------------------------------
       
   952 //        
       
   953 void CCmPluginPacketData::BearerRecordIdLC( HBufC* &aBearerName, 
       
   954                                             TUint32& aRecordId )
       
   955     {
       
   956     LOGGER_ENTERFN( "CCmPluginPacketData::BearerRecordIdLC" );
       
   957 
       
   958 	CMDBRecordSet<CCDModemBearerRecord>* bearerRS = 
       
   959 	        new(ELeave) CMDBRecordSet<CCDModemBearerRecord>(KCDTIdModemBearerRecord);
       
   960 	CleanupStack::PushL( bearerRS );
       
   961     
       
   962     CCDModemBearerRecord* bearerRecord = static_cast<CCDModemBearerRecord *>
       
   963                             (CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord));
       
   964                                     
       
   965     CleanupStack::PushL( bearerRecord );
       
   966     
       
   967     bearerRecord->iRecordName.SetL( KModemBearerPacketData );
       
   968     bearerRS->iRecords.AppendL( bearerRecord );
       
   969     CleanupStack::Pop( bearerRecord );
       
   970     
       
   971     if( bearerRS->FindL( Session() ) )
       
   972         {
       
   973         CLOG_WRITE_1( "Bearers: [%d]", bearerRS->iRecords.Count() );
       
   974 
       
   975         bearerRecord = static_cast<CCDModemBearerRecord*>(bearerRS->iRecords[0]);
       
   976         aRecordId = bearerRecord->RecordId();
       
   977         }
       
   978     else
       
   979         // bearer not found -> create dummy values
       
   980         {
       
   981         CLOG_WRITE( "No bearer record found" );
       
   982 
       
   983         bearerRecord->SetRecordId( KCDNewRecordRequest );
       
   984         bearerRecord->StoreL( Session() );
       
   985         
       
   986         aRecordId = bearerRecord->RecordId();
       
   987         }
       
   988 
       
   989     CleanupStack::PopAndDestroy( bearerRS );
       
   990 
       
   991     aBearerName = TPtrC(KCDTypeNameModemBearer).AllocLC();
       
   992     }
       
   993 
       
   994 // ----------------------------------------------------------------------------
       
   995 // CCmPluginPacketData::CheckNetworkCoverageL()
       
   996 // ----------------------------------------------------------------------------
       
   997 //        
       
   998 TBool CCmPluginPacketData::CheckNetworkCoverageL() const
       
   999     {
       
  1000     LOGGER_ENTERFN("CCmPluginPacketData::CheckNetworkCoverageL");
       
  1001     
       
  1002     TBool retVal( EFalse );
       
  1003     
       
  1004 #ifdef __WINS__
       
  1005     retVal = ETrue;
       
  1006 #else
       
  1007     CCmPDCoverageCheck* coverage = new (ELeave) CCmPDCoverageCheck;
       
  1008     CleanupStack::PushL( coverage );
       
  1009     
       
  1010     retVal = coverage->IsThereCoverageL();
       
  1011     
       
  1012     CleanupStack::PopAndDestroy( coverage );
       
  1013     
       
  1014 #endif  // __WINS
       
  1015     return retVal;
       
  1016     }
       
  1017 
       
  1018 // ----------------------------------------------------------------------------
       
  1019 // CCmPluginPacketData::SetPDPTypeL()
       
  1020 // ----------------------------------------------------------------------------
       
  1021 //        
       
  1022 void CCmPluginPacketData::SetPDPTypeL( RPacketContext::TProtocolType aPdpType )
       
  1023     {
       
  1024     LOGGER_ENTERFN( "CCmPluginPacketData::SetPDPTypeL" );
       
  1025 
       
  1026     if( aPdpType != RPacketContext::EPdpTypeIPv4 &&
       
  1027         aPdpType != RPacketContext::EPdpTypeIPv6 )
       
  1028         {
       
  1029         User::Leave( KErrArgument );
       
  1030         }
       
  1031         
       
  1032     if( FeatureSupported( KFeatureIdIPv6 ) && aPdpType == 
       
  1033         RPacketContext::EPdpTypeIPv6 )
       
  1034         {
       
  1035         ServiceRecord().iGPRSPDPType = RPacketContext::EPdpTypeIPv6;
       
  1036         ServiceRecord().iGPRSIfNetworks.SetL( KDefIspIfNetworksIPv6 );
       
  1037         }
       
  1038     else
       
  1039         {
       
  1040         if( aPdpType == RPacketContext::EPdpTypeIPv6 )
       
  1041             {
       
  1042             User::Leave( KErrNotSupported );
       
  1043             }
       
  1044             
       
  1045         ServiceRecord().iGPRSIfNetworks.SetL( KDefIspIfNetworksIPv4 );
       
  1046         ServiceRecord().iGPRSPDPType = RPacketContext::EPdpTypeIPv4;
       
  1047         }
       
  1048     }
       
  1049     
       
  1050 // ----------------------------------------------------------------------------
       
  1051 // CCmPluginPacketData::AdditionalReset()
       
  1052 // ----------------------------------------------------------------------------
       
  1053 //        
       
  1054 void CCmPluginPacketData::AdditionalReset()
       
  1055     {
       
  1056     LOGGER_ENTERFN( "CCmPluginPacketData::AdditionalReset" );
       
  1057 
       
  1058     delete iPacketDataQoSRecord;
       
  1059     iPacketDataQoSRecord = NULL;
       
  1060     }
       
  1061 
       
  1062 // ---------------------------------------------------------------------------
       
  1063 // CCmPluginPacketData::PrepareToCopyDataL
       
  1064 // ---------------------------------------------------------------------------
       
  1065 //
       
  1066 void CCmPluginPacketData::PrepareToCopyDataL( CCmPluginBaseEng* aDestInst ) const
       
  1067     {
       
  1068     LOGGER_ENTERFN( "CCmPluginPacketData::PrepareToCopyDataL" );
       
  1069 
       
  1070     aDestInst->SetBoolAttributeL( EPacketDataOutGoing, iOutgoing );
       
  1071     }
       
  1072 
       
  1073 
       
  1074 // ---------------------------------------------------------------------------
       
  1075 // CCmPluginPacketData::SetDaemonNameL
       
  1076 // ---------------------------------------------------------------------------
       
  1077 //
       
  1078 void CCmPluginPacketData::SetDaemonNameL()
       
  1079     {
       
  1080     LOGGER_ENTERFN( "CCmPluginPacketData::SetDaemonNameL" );
       
  1081 
       
  1082     // use DHCP if we can
       
  1083     TBool ipfromSrv = GetBoolAttributeL( ECmIPAddFromServer );
       
  1084     if ( ipfromSrv )
       
  1085         {
       
  1086         SetStringAttributeL( ECmConfigDaemonManagerName, 
       
  1087                            KDaemonManagerName );
       
  1088         SetStringAttributeL( ECmConfigDaemonName, 
       
  1089                            KConfigDaemonName );
       
  1090         }
       
  1091     else
       
  1092         {
       
  1093         if ( FeatureSupported( KFeatureIdIPv6 ) )
       
  1094             {
       
  1095             SetStringAttributeL( ECmConfigDaemonManagerName, 
       
  1096                                KDaemonManagerName );
       
  1097             SetStringAttributeL( ECmConfigDaemonName, 
       
  1098                                KConfigDaemonName );
       
  1099             }
       
  1100         else
       
  1101             {
       
  1102             SetStringAttributeL( ECmConfigDaemonManagerName, 
       
  1103                                KNullDesC() );
       
  1104             SetStringAttributeL( ECmConfigDaemonName, 
       
  1105                                KNullDesC() );
       
  1106             }
       
  1107         }
       
  1108     }
       
  1109 
       
  1110 
       
  1111 // ---------------------------------------------------------------------------
       
  1112 // CCmPluginPacketData::CreateAdditionalRecordsL
       
  1113 // ---------------------------------------------------------------------------
       
  1114 //
       
  1115 void CCmPluginPacketData::CreateAdditionalRecordsL()
       
  1116     {
       
  1117     LOGGER_ENTERFN( "CCmPluginPacketData::CreateAdditionalRecordsL" );
       
  1118 
       
  1119     delete iPacketDataQoSRecord;
       
  1120     iPacketDataQoSRecord = NULL;
       
  1121 
       
  1122     iPacketDataQoSRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord *>
       
  1123                            (CCDRecordBase::RecordFactoryL(KCDTIdUmtsR99QoSAndOnTableRecord));
       
  1124 
       
  1125     iPacketDataQoSRecord->iGPRSReqTrafficClass = RPacketQoS::ETrafficClassUnspecified;
       
  1126     iPacketDataQoSRecord->iGPRSMinTrafficClass = RPacketQoS::ETrafficClassUnspecified;
       
  1127     iPacketDataQoSRecord->iGPRSReqDeliveryOrder = RPacketQoS::EDeliveryOrderUnspecified;
       
  1128     iPacketDataQoSRecord->iGPRSMinDeliveryOrder = RPacketQoS::EDeliveryOrderUnspecified;
       
  1129     iPacketDataQoSRecord->iGPRSReqDeliverErroneousSDU = RPacketQoS::EErroneousSDUDeliveryUnspecified;
       
  1130     iPacketDataQoSRecord->iGPRSMinDeliverErroneousSDU = RPacketQoS::EErroneousSDUDeliveryUnspecified;
       
  1131     iPacketDataQoSRecord->iGPRSReqMaxSDUSize = 0;
       
  1132     iPacketDataQoSRecord->iGPRSMinAcceptableMaxSDUSize = 0;
       
  1133     iPacketDataQoSRecord->iGPRSReqMaxUplinkRate = 0;
       
  1134     iPacketDataQoSRecord->iGPRSReqMinUplinkRate = 0;
       
  1135     iPacketDataQoSRecord->iGPRSReqMaxDownlinkRate = 0;
       
  1136     iPacketDataQoSRecord->iGPRSReqMinDownlinkRate = 0;
       
  1137     iPacketDataQoSRecord->iGPRSReqBER = RPacketQoS::EBERUnspecified;
       
  1138     iPacketDataQoSRecord->iGPRSMaxBER = RPacketQoS::EBERUnspecified;
       
  1139     iPacketDataQoSRecord->iGPRSReqSDUErrorRatio = RPacketQoS::ESDUErrorRatioUnspecified;
       
  1140     iPacketDataQoSRecord->iGPRSMaxSDUErrorRatio = RPacketQoS::ESDUErrorRatioUnspecified;
       
  1141     iPacketDataQoSRecord->iGPRSReqTrafficHandlingPriority = RPacketQoS::ETrafficPriorityUnspecified;
       
  1142     iPacketDataQoSRecord->iGPRSMinTrafficHandlingPriority = RPacketQoS::ETrafficPriorityUnspecified;
       
  1143     iPacketDataQoSRecord->iGPRSReqTransferDelay = 0;
       
  1144     iPacketDataQoSRecord->iGPRSMaxTransferDelay = 0;
       
  1145     iPacketDataQoSRecord->iGPRSReqGuaranteedUplinkRate = 0;
       
  1146     iPacketDataQoSRecord->iGPRSMinGuaranteedUplinkRate = 0;
       
  1147     iPacketDataQoSRecord->iGPRSReqGuaranteedDownlinkRate = 0;
       
  1148     iPacketDataQoSRecord->iGPRSMinGuaranteedDownlinkRate = 0;
       
  1149     iPacketDataQoSRecord->iGPRSSignallingIndication = EFalse;
       
  1150     iPacketDataQoSRecord->iGPRS_ImCnSignallingIndication = EFalse;
       
  1151     iPacketDataQoSRecord->iGPRSSourceStatisticsDescriptor = RPacketQoS::ESourceStatisticsDescriptorUnknown;
       
  1152     }
       
  1153 
       
  1154 // --------------------------------------------------------------------------
       
  1155 // CCmPluginPacketData::DeleteAdditionalRecordsL
       
  1156 // --------------------------------------------------------------------------
       
  1157 //
       
  1158 void CCmPluginPacketData::DeleteAdditionalRecordsL()
       
  1159     {
       
  1160     LOGGER_ENTERFN( "CCmPluginPacketData::DeleteAdditionalRecordsL" );    
       
  1161 
       
  1162     // If packet record is common with other packet iaps, do not delete it!
       
  1163     if ( !TPtrC(iPacketDataQoSRecord->iRecordName).CompareF( KDefaultQosDataRecordName ) 
       
  1164          || !TPtrC(iPacketDataQoSRecord->iRecordName).CompareF( KDefaultQosDataRecordNamewithSpace ) )
       
  1165         {
       
  1166         return;
       
  1167         }
       
  1168     
       
  1169     iPacketDataQoSRecord->DeleteL( Session() );
       
  1170     }
       
  1171 
       
  1172 // --------------------------------------------------------------------------
       
  1173 // CCmPluginPacketData::LoadAdditionalRecordsL()
       
  1174 // --------------------------------------------------------------------------
       
  1175 //        
       
  1176 void CCmPluginPacketData::LoadAdditionalRecordsL()
       
  1177     {
       
  1178     LOGGER_ENTERFN( "CCmPluginPacketData::LoadAdditionalRecordsL" );
       
  1179 
       
  1180     if ( ServiceRecord().iUmtsR99QoSAndOnTable )
       
  1181         {
       
  1182         iPacketDataQoSRecord = static_cast<CCDUmtsR99QoSAndOnTableRecord *>
       
  1183                            (CCDRecordBase::RecordFactoryL(KCDTIdUmtsR99QoSAndOnTableRecord));
       
  1184         
       
  1185         iPacketDataQoSRecord->SetRecordId( ServiceRecord().iUmtsR99QoSAndOnTable );
       
  1186 
       
  1187         iPacketDataQoSRecord->LoadL( Session() );
       
  1188                 
       
  1189 //        AddConverstionTableL( (CCDRecordBase**)&iPacketDataQoSRecord, NULL, SQoSDataConvTbl );
       
  1190         }
       
  1191     }
       
  1192 
       
  1193 // ---------------------------------------------------------------------------
       
  1194 // CCmPluginPacketData::UpdateAdditionalRecordsL
       
  1195 // ---------------------------------------------------------------------------
       
  1196 //
       
  1197 void CCmPluginPacketData::UpdateAdditionalRecordsL()
       
  1198     {
       
  1199     LOGGER_ENTERFN( "CCmPluginPacketData::UpdateAdditionalRecordsL" );
       
  1200 
       
  1201     if( !iPacketDataQoSRecord->RecordId() )
       
  1202         {
       
  1203         iPacketDataQoSRecord->SetRecordId( KCDNewRecordRequest );
       
  1204         iPacketDataQoSRecord->StoreL( Session() );
       
  1205         }
       
  1206     else
       
  1207         {
       
  1208         iPacketDataQoSRecord->ModifyL( Session() );
       
  1209         }
       
  1210     // Set service record to point to QoS record if it does not yet
       
  1211     if ( !ServiceRecord().iUmtsR99QoSAndOnTable )
       
  1212         {
       
  1213         ServiceRecord().iUmtsR99QoSAndOnTable = iPacketDataQoSRecord->RecordId();
       
  1214         ServiceRecord().ModifyL( Session() );
       
  1215         }
       
  1216     }