wvuing/IMPSAlwaysOnlinePlugin/src/CPEngAlwaysOnlinePlugin.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004 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 CAlwaysOnlineEComInterface interface
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "CPEngAlwaysOnlinePlugin.h"
       
    20 #include "CIMPSAlwaysOnlinePluginImp.h"
       
    21 #include "IMPSCommonUiDebugPrint.h"
       
    22 #include "ChatNGCommonUIDs.h"
       
    23 #include "CPEngAOCallObserver.h"
       
    24 #include "CIMPSReconnectNoteHandler.h"
       
    25 #include "IMPSUIDDefs.h"
       
    26 
       
    27 #include <e32std.h>
       
    28 #include <ImplementationProxy.h>
       
    29 #include <alwaysonlinemanagercommon.h>
       
    30 #include <FeatMgr.h>
       
    31 #include <coemain.h>
       
    32 #include <GulUtil.h>
       
    33 #include <e32property.h>
       
    34 
       
    35 #include "impscommonuibuilddefinitions.h"
       
    36 #include "cimpsresourcereader.h"
       
    37 
       
    38 CPEngAlwaysOnlinePlugin::CPEngAlwaysOnlinePlugin()
       
    39         : CAlwaysOnlineEComInterface()
       
    40     {
       
    41     }
       
    42 
       
    43 // ----------------------------------------------------------------------------
       
    44 // CPEngAlwaysOnlinePlugin::ConstructL
       
    45 // Symbian 2nd phase constructor can leave.
       
    46 // ----------------------------------------------------------------------------
       
    47 //
       
    48 void CPEngAlwaysOnlinePlugin::ConstructL()
       
    49     {
       
    50     IMPSCUI_DP_FUNC_ENTER( "ConstructL" );
       
    51 
       
    52     FeatureManager::InitializeLibL();
       
    53 
       
    54     CleanupStack::PushL( TCleanupItem( CleanupFeatureManager, this ) );
       
    55 
       
    56     if ( FeatureManager::FeatureSupported( KFeatureIdIm ) )
       
    57         {
       
    58         iIMAOPlugin = CIMPSAlwaysOnlinePluginImp::NewL();
       
    59 
       
    60         CIMPSResourceReader* resourceReader = CIMPSResourceReader::NewLC();
       
    61         TBool showRoamingWarning = resourceReader->IsRoamingWarningRequiredL();
       
    62         if ( showRoamingWarning )
       
    63             {
       
    64             iIMAOPlugin->SetShowRoamingWarning( showRoamingWarning );
       
    65             }
       
    66         CleanupStack::PopAndDestroy( resourceReader );
       
    67         }
       
    68 
       
    69     CleanupStack::PopAndDestroy(); // CleanupFeatureManager
       
    70 
       
    71     IMPSCUI_DP_FUNC_DONE( "ConstructL" );
       
    72     }
       
    73 
       
    74 // Destructor
       
    75 CPEngAlwaysOnlinePlugin::~CPEngAlwaysOnlinePlugin()
       
    76     {
       
    77     delete iIMAOPlugin;
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // CPEngAlwaysOnlinePlugin::NewL
       
    82 // Two-phased constructor.
       
    83 // ----------------------------------------------------------------------------
       
    84 //
       
    85 CPEngAlwaysOnlinePlugin* CPEngAlwaysOnlinePlugin::NewL()
       
    86     {
       
    87     CPEngAlwaysOnlinePlugin* self = new ( ELeave ) CPEngAlwaysOnlinePlugin();
       
    88     CleanupStack::PushL( self );
       
    89     self->ConstructL();
       
    90     CleanupStack::Pop( self );
       
    91     return self;
       
    92     }
       
    93 
       
    94 // ----------------------------------------------------------------------------
       
    95 // CPEngAlwaysOnlinePlugin::CleanupFeatureManager
       
    96 // Two-phased constructor.
       
    97 // ----------------------------------------------------------------------------
       
    98 //
       
    99 void CPEngAlwaysOnlinePlugin::CleanupFeatureManager( TAny* /*aPtr*/ )
       
   100     {
       
   101     FeatureManager::UnInitializeLib();
       
   102     }
       
   103 // ---------------------------------------------------------
       
   104 // CPEngAlwaysOnlinePlugin::HandleServerCommandL
       
   105 // Handles the events coming from the Always Online Server
       
   106 // ---------------------------------------------------------
       
   107 //
       
   108 TAny* CPEngAlwaysOnlinePlugin::HandleServerCommandL( TInt aCommand,
       
   109                                                      TDesC8* /*aParameters*/ )
       
   110     {
       
   111     IMPSCUI_DP( D_IMPSCUI_LIT( "CPEngAlwaysOnlinePlugin::HandleServerCommandL [%d]" ), aCommand );
       
   112     TInt err( KErrNone );
       
   113 
       
   114     switch ( aCommand )
       
   115         {
       
   116         case EAOManagerPluginStart:
       
   117             {
       
   118             //do your plugin start here
       
   119             if ( iIMAOPlugin )
       
   120                 {
       
   121                 iIMAOPlugin->StartPluginL();
       
   122                 }
       
   123             break;
       
   124             }
       
   125         case EAOManagerPluginStop:
       
   126             {
       
   127             // we should make a logout here
       
   128             if ( iIMAOPlugin )
       
   129                 {
       
   130                 iIMAOPlugin->StopPlugin();
       
   131                 }
       
   132             break;
       
   133             }
       
   134         case EAOManagerStartedRoaming:
       
   135             {
       
   136             // tell the plugin that we started
       
   137             if ( iIMAOPlugin )
       
   138                 {
       
   139                 iIMAOPlugin->SetRoaming( ETrue );
       
   140                 }
       
   141 
       
   142             // Show  warning, if variated so
       
   143             CIMPSResourceReader* resourceReader = CIMPSResourceReader::NewLC();
       
   144             TBool showRoamingWarning = resourceReader->IsRoamingWarningRequiredL();
       
   145             CleanupStack::PopAndDestroy( resourceReader );
       
   146 
       
   147             if ( showRoamingWarning )
       
   148                 {
       
   149                 User::LeaveIfError( RProperty::Set( KIMPSConnUiTemporaryUid, EIMPSSharedKeysRoaming, ETrue ) );
       
   150 
       
   151                 if ( iIMAOPlugin )
       
   152                     {
       
   153                     // Dont do any action if login type is Auto in home n/w
       
   154                     if ( !iIMAOPlugin->IsLoginAutoInHomeNW() )
       
   155                         {
       
   156                         TBool roamingDlgShown( EFalse );
       
   157                         User::LeaveIfError( RProperty::Get( KIMPSConnUiTemporaryUid, EIMPSSharedKeysRoamingDlgShown, roamingDlgShown ) );
       
   158 
       
   159                         if ( !roamingDlgShown && iIMAOPlugin->IsUserLoggedInL() )
       
   160                             {
       
   161                             iIMAOPlugin->HandleRoamingL();
       
   162 
       
   163                             // Set the property
       
   164                             roamingDlgShown = ETrue;
       
   165                             User::LeaveIfError( RProperty::Set( KIMPSConnUiTemporaryUid, EIMPSSharedKeysRoamingDlgShown, roamingDlgShown ) );
       
   166                             }
       
   167                         }
       
   168                     }
       
   169                 }
       
   170             else
       
   171                 {
       
   172                 err = KErrNotSupported;
       
   173                 }
       
   174 
       
   175             break;
       
   176             }
       
   177         case EAOManagerStoppedRoaming:
       
   178             {
       
   179             // tell the plugin that we are back in home network
       
   180             if ( iIMAOPlugin )
       
   181                 {
       
   182                 iIMAOPlugin->SetRoaming( EFalse );
       
   183                 }
       
   184 
       
   185             // If  warning is to be shown, then Set the roaing property
       
   186             CIMPSResourceReader* resourceReader = CIMPSResourceReader::NewLC();
       
   187             TBool showRoamingWarning = resourceReader->IsRoamingWarningRequiredL();
       
   188             CleanupStack::PopAndDestroy( resourceReader );
       
   189 
       
   190             if ( showRoamingWarning )
       
   191                 {
       
   192                 User::LeaveIfError( RProperty::Set( KIMPSConnUiTemporaryUid, EIMPSSharedKeysRoaming, EFalse ) );
       
   193                 }
       
   194             else
       
   195                 {
       
   196                 err = KErrNotSupported;
       
   197                 }
       
   198             break;
       
   199             }
       
   200         case EAOManagerNWOpsAllowed:
       
   201             {
       
   202             // tell the implementation part that the network ops are allowed
       
   203             if ( iIMAOPlugin )
       
   204                 {
       
   205                 iIMAOPlugin->SetNetworkOpsAllowed( ETrue );
       
   206                 }
       
   207             break;
       
   208             }
       
   209         case EAOManagerNWOpsNotAllowed:
       
   210             {
       
   211             // tell the implementation part that the network ops are disallowed
       
   212             if ( iIMAOPlugin )
       
   213                 {
       
   214                 iIMAOPlugin->SetNetworkOpsAllowed( EFalse );
       
   215                 }
       
   216             break;
       
   217             }
       
   218         case EAOManagerSuicideQuery:
       
   219             {
       
   220             err = ETrue;
       
   221             if ( iIMAOPlugin )
       
   222                 {
       
   223                 err = !iIMAOPlugin->CheckPluginNeed();
       
   224                 }
       
   225             break;
       
   226             }
       
   227         default:
       
   228             {
       
   229             err = KErrNotSupported;
       
   230             break;
       
   231             }
       
   232         }
       
   233 
       
   234     return ( TAny* )err;
       
   235     }
       
   236 
       
   237 // __________________________________________________________________________
       
   238 // Exported proxy for instantiation method resolution
       
   239 // Use the plugin UID and Implementation factory method
       
   240 // as a pair for ECom instantiation.
       
   241 const TImplementationProxy ImplementationTable[] =
       
   242     {
       
   243     IMPLEMENTATION_PROXY_ENTRY( KIMPSALWAYSONLINEUID3, CPEngAlwaysOnlinePlugin::NewL )
       
   244     };
       
   245 
       
   246 // Give the table to the caller
       
   247 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
   248     {
       
   249     aTableCount = sizeof( ImplementationTable ) / sizeof( ImplementationTable[0] );
       
   250     return ImplementationTable;
       
   251     }
       
   252