dbcreator/commsdatcreator/Src/cdcprocessorglobal.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
    36 #include <datamobilitycommsdattypes.h>
    36 #include <datamobilitycommsdattypes.h>
    37 #include <metadatabase.h>
    37 #include <metadatabase.h>
    38 #include <cmmanagerext.h>
    38 #include <cmmanagerext.h>
    39 #include <cmmanager.h>
    39 #include <cmmanager.h>
    40 #include <cmdestinationext.h>
    40 #include <cmdestinationext.h>
       
    41 #include <cmdefconnvalues.h>
    41 #include <WlanCdbCols.h>
    42 #include <WlanCdbCols.h>
    42 #include <wlancontainer.h>
    43 #include <wlancontainer.h>
    43 #include <featmgr.h>
    44 #include <featmgr.h>
    44 
    45 
    45 // CONSTANTS
    46 // CONSTANTS
   103                           CReaderBase* aFileReader,
   104                           CReaderBase* aFileReader,
   104                           RCmManagerExt& aCmManager,
   105                           RCmManagerExt& aCmManager,
   105                           RPointerArray< RCmConnectionMethodExt >& aPluginArray,
   106                           RPointerArray< RCmConnectionMethodExt >& aPluginArray,
   106                           RPointerArray< HBufC >& aPluginNames, 
   107                           RPointerArray< HBufC >& aPluginNames, 
   107                           RPointerArray< RCmDestinationExt >& aDestArray,
   108                           RPointerArray< RCmDestinationExt >& aDestArray,
   108                           RPointerArray< HBufC >& aDestNames )
   109                           RPointerArray< HBufC >& aDestNames,
       
   110                           RPointerArray< HBufC >& aDefCon )
   109     {
   111     {
   110     CProcessorGlobal* self = new ( ELeave ) CProcessorGlobal( aFileReader,
   112     CProcessorGlobal* self = new ( ELeave ) CProcessorGlobal( aFileReader,
   111                                                               aCmManager,
   113                                                               aCmManager,
   112                                                               aPluginArray,
   114                                                               aPluginArray,
   113                                                               aPluginNames,
   115                                                               aPluginNames,
   114                                                               aDestArray,
   116                                                               aDestArray,
   115                                                               aDestNames );
   117                                                               aDestNames,
       
   118                                                               aDefCon );
   116     CleanupStack::PushL( self );
   119     CleanupStack::PushL( self );
   117 
   120 
   118     // From base class
   121     // From base class
   119     self->ConstructL();
   122     self->ConstructL();
   120     CleanupStack::Pop( self );
   123     CleanupStack::Pop( self );
   129 CProcessorGlobal::CProcessorGlobal( CReaderBase* aFileReader,
   132 CProcessorGlobal::CProcessorGlobal( CReaderBase* aFileReader,
   130                                     RCmManagerExt& aCmManager,
   133                                     RCmManagerExt& aCmManager,
   131                                     RPointerArray< RCmConnectionMethodExt >& aPluginArray,
   134                                     RPointerArray< RCmConnectionMethodExt >& aPluginArray,
   132                                     RPointerArray< HBufC >& aPluginNames, 
   135                                     RPointerArray< HBufC >& aPluginNames, 
   133                                     RPointerArray< RCmDestinationExt >& aDestArray,
   136                                     RPointerArray< RCmDestinationExt >& aDestArray,
   134                                     RPointerArray< HBufC >& aDestNames ) :
   137                                     RPointerArray< HBufC >& aDestNames,
       
   138                                     RPointerArray< HBufC >& aDefCon ) :
   135     CProcessorBase( aFileReader, aCmManager, aPluginArray, aPluginNames, aDestArray, aDestNames ),
   139     CProcessorBase( aFileReader, aCmManager, aPluginArray, aPluginNames, aDestArray, aDestNames ),
   136     iAttachWhenNeeded ( EFalse )
   140     iAttachWhenNeeded ( EFalse )
   137     {
   141     {
       
   142     iDefCon = &aDefCon;
   138     }
   143     }
   139     
   144     
   140     
   145     
   141 // ---------------------------------------------------------
   146 // ---------------------------------------------------------
   142 // CProcessorGlobal::ConstructL
   147 // CProcessorGlobal::ConstructL
   149     iSession->SetAttributeMask( ECDNoWriteButDelete | ECDHidden | ECDProtectedWrite | ECDPrivate ); // Check this
   154     iSession->SetAttributeMask( ECDNoWriteButDelete | ECDHidden | ECDProtectedWrite | ECDPrivate ); // Check this
   150     
   155     
   151     // Create General connection settings struct and set the default values
   156     // Create General connection settings struct and set the default values
   152     iGenConnSettings = new (ELeave) TCmGenConnSettings;
   157     iGenConnSettings = new (ELeave) TCmGenConnSettings;
   153     iGenConnSettings->iUsageOfWlan = ECmUsageOfWlanKnown;
   158     iGenConnSettings->iUsageOfWlan = ECmUsageOfWlanKnown;
   154     iGenConnSettings->iCellularDataUsageHome = ECmCellularDataUsageAutomatic;
   159     iGenConnSettings->iCellularDataUsageHome = ECmCellularDataUsageConfirm;
   155     iGenConnSettings->iCellularDataUsageVisitor = ECmCellularDataUsageConfirm;
   160     iGenConnSettings->iCellularDataUsageVisitor = ECmCellularDataUsageConfirm;
   156 
   161 
   157     CLOG_WRITE( "Initialising FeatureManager\n" )   
   162     CLOG_WRITE( "Initialising FeatureManager\n" )   
   158     //checks if Wlan feature is supported
   163     //checks if Wlan feature is supported
   159     FeatureManager::InitializeLibL();
   164     FeatureManager::InitializeLibL();
   260                     snapTable->LoadL( *iSession );
   265                     snapTable->LoadL( *iSession );
   261                     // Then add default record to table
   266                     // Then add default record to table
   262                     CCDSNAPMetadataRecord* defaultRecord = new( ELeave )
   267                     CCDSNAPMetadataRecord* defaultRecord = new( ELeave )
   263                             CCDSNAPMetadataRecord( snapTable->TableId() );
   268                             CCDSNAPMetadataRecord( snapTable->TableId() );
   264                     CleanupStack::PushL( defaultRecord );
   269                     CleanupStack::PushL( defaultRecord );
   265                     defaultRecord->SetRecordId( KCDNewRecordRequest );
       
   266                     defaultRecord->iMetadata.SetL( 0 );
   270                     defaultRecord->iMetadata.SetL( 0 );
   267                     defaultRecord->iIcon.SetL( icon );
   271                     
   268                     defaultRecord->StoreL( *iSession );
   272                     if ( !defaultRecord->FindL( *iSession ) )
       
   273                         {
       
   274                         defaultRecord->SetRecordId( KCDNewRecordRequest );
       
   275                         defaultRecord->iIcon.SetL( icon );
       
   276                         defaultRecord->StoreL( *iSession );
       
   277                         }
       
   278                     else
       
   279                         {
       
   280                         defaultRecord->iIcon.SetL( icon );
       
   281                         defaultRecord->ModifyL( *iSession );
       
   282                         }
   269                     
   283                     
   270                     CleanupStack::PopAndDestroy( defaultRecord ); // defaultRecord
   284                     CleanupStack::PopAndDestroy( defaultRecord ); // defaultRecord
   271                     CleanupStack::PopAndDestroy( snapTable ); // snapTable
   285                     CleanupStack::PopAndDestroy( snapTable ); // snapTable
   272                     }
   286                     }
   273                 break;
   287                 break;
   301                     UpdateGlobalBearerArrayL( fieldId, prio );
   315                     UpdateGlobalBearerArrayL( fieldId, prio );
   302                     }
   316                     }
   303                 break;
   317                 break;
   304                 }
   318                 }
   305                 
   319                 
       
   320             case EDefaultConnectionType:
       
   321                 {
       
   322                 iDefCon->Append( ptrTag->AllocL() );
       
   323                 //SetDefaultConnectionTypeL( ptrTag )
       
   324                 break;
       
   325                 }
       
   326                 
       
   327             case EDefaultConnectionName:
       
   328                 {
       
   329                 iDefCon->Append( ptrTag->AllocL() );
       
   330                 //SetDefaultConnectionNameL( ptrTag )
       
   331                 break;
       
   332                 }
       
   333                 
   306             case EGprsLastSocketActivityTimeout:
   334             case EGprsLastSocketActivityTimeout:
   307             case EGprsLastSessionClosedTimeout:
   335             case EGprsLastSessionClosedTimeout:
   308             case EGprsLastSocketClosedTimeout:		
   336             case EGprsLastSocketClosedTimeout:		
   309                 {            				    
   337                 {            				    
   310                 // Load modem bearer record
   338                 // Load modem bearer record
   590         CleanupStack::PopAndDestroy( tableName ); // tableName 
   618         CleanupStack::PopAndDestroy( tableName ); // tableName 
   591         }
   619         }
   592     }
   620     }
   593 
   621 
   594 // ---------------------------------------------------------
   622 // ---------------------------------------------------------
       
   623 // CProcessorGlobal::SetDefaultConnectionL
       
   624 // ---------------------------------------------------------
       
   625 //
       
   626 void CProcessorGlobal::SetDefaultConnectionL()
       
   627     {
       
   628     if( iDefCon->Count() > 0 )
       
   629         {
       
   630         SetDefaultConnectionTypeL( (*iDefCon)[0] );
       
   631         }
       
   632     if( iDefCon->Count() > 1 )
       
   633         {
       
   634         SetDefaultConnectionNameL( (*iDefCon)[1] );
       
   635         }
       
   636     }
       
   637 
       
   638 // ---------------------------------------------------------
       
   639 // CProcessorGlobal::SetDefaultConnectionTypeL
       
   640 // ---------------------------------------------------------
       
   641 //
       
   642 void CProcessorGlobal::SetDefaultConnectionTypeL( HBufC16* aPtrTag )
       
   643     {
       
   644     iDefaultConnectionSet = EFalse;
       
   645     
       
   646     if ( aPtrTag->CompareF( KStrAlwaysAsk ) == 0 ) 
       
   647         {
       
   648         iDefaultConnectionType = ECmDefConnAlwaysAsk;
       
   649         SetDefConnRecordL( 0 );
       
   650         }
       
   651     else if ( aPtrTag->CompareF( KStrAskOnce ) == 0 ) 
       
   652         {
       
   653         iDefaultConnectionType = ECmDefConnAskOnce;
       
   654         SetDefConnRecordL( 0 );
       
   655         }
       
   656     else if ( aPtrTag->CompareF( KStrDestination ) == 0 ) 
       
   657         {
       
   658         iDefaultConnectionType = ECmDefConnDestination;
       
   659         }
       
   660     else if ( aPtrTag->CompareF( KStrConnectionMethod ) == 0 ) 
       
   661         {
       
   662         iDefaultConnectionType = ECmDefConnConnectionMethod;
       
   663         }
       
   664     else
       
   665         {
       
   666         CLOG_WRITE(
       
   667         "Warning: Default connection type is not valid. Always ask is set.")
       
   668         iDefaultConnectionType = ECmDefConnAlwaysAsk;
       
   669         SetDefConnRecordL( 0 );
       
   670         }    
       
   671     }
       
   672 
       
   673 // ---------------------------------------------------------
       
   674 // CProcessorGlobal::SetDefaultConnectionNameL
       
   675 // ---------------------------------------------------------
       
   676 //
       
   677 void CProcessorGlobal::SetDefaultConnectionNameL( HBufC16* aPtrTag )
       
   678     {
       
   679         
       
   680     // Name is ignored if the defconn has been set. It can happen e.g.
       
   681     // if iDefaultConnectionType is ECmDefConnAlwaysAsk or ECmDefConnAskOnce     
       
   682     if ( iDefaultConnectionSet )
       
   683         {
       
   684         return;
       
   685         }
       
   686         
       
   687     TInt uId = KErrNotFound;
       
   688     if ( iDefaultConnectionType == ECmDefConnDestination )
       
   689         {
       
   690         uId = GetDestinationIdL( aPtrTag );
       
   691         }
       
   692     else if ( iDefaultConnectionType == ECmDefConnConnectionMethod )
       
   693         {
       
   694         uId = GetPluginIdL( aPtrTag );
       
   695         }
       
   696         
       
   697     if( uId != KErrNotFound )
       
   698         {
       
   699         SetDefConnRecordL( uId );
       
   700         }
       
   701     }
       
   702 
       
   703 // ---------------------------------------------------------
   595 // CProcessorGlobal::SetGenConnSettingWlanUsage
   704 // CProcessorGlobal::SetGenConnSettingWlanUsage
   596 // ---------------------------------------------------------
   705 // ---------------------------------------------------------
   597 //
   706 //
   598 void CProcessorGlobal::SetGenConnSettingWlanUsage( HBufC16* aPtrTag )
   707 void CProcessorGlobal::SetGenConnSettingWlanUsage( HBufC16* aPtrTag )
   599     {
   708     {
   652     cmManager.CreateTablesAndOpenL();
   761     cmManager.CreateTablesAndOpenL();
   653     CleanupClosePushL( cmManager );
   762     CleanupClosePushL( cmManager );
   654     cmManager.WriteGenConnSettingsL( *iGenConnSettings );
   763     cmManager.WriteGenConnSettingsL( *iGenConnSettings );
   655     CleanupStack::PopAndDestroy( &cmManager );
   764     CleanupStack::PopAndDestroy( &cmManager );
   656     }
   765     }
       
   766 
       
   767 //-----------------------------------------------------------------------------
       
   768 //  CProcessorGlobal::SetDefConnRecordL()
       
   769 //-----------------------------------------------------------------------------
       
   770 //
       
   771 void CProcessorGlobal::SetDefConnRecordL( const TInt aId )
       
   772     {
       
   773 
       
   774     TCmDefConnValue value;
       
   775     value.iType = iDefaultConnectionType;
       
   776     value.iId = aId;
       
   777     
       
   778     iCmManager->WriteDefConnL( value );
       
   779     
       
   780     // It gets true if the defconn was set correctly
       
   781     iDefaultConnectionSet = ETrue;
       
   782 
       
   783     }
       
   784     
   657 
   785 
   658 //-----------------------------------------------------------------------------
   786 //-----------------------------------------------------------------------------
   659 //  CProcessorGlobal::SaveGlobalWlanParameterL()
   787 //  CProcessorGlobal::SaveGlobalWlanParameterL()
   660 //-----------------------------------------------------------------------------
   788 //-----------------------------------------------------------------------------
   661 //
   789 //