hotspotfw/hsbrowser/src/hsbrowsermodel.cpp
branchRCL_3
changeset 25 f28ada11abbf
parent 0 56b72877c1cb
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
       
     1 /*
       
     2 * Copyright (c) 2007 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:   Implements the model for application.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <es_enum.h>
       
    22 #include <coemain.h>
       
    23 
       
    24 #include "hotspotclientserver.h"
       
    25 #include "hsbrowsermodel.h"
       
    26 #include "am_debug.h"
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 
       
    30 // ----------------------------------------------------
       
    31 // CHsBrowserModel::NewL
       
    32 // ----------------------------------------------------
       
    33 //
       
    34 CHsBrowserModel* CHsBrowserModel::NewL()
       
    35 	{
       
    36 	DEBUG( "CHsBrowserModel::NewL()" );
       
    37     CHsBrowserModel* self = new(ELeave) CHsBrowserModel();
       
    38     CleanupStack::PushL(self);
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop( self );
       
    41     return self;
       
    42 	}
       
    43 
       
    44 // ----------------------------------------------------
       
    45 // CHsBrowserModel::~CHsBrowserModel
       
    46 // ----------------------------------------------------
       
    47 //
       
    48 CHsBrowserModel::~CHsBrowserModel()
       
    49 	{
       
    50 	DEBUG( "CHsBrowserModel::~CHsBrowserModel()" );
       
    51 	if ( iUrl )
       
    52 		{
       
    53 		delete iUrl;
       
    54 		}
       
    55     if ( iState != EHsBrowserUiClosed )
       
    56         {
       
    57         iHsServer.SetUiState( iIapId, EHsBrowserUiClosed );
       
    58         }
       
    59 
       
    60 	iHsServer.Close();
       
    61     // Removed iConnection and iSocketServ Close() calls.
       
    62     // It seems like Browser Control is freeing them as it's using them also.
       
    63 
       
    64 	if ( iStaticTitle )
       
    65 		{
       
    66 		delete iStaticTitle;
       
    67 		}
       
    68     if ( iPageTitle )
       
    69     	{
       
    70     	delete iPageTitle;
       
    71     	}
       
    72     DEBUG( "CHsBrowserModel::~CHsBrowserModel() DONE" );
       
    73 	}
       
    74 
       
    75 // ----------------------------------------------------
       
    76 // CHsBrowserModel::SetState
       
    77 // ----------------------------------------------------
       
    78 //
       
    79 void CHsBrowserModel::SetState( TUint state, TBool sendToHss )
       
    80 	{
       
    81 	DEBUG( "CHsBrowserModel::SetState()" );
       
    82     iState = state;
       
    83     if ( sendToHss )
       
    84     	{
       
    85     	iHsServer.SetUiState( iIapId, iState );
       
    86     	}
       
    87 	}
       
    88 
       
    89 // ----------------------------------------------------
       
    90 // CHsBrowserModel::Attach
       
    91 // ----------------------------------------------------
       
    92 //
       
    93 TInt CHsBrowserModel::Attach()
       
    94 	{
       
    95 	DEBUG( "CHsBrowserModel::Attach() 1" );
       
    96     TInt err = KErrNone;
       
    97     TConnectionInfoBuf currentConnInfo;
       
    98 	// Open channel to Socket Server
       
    99     err = iSocketServ.Connect();
       
   100     if ( err != KErrNone)
       
   101     	{
       
   102     	return err;
       
   103     	}
       
   104     // Open connection
       
   105     err = iConnection.Open( iSocketServ );
       
   106     if ( err != KErrNone)
       
   107     	{
       
   108     	return err;
       
   109     	} 
       
   110     currentConnInfo().iIapId = iIapId;
       
   111     currentConnInfo().iNetId = iNetId;
       
   112     
       
   113 	err = iConnection.Attach( currentConnInfo,
       
   114 							  RConnection::EAttachTypeMonitor );
       
   115 	
       
   116 	if (err != KErrNone)
       
   117 	    {
       
   118 	    iConnection.Close(); // Just to be sure...
       
   119 	    }
       
   120 	
       
   121 	return err;
       
   122 	}
       
   123 
       
   124 // ----------------------------------------------------
       
   125 // CHsBrowserModel::CHsBrowserModel
       
   126 // ----------------------------------------------------
       
   127 //
       
   128 CHsBrowserModel::CHsBrowserModel() :
       
   129     iIapId( 1 ), 
       
   130     iNetId( 0 ),
       
   131     iUrl( NULL ),
       
   132     iState( 0 ),
       
   133     iForeground( ETrue ),
       
   134     iLoginCompleteNoteShown( EFalse ),
       
   135     iStaticTitle( NULL ),
       
   136     iPageTitle( NULL)
       
   137     {
       
   138     DEBUG( "CHsBrowserModel::CHsBrowserModel()" );
       
   139     }
       
   140 
       
   141 // ----------------------------------------------------
       
   142 // CHsBrowserModel::ConstructL
       
   143 // ----------------------------------------------------
       
   144 //
       
   145 void CHsBrowserModel::ConstructL()
       
   146     {
       
   147     DEBUG( "CHsBrowserModel::ConstructL()" );
       
   148     User::LeaveIfError( iHsServer.Connect() );
       
   149     iPosition = CCoeEnv::Static()->RootWin().OrdinalPosition();
       
   150     iPriority = CCoeEnv::Static()->RootWin().OrdinalPriority();
       
   151     }
       
   152 
       
   153 // end of file