localconnectivityservice/lcstylustap/src/lcstylustapdismount.cpp
branchRCL_3
changeset 39 4096754ee773
parent 38 3dcb815346df
child 40 52a167391590
equal deleted inserted replaced
38:3dcb815346df 39:4096754ee773
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  ECOM  implementation for touch indicator
       
    15 *
       
    16 */
       
    17 
       
    18 #include "debug.h"
       
    19 #include "lcstylustapdismount.h"
       
    20 
       
    21 // ---------------------------------------------------------------------------
       
    22 // Destructor.
       
    23 // ---------------------------------------------------------------------------
       
    24 //
       
    25 CLcStylusTapDismount::~CLcStylusTapDismount()
       
    26     {
       
    27     TRACE_FUNC
       
    28     Cancel(); 
       
    29     delete iDismountTimer;    
       
    30     iRFs.Close();    
       
    31     }
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // Symbian two phase constructor.
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CLcStylusTapDismount* CLcStylusTapDismount::NewL()
       
    38     {
       
    39     TRACE_FUNC    
       
    40     CLcStylusTapDismount* self = CLcStylusTapDismount::NewLC();
       
    41     CleanupStack::Pop(self);    
       
    42     return self;
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // Symbian two phase constructor. Object pushed to cleanup stack 
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CLcStylusTapDismount* CLcStylusTapDismount::NewLC()
       
    50     {
       
    51     TRACE_FUNC
       
    52     
       
    53     CLcStylusTapDismount* self = new (ELeave) CLcStylusTapDismount();
       
    54     CleanupStack::PushL(self);
       
    55     self->ConstructL();
       
    56     
       
    57     return self;
       
    58 
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // Returning of previous notifier and starting of new one 
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void CLcStylusTapDismount::RunL()
       
    66     {
       
    67     TRACE_FUNC    
       
    68     
       
    69     delete iDismountTimer;    
       
    70     iDismountTimer = NULL;    
       
    71     
       
    72     if ( iDriveIndex < KMaxDrives )
       
    73         {
       
    74         DoDismount();
       
    75         }
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // Cancel pending notifier and those in queue 
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CLcStylusTapDismount::DoCancel()
       
    83     {
       
    84     TRACE_FUNC
       
    85     iRFs.NotifyDismountCancel(iStatus);
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // C++ constructor 
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 CLcStylusTapDismount::CLcStylusTapDismount()
       
    93     : CActive(EPriorityStandard)
       
    94     {
       
    95     TRACE_FUNC    
       
    96     CActiveScheduler::Add(this);    
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // 2nd-phase constructor 
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void CLcStylusTapDismount::ConstructL()
       
   104     {
       
   105     TRACE_FUNC    
       
   106     User::LeaveIfError( iRFs.Connect());
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // Dismount drive 
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CLcStylusTapDismount::DisMountUsbDrives()
       
   114     {    
       
   115     TRACE_FUNC
       
   116     Cancel();
       
   117     iDriveIndex = 0;
       
   118     iRFs.DriveList( iDriveList );
       
   119     DoDismount();
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // Dismount next drive 
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 void CLcStylusTapDismount::DoDismount()
       
   127     {
       
   128     TRACE_FUNC        
       
   129     TDriveInfo info;
       
   130     TInt err = KErrNone;
       
   131     for ( ; iDriveIndex < KMaxDrives; iDriveIndex++ )
       
   132         {
       
   133         if ( iDriveList[iDriveIndex] )
       
   134             {
       
   135             err = iRFs.Drive( info , iDriveIndex );            
       
   136             if ( info.iConnectionBusType == EConnectionBusUsb &&                 
       
   137                  info.iDriveAtt & KDriveAttExternal && 
       
   138                  err == KErrNone  )
       
   139                 {
       
   140                 TRACE_INFO(_L("CLcStylusTapDismount::DoDismount Dismount notify request "));    
       
   141                 iRFs.NotifyDismount( iDriveIndex, iStatus, EFsDismountNotifyClients );                
       
   142                 TRAP_IGNORE( iDismountTimer = CForceDismountTimer::NewL(this) );
       
   143                 SetActive();
       
   144                 break;
       
   145                 }                     
       
   146             }
       
   147         }
       
   148     }
       
   149 
       
   150 // ---------------------------------------------------------------------------
       
   151 // Dismount next drive 
       
   152 // ---------------------------------------------------------------------------
       
   153 //
       
   154 void CLcStylusTapDismount::TimerExpired()
       
   155     {
       
   156     TRACE_FUNC    
       
   157     
       
   158     Cancel();
       
   159     delete iDismountTimer;
       
   160     iDismountTimer = NULL;    
       
   161     iRFs.NotifyDismount( iDriveIndex, iStatus, EFsDismountForceDismount );                
       
   162     SetActive();
       
   163     
       
   164     }    
       
   165 // End of File