localconnectivityservice/obexserviceman/utils/src/obexutilsglobaldialog.cpp
branchRCL_3
changeset 39 4096754ee773
parent 38 3dcb815346df
child 40 52a167391590
equal deleted inserted replaced
38:3dcb815346df 39:4096754ee773
     1 /*
       
     2 * Copyright (c) 2002 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:  Handles the global progress dialog for voice recognition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 
       
    24 #include "obexutilsglobalprogressdialog.h"
       
    25 #include "obexutilsuilayer.h"
       
    26 #include <AknIconUtils.h>
       
    27 #include <avkon.mbg>
       
    28 #include <avkon.rsg>
       
    29 #include <bautils.h>
       
    30 #include    "obexutilsdebug.h"
       
    31 
       
    32 
       
    33 
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35 
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 //
       
    39 CGlobalDialog::CGlobalDialog() : CActive(EPriorityNormal)
       
    40    {
       
    41    CActiveScheduler::Add( this );
       
    42    }
       
    43 
       
    44 // Symbian default constructor can leave.
       
    45 void CGlobalDialog::ConstructL(MGlobalNoteCallback* aObserver)
       
    46    {    
       
    47     iKeyCallback = aObserver;
       
    48     iAknGlobalNote = CAknGlobalNote::NewL();
       
    49    }
       
    50 
       
    51 
       
    52 // Two-phased constructor.
       
    53 EXPORT_C CGlobalDialog* CGlobalDialog::NewL(MGlobalNoteCallback* aObserver)
       
    54    {
       
    55    CGlobalDialog* self = NewLC(aObserver);
       
    56    CleanupStack::Pop();
       
    57    return self;
       
    58    }
       
    59 
       
    60 // Two-phased constructor.- stack version
       
    61 EXPORT_C CGlobalDialog* CGlobalDialog::NewLC(MGlobalNoteCallback* aObserver)
       
    62    {
       
    63    CGlobalDialog* self=new (ELeave) CGlobalDialog();
       
    64    CleanupStack::PushL(self);
       
    65    self->ConstructL(aObserver);
       
    66    return self;
       
    67    }
       
    68 
       
    69 EXPORT_C void CGlobalDialog::ShowErrorDialogL(TInt aResourceId)
       
    70 {
       
    71     TFileName fileName;
       
    72     fileName += KObexUtilsFileDrive;
       
    73     fileName += KDC_RESOURCE_FILES_DIR;
       
    74     fileName += KObexUtilsResourceFileName;
       
    75     
       
    76     if(!iStringResourceReader)
       
    77     {
       
    78         iStringResourceReader= CStringResourceReader::NewL( fileName );
       
    79     }
       
    80     TPtrC buf;
       
    81     buf.Set(iStringResourceReader-> ReadResourceString(aResourceId)); 
       
    82     iAknGlobalNote->SetSoftkeys(R_AVKON_SOFTKEYS_CLOSE);
       
    83     iAknGlobalNote->ShowNoteL(iStatus,EAknGlobalInformationNote, buf);    
       
    84     FTRACE( FPrint(_L( "[ObexUtils] CGlobalDialog: ShowNoteDialogL buf: \t %S" ), &buf) );
       
    85     SetActive();    
       
    86     
       
    87 }
       
    88 EXPORT_C void CGlobalDialog::ShowNoteDialogL( TInt aResourceId, TBool anAnimation)
       
    89 {
       
    90     TFileName fileName;
       
    91     fileName += KObexUtilsFileDrive;
       
    92     fileName += KDC_RESOURCE_FILES_DIR;
       
    93     fileName += KObexUtilsResourceFileName;
       
    94     
       
    95     if(!iStringResourceReader)
       
    96     {
       
    97         iStringResourceReader= CStringResourceReader::NewL( fileName );
       
    98     }
       
    99     TPtrC buf;
       
   100     buf.Set(iStringResourceReader-> ReadResourceString(aResourceId)); 
       
   101     iAknGlobalNote->SetSoftkeys(R_AVKON_SOFTKEYS_CANCEL);
       
   102     if(anAnimation)
       
   103     {
       
   104         iAknGlobalNote->SetAnimation(R_QGN_GRAF_WAIT_BAR_ANIM);
       
   105     }
       
   106     iAknGlobalNote->ShowNoteL(iStatus,EAknGlobalWaitNote, buf);    
       
   107     FTRACE( FPrint(_L( "[ObexUtils] CGlobalDialog: ShowNoteDialogL buf: \t %S" ), &buf) );
       
   108     SetActive();
       
   109 
       
   110 }
       
   111 
       
   112 // Destructor
       
   113 CGlobalDialog::~CGlobalDialog()
       
   114    {
       
   115    Cancel();
       
   116    if(iAknGlobalNote)
       
   117    {
       
   118        delete iAknGlobalNote;   
       
   119        iAknGlobalNote = NULL;
       
   120    }
       
   121    
       
   122    delete iStringResourceReader;
       
   123    
       
   124    }
       
   125 
       
   126 
       
   127 
       
   128 // ---------------------------------------------------------
       
   129 // CGlobalDialog::DoCancel
       
   130 // Active object cancel
       
   131 // ---------------------------------------------------------
       
   132 //
       
   133 void CGlobalDialog::DoCancel()
       
   134    {
       
   135       ProcessFinished();
       
   136     if(iStringResourceReader)
       
   137     {
       
   138         delete iStringResourceReader;
       
   139         iStringResourceReader = NULL;
       
   140     }
       
   141    }
       
   142 
       
   143 // ---------------------------------------------------------
       
   144 // CGlobalDialog::RunL
       
   145 // Active object RunL
       
   146 // ---------------------------------------------------------
       
   147 //
       
   148 void CGlobalDialog::RunL()
       
   149     {
       
   150 
       
   151     FTRACE( FPrint(_L( "[ObexUtils] CGlobalDialog: RunL iStatus.Int():\t %d" ), iStatus.Int() ) );
       
   152     if ( iKeyCallback != NULL )
       
   153         {
       
   154         iKeyCallback->HandleGlobalNoteDialogL(iStatus.Int());
       
   155         }
       
   156     }
       
   157 
       
   158 // ---------------------------------------------------------
       
   159 // CGlobalDialog::ProcessFinished
       
   160 // Stops the progress dialog
       
   161 // ---------------------------------------------------------
       
   162 //
       
   163 EXPORT_C void CGlobalDialog::ProcessFinished()
       
   164    { 
       
   165     FLOG( _L( "[ObexUtils] CGlobalDialog::ProcessFinished\t" ) );   
       
   166     delete iAknGlobalNote;
       
   167     iAknGlobalNote = NULL;   
       
   168    }
       
   169