connectionmonitoring/connectionmonitorplugin/src/connectionmonitorplugin.cpp
changeset 0 5a93021fdf25
child 8 2e6c4614c58e
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     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:  ConnectionMonitorPlugin implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // User includes
       
    20 #include    "connectionmonitorplugin.h"
       
    21 #include    <GSParentPlugin.h>
       
    22 #include    <GSCommon.hrh>
       
    23 #include    <connectionmonitorpluginrsc.rsg> // GUI Resource
       
    24 #include    <connectionmonitorplugin.mbg>
       
    25 #include    <GSPrivatePluginProviderIds.h>
       
    26 #include    <GSFWViewUIDs.h>
       
    27 
       
    28 // System includes
       
    29 #include    <AknNullService.h>
       
    30 #include    <bautils.h>
       
    31 #include    <StringLoader.h>
       
    32 #include    <AknGlobalNote.h>
       
    33 #include    <ErrorUI.h>
       
    34 
       
    35 // Constants
       
    36 
       
    37 // ========================= MEMBER FUNCTIONS ================================
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CConnectionMonitorPlugin::CConnectionMonitorPlugin()
       
    41 // Constructor
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CConnectionMonitorPlugin::CConnectionMonitorPlugin()
       
    45     : iResources( *iCoeEnv ),
       
    46       iNullService(NULL)
       
    47     {
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CConnectionMonitorPlugin::~CConnectionMonitorPlugin()
       
    53 // Destructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CConnectionMonitorPlugin::~CConnectionMonitorPlugin()
       
    57     {
       
    58     iResources.Close();
       
    59 
       
    60     if ( iNullService )
       
    61         {
       
    62         delete iNullService;
       
    63         }
       
    64     }
       
    65 
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CConnectionMonitorPlugin::ConstructL()
       
    69 // Symbian OS two-phased constructor
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void CConnectionMonitorPlugin::ConstructL()
       
    73     {
       
    74     BaseConstructL();
       
    75     
       
    76     OpenLocalizedResourceFileL( KConnectionMonitorPluginResourceFileName,
       
    77                                 iResources );
       
    78     }
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // CConnectionMonitorPlugin::NewL()
       
    83 // Static constructor
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 CConnectionMonitorPlugin* CConnectionMonitorPlugin::NewL( 
       
    87                                                     TAny* /*aInitParams*/ )
       
    88     {
       
    89     CConnectionMonitorPlugin* self = 
       
    90                                 new( ELeave ) CConnectionMonitorPlugin();
       
    91     CleanupStack::PushL( self );
       
    92     self->ConstructL();
       
    93     CleanupStack::Pop( self );
       
    94     return self;
       
    95     }
       
    96 
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CConnectionMonitorPlugin::Id
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TUid CConnectionMonitorPlugin::Id() const
       
   103     {
       
   104     return KConnectionMonitorPluginUID;
       
   105     }
       
   106 
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CConnectionMonitorPlugin::DoActivateL
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CConnectionMonitorPlugin::DoActivateL( 
       
   113                                   const TVwsViewId& /*aPrevViewId*/,
       
   114                                   TUid /*aCustomMessageId*/,
       
   115                                   const TDesC8& /*aCustomMessage*/ )
       
   116     {
       
   117     }
       
   118 
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CConnectionMonitorPlugin::DoDeactivate
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CConnectionMonitorPlugin::DoDeactivate()
       
   125     {
       
   126     }
       
   127 
       
   128 
       
   129 // ========================= From CGSPluginInterface ==================
       
   130 
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CConnectionMonitorPlugin::GetCaptionL
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CConnectionMonitorPlugin::GetCaptionL( TDes& aCaption ) const
       
   137     {
       
   138     HBufC* result = StringLoader::LoadL( 
       
   139                                     R_QTN_CP_FOLDER_CONNECTION_MANAGEMENT );
       
   140     aCaption.Copy( *result );
       
   141     delete result;
       
   142     }
       
   143 
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CConnectionMonitorPlugin::PluginProviderCategory
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 TInt CConnectionMonitorPlugin::PluginProviderCategory() const
       
   150     {
       
   151     return KGSPluginProviderInternal;
       
   152     }
       
   153 
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CConnectionMonitorPlugin::ItemType()
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 TGSListboxItemTypes CConnectionMonitorPlugin::ItemType()
       
   160     {
       
   161     return EGSItemTypeSettingDialog;
       
   162     }
       
   163 
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CConnectionMonitorPlugin::GetValue()
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 void CConnectionMonitorPlugin::GetValue( const TGSPluginValueKeys /*aKey*/,
       
   170                                       TDes& /*aValue*/ )
       
   171     {
       
   172     }
       
   173 
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // CConnectionMonitorPlugin::HandleSelection()
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 void CConnectionMonitorPlugin::HandleSelection(
       
   180     const TGSSelectionTypes /*aSelectionType*/ )
       
   181     {
       
   182     TRAPD( error, LaunchConnectionMonitorAppL() );
       
   183     if( error != KErrNone )
       
   184         {
       
   185         ShowErrorNote( error );
       
   186         }
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // CConnectionMonitorPlugin::CreateIconL
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 CGulIcon* CConnectionMonitorPlugin::CreateIconL( const TUid aIconType )
       
   194     {
       
   195     //EMbm<Mbm_file_name><Bitmap_name>
       
   196     CGulIcon* icon;
       
   197     TParse* fp = new( ELeave ) TParse();
       
   198     CleanupStack::PushL( fp );
       
   199     fp->Set( KConnectionMonitorPluginIconDirAndName, &KDC_BITMAP_DIR, NULL );
       
   200 
       
   201     if ( aIconType == KGSIconTypeLbxItem )
       
   202         {
       
   203         icon = AknsUtils::CreateGulIconL(
       
   204         AknsUtils::SkinInstance(),
       
   205         KAknsIIDQgnPropCpConnMan,
       
   206         fp->FullName(),
       
   207         EMbmConnectionmonitorpluginQgn_prop_cp_conn_man,
       
   208         EMbmConnectionmonitorpluginQgn_prop_cp_conn_man_mask );
       
   209         }    
       
   210     else
       
   211         {
       
   212         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   213         }
       
   214 
       
   215     CleanupStack::PopAndDestroy( fp );
       
   216 
       
   217     return icon;
       
   218     }
       
   219 
       
   220 
       
   221 // -----------------------------------------------------------------------------
       
   222 // CConnectionMonitorPlugin::OpenLocalizedResourceFileL()
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 void CConnectionMonitorPlugin::OpenLocalizedResourceFileL(
       
   226     const TDesC& aResourceFileName,
       
   227     RConeResourceLoader& aResourceLoader )
       
   228     {
       
   229     RFs fsSession;
       
   230     User::LeaveIfError( fsSession.Connect() );
       
   231 
       
   232     // Find the resource file:
       
   233     TParse parse;
       
   234     parse.Set( aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
       
   235     TFileName fileName( parse.FullName() );
       
   236 
       
   237     // Get language of resource file:
       
   238     BaflUtils::NearestLanguageFile( fsSession, fileName );
       
   239 
       
   240     // Open resource file:
       
   241     aResourceLoader.OpenL( fileName );
       
   242 
       
   243     // If leave occurs before this, close is called automatically when the
       
   244     // thread exits.
       
   245     fsSession.Close();
       
   246     }
       
   247 
       
   248 
       
   249 // -----------------------------------------------------------------------------
       
   250 // CConnectionMonitorPlugin::LaunchConnectionMonitorAppL()
       
   251 // -----------------------------------------------------------------------------
       
   252 //
       
   253 void CConnectionMonitorPlugin::LaunchConnectionMonitorAppL()
       
   254     {
       
   255     // Launch app
       
   256     if ( iNullService )
       
   257         {
       
   258         delete iNullService;
       
   259         iNullService = NULL;
       
   260         }
       
   261     iNullService = CAknNullService::NewL( KConnectionMonitorAppUid, this );
       
   262     }
       
   263 
       
   264 // ---------------------------------------------------------
       
   265 // CWlanPlugin::ShowErrorNote
       
   266 // ---------------------------------------------------------
       
   267 //
       
   268 void CConnectionMonitorPlugin::ShowErrorNote(TInt aErrorCode)
       
   269     {
       
   270     TBool errorNoteShowed = EFalse;
       
   271         
       
   272     TRAPD(error, errorNoteShowed = ShowErrorNoteL(aErrorCode));
       
   273             
       
   274     if(error || !errorNoteShowed) 
       
   275         {
       
   276         TRAP_IGNORE( ShowGeneralErrorNoteL() );
       
   277         }    
       
   278     }
       
   279 
       
   280 // ---------------------------------------------------------
       
   281 // CWlanPlugin::ShowErrorNoteL
       
   282 // ---------------------------------------------------------
       
   283 //
       
   284 TBool CConnectionMonitorPlugin::ShowErrorNoteL(TInt aErrorCode)
       
   285     {
       
   286     CErrorUI* errorUi = CErrorUI::NewLC();
       
   287     
       
   288     TBool errorNoteShowed = errorUi->ShowGlobalErrorNoteL( aErrorCode );
       
   289     
       
   290     CleanupStack::PopAndDestroy( errorUi );
       
   291         
       
   292     return errorNoteShowed;
       
   293     }    
       
   294 
       
   295 // ---------------------------------------------------------
       
   296 // CWlanPlugin::ShowGeneralErrorNoteL
       
   297 // ---------------------------------------------------------
       
   298 //
       
   299 void CConnectionMonitorPlugin::ShowGeneralErrorNoteL()
       
   300     {
       
   301     HBufC *msg = HBufC::NewL( R_QTN_ERR_OS_GENERAL );
       
   302     
       
   303 	msg->Des().Copy( _L( "" ) );
       
   304     CAknGlobalNote *note = CAknGlobalNote::NewLC();
       
   305     
       
   306     
       
   307     note->ShowNoteL( EAknGlobalErrorNote, *msg );
       
   308 
       
   309 
       
   310     CleanupStack::PopAndDestroy( note );
       
   311     CleanupStack::PopAndDestroy( msg );
       
   312     }
       
   313    
       
   314 // End of file