btobexprofiles/obexserviceman/utils/src/obexutilsdialog.cpp
changeset 42 b72428996822
parent 32 19bd632b5100
child 57 5ebadcda06cb
equal deleted inserted replaced
32:19bd632b5100 42:b72428996822
     1 /*
     1 /*
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include    "obexutilsdialog.h"
    20 #include "obexutilsdialog.h"
    21 #include    "obexutilsdialogtimer.h"
    21 #include "obexutilsdialogtimer.h"
    22 #include    "obexutilsuilayer.h"
    22 #include "obexutilsdebug.h"
    23 #include    <secondarydisplay/obexutilssecondarydisplayapi.h>
    23 #include <hbdevicenotificationdialogsymbian.h>
    24 #include    <aknnotewrappers.h>
    24 #include <btservices/bluetoothdevicedialogs.h>
    25 #include    <eikprogi.h>
    25 #include <hbtextresolversymbian.h>
    26 #include    <Obexutils.rsg>
    26 
    27 #include    <e32def.h>
    27 _LIT(KSendingDialog, "com.nokia.hb.btdevicedialog/1.0");
    28 #include    <bautils.h>
    28 _LIT(KCurrentFileIndex,"currentFileIdx" );
    29 #include    <StringLoader.h>
    29 _LIT(KTotalFileCount, "totalFilesCnt");
    30 #include    <featmgr.h>
    30 _LIT(KDestinationName, "destinationName");
    31 #include    "obexutilsdebug.h"
    31 _LIT(KFileName,"fileName");
       
    32 _LIT(KFileSizeTxt,"fileSzTxt");
       
    33 _LIT(KFileSize,"fileSz");
       
    34 _LIT(KProgressValue,"progressValue");
       
    35 
       
    36 _LIT(KSendingCancelledText, "txt_bt_dpophead_sending_cancelled");
       
    37 _LIT(KDeviceText,"txt_bt_dpopinfo_sent_to_1");
       
    38 
       
    39 const TInt KMaxDescriptionLength = 256;
       
    40 const TInt KMinStringSize = 10;
       
    41 const TInt KMinFileSize = 1024;
       
    42 
       
    43 _LIT(KLocFileName, "btdialogs_");     
       
    44 _LIT(KPath, "z:/resource/qt/translations/"); 
    32 
    45 
    33 // ============================ MEMBER FUNCTIONS ===============================
    46 // ============================ MEMBER FUNCTIONS ===============================
    34 
    47 
    35 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    36 // C++ default constructor can NOT contain any code, that
    49 // C++ default constructor can NOT contain any code, that
    76         {
    89         {
    77         // The observer pointer was not given as an argument.
    90         // The observer pointer was not given as an argument.
    78         //
    91         //
    79         User::Leave(KErrArgument);
    92         User::Leave(KErrArgument);
    80         }
    93         }
    81   
       
    82     TFileName fileName;
       
    83     fileName += KObexUtilsFileDrive;
       
    84     fileName += KDC_RESOURCE_FILES_DIR;
       
    85     fileName += KObexUtilsResourceFileName;
       
    86     BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), fileName );
       
    87     iResourceFileId = CCoeEnv::Static()->AddResourceFileL( fileName );
       
    88 
       
    89     iCoverDisplayEnabled = IsCoverDisplayL();
       
    90 
       
    91     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::ConstructL() completed"));
    94     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::ConstructL() completed"));
    92     } 
    95     } 
    93 
    96 
    94 // -----------------------------------------------------------------------------
    97 // -----------------------------------------------------------------------------
    95 // Destructor
    98 // Destructor
    96 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
    97 CObexUtilsDialog::~CObexUtilsDialog()
   100 EXPORT_C CObexUtilsDialog::~CObexUtilsDialog()
    98     {
   101     {
    99     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::~CObexUtilsDialog()"));
   102     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::~CObexUtilsDialog()"));
   100 
   103     iDeviceName.Close();
   101     CCoeEnv::Static()->DeleteResourceFile( iResourceFileId );
   104     delete iWaitDialog;
       
   105     delete iProgressDialog;
   102     delete iObexDialogTimer;
   106     delete iObexDialogTimer;
   103 
   107     delete iMessageBox;
   104     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::~CObexUtilsDialog() completed"));
   108     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::~CObexUtilsDialog() completed"));
   105     }
   109     }
   106 
   110 
   107 // -----------------------------------------------------------------------------
   111 // -----------------------------------------------------------------------------
   108 // CObexUtilsDialog::LaunchProgressDialogL
   112 // CObexUtilsDialog::LaunchProgressDialogL
   109 // -----------------------------------------------------------------------------
   113 // -----------------------------------------------------------------------------
   110 EXPORT_C void CObexUtilsDialog::LaunchProgressDialogL( 
   114 EXPORT_C void CObexUtilsDialog::LaunchProgressDialogL(
   111     MObexUtilsProgressObserver* aObserverPtr, TInt aFinalValue, 
   115     MObexUtilsProgressObserver* aObserverPtr, TInt aFileCount, 
   112     TInt aResId, TInt aTimeoutValue )
   116     const TDesC& aDeviceName, TInt aTimeoutValue )
   113     {
   117     {
   114     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchProgressDialogL()"));
   118     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchProgressDialogL()"));
   115 
   119     
       
   120     TBuf<KMinStringSize> key;
   116     if ( aObserverPtr )
   121     if ( aObserverPtr )
   117         {
   122         {
   118         // The observerPtr was given, so store it and start a timer
   123         // The observerPtr was given, so store it and start a timer
   119         //
   124         //
   120         iProgressObserverPtr = aObserverPtr;
   125         iProgressObserverPtr = aObserverPtr;
   121 
   126 
   122         if ( iObexDialogTimer )
   127         if ( !iObexDialogTimer )
   123             {
   128             {
   124             iObexDialogTimer->Cancel();
   129             iObexDialogTimer = CObexUtilsDialogTimer::NewL( this );
   125             delete iObexDialogTimer;
       
   126             iObexDialogTimer = NULL;
       
   127             }
   130             }
   128 
   131         iObexDialogTimer->Cancel();
   129         iObexDialogTimer = CObexUtilsDialogTimer::NewL( this );
       
   130         iObexDialogTimer->SetTimeout( aTimeoutValue );
   132         iObexDialogTimer->SetTimeout( aTimeoutValue );
   131         }
   133         }
   132 
   134 
   133     iProgressDialogResId = aResId;
   135     iFileCount = aFileCount;
   134    
   136     iDeviceName.Close();
   135     iProgressDialog = new( ELeave ) CAknProgressDialog( 
   137     iDeviceName.CreateL(aDeviceName);
   136         ( reinterpret_cast<CEikDialog**>( &iProgressDialog ) ), ETrue );
   138     iProgressDialog = CHbDeviceDialogSymbian::NewL();
   137     PrepareDialogExecuteL( aResId, iProgressDialog );
   139     
   138     iProgressDialog->ExecuteLD( R_SENDING_PROGRESS_NOTE );
   140     CHbSymbianVariantMap* map = CHbSymbianVariantMap::NewL();
   139     
   141     CleanupStack::PushL(map);
   140     HBufC* buf = StringLoader::LoadLC( aResId );
   142     TInt data = TBluetoothDialogParams::ESend;
   141     iProgressDialog->SetTextL( buf->Des() );
   143     key.Num(TBluetoothDialogParams::EDialogType);
   142     CleanupStack::PopAndDestroy( buf );
   144     AddDataL( map, key, &data, CHbSymbianVariant::EInt );
   143 
   145     User::LeaveIfError(iProgressDialog->Show(KSendingDialog(),*map,this));
   144     iProgressDialog->GetProgressInfoL()->SetFinalValue( aFinalValue );
   146     CleanupStack::PopAndDestroy(map);    
   145     iProgressDialog->SetCallback( this );
   147 
   146     if ( iProgressObserverPtr )
   148     if ( iProgressObserverPtr )
   147         {
   149         {
   148         iObexDialogTimer->Tickle();
   150         iObexDialogTimer->Tickle();
   149         }
   151         }
   150 
   152 
   151     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchProgressDialogL() completed"));
   153     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchProgressDialogL() completed"));    
       
   154     }
       
   155 
       
   156 
       
   157 EXPORT_C void CObexUtilsDialog::UpdateProgressNoteL( TInt aFileSize,TInt aFileIndex, const TDesC& aFileName )
       
   158     {
       
   159     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressNoteL()"));  
       
   160     HBufC* key = HBufC::NewL(KMaxDescriptionLength);
       
   161     CleanupStack::PushL(key);
       
   162     
       
   163     CHbSymbianVariantMap* map = CHbSymbianVariantMap::NewL();
       
   164     CleanupStack::PushL(map);
       
   165     
       
   166     iFileIndex = aFileIndex+1;
       
   167     key->Des().Copy(KCurrentFileIndex());
       
   168     AddDataL( map, *key, &iFileIndex, CHbSymbianVariant::EInt );
       
   169     
       
   170     key->Des().Copy(KTotalFileCount());
       
   171     AddDataL( map, *key, &iFileCount, CHbSymbianVariant::EInt );
       
   172 
       
   173     key->Des().Copy(KDestinationName());
       
   174     AddDataL( map, *key, &iDeviceName, CHbSymbianVariant::EDes );
       
   175     
       
   176     key->Des().Copy(KFileName());
       
   177     AddDataL( map, *key, &aFileName, CHbSymbianVariant::EDes );
       
   178     
       
   179     // todo: localiation is needed for code below:
       
   180     HBufC* value = HBufC::NewL(KMaxDescriptionLength);
       
   181     CleanupStack::PushL(value);
       
   182     key->Des().Copy(KFileSizeTxt());
       
   183     value->Des().Zero();
       
   184     if(aFileSize < KMinFileSize)
       
   185         {
       
   186         value->Des().AppendNum(aFileSize);
       
   187         value->Des().Append(_L(" Bytes"));
       
   188         }
       
   189     else
       
   190         {
       
   191         TInt filesize =  aFileSize/KMinFileSize;
       
   192         value->Des().AppendNum(filesize);
       
   193         value->Des().Append(_L(" KB"));
       
   194         }
       
   195     AddDataL( map, *key, value, CHbSymbianVariant::EDes );
       
   196     CleanupStack::PopAndDestroy( value );
       
   197     
       
   198     key->Des().Copy(KFileSize());
       
   199     AddDataL( map, *key, &aFileSize, CHbSymbianVariant::EInt );
       
   200     TInt ret = iProgressDialog->Update(*map);
       
   201     CleanupStack::PopAndDestroy(map);
       
   202     CleanupStack::PopAndDestroy(key);
       
   203     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressNoteL()Completed"));  
   152     }
   204     }
   153 
   205 
   154 // -----------------------------------------------------------------------------
   206 // -----------------------------------------------------------------------------
   155 // CObexUtilsDialog::LaunchWaitDialogL
   207 // CObexUtilsDialog::LaunchWaitDialogL
   156 // -----------------------------------------------------------------------------
   208 // -----------------------------------------------------------------------------
   157 EXPORT_C void CObexUtilsDialog::LaunchWaitDialogL( TInt aResId )
   209 EXPORT_C void CObexUtilsDialog::LaunchWaitDialogL( const TDesC& aDisplayText )
   158     {
   210     {
   159     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchWaitDialogL()"));
   211     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchWaitDialogL()"));
   160 
   212 
   161     if ( iWaitDialog || iProgressDialog )
   213     if ( iWaitDialog || iProgressDialog )
   162         {
   214         {
   163         // Allow only one dialog at a time
   215         // Allow only one dialog at a time
   164         //
   216         //
   165         User::Leave( KErrInUse );
   217         User::Leave( KErrInUse );
   166         }
   218         }
   167 
   219     iWaitDialog = CHbDeviceProgressDialogSymbian::NewL(CHbDeviceProgressDialogSymbian::EWaitDialog,this);
   168     iWaitDialog = new( ELeave ) CAknWaitDialog(
   220     iWaitDialog->SetTextL(aDisplayText);
   169             ( reinterpret_cast<CEikDialog**>( &iWaitDialog ) ), EFalse );
   221     iWaitDialog->ShowL();
   170     
       
   171     iWaitDialog->SetCallback( this );
       
   172     PrepareDialogExecuteL( aResId, iWaitDialog );
       
   173     iWaitDialog->ExecuteLD( aResId );
       
   174 
   222 
   175     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchWaitDialogL() completed"));
   223     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchWaitDialogL() completed"));
   176     }
   224     }
   177 
   225 
   178 // -----------------------------------------------------------------------------
   226 // -----------------------------------------------------------------------------
   179 // CObexUtilsDialog::CancelWaitDialogL
   227 // CObexUtilsDialog::CancelWaitDialogL
   180 // -----------------------------------------------------------------------------
   228 // -----------------------------------------------------------------------------
   181 EXPORT_C void CObexUtilsDialog::CancelWaitDialogL()
   229 EXPORT_C void CObexUtilsDialog::CancelWaitDialog()
   182     {
   230     {
   183     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelWaitDialogL()"));
   231     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelWaitDialogL()"));
   184 
   232 
   185     if( iWaitDialog )
   233     if( iWaitDialog )
   186         {
   234         {
   187         iWaitDialog->SetCallback(NULL);
   235         iWaitDialog->Close();
   188         iWaitDialog->ProcessFinishedL();
   236         delete iWaitDialog;
   189         iWaitDialog = NULL;
   237         iWaitDialog = NULL;
   190         }
   238         }
   191 
   239 
   192     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelWaitDialogL() completed"));
   240     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelWaitDialogL() completed"));
   193     }
   241     }
   194 
   242 
   195 // -----------------------------------------------------------------------------
   243 // -----------------------------------------------------------------------------
   196 // CObexUtilsDialog::CancelProgressDialogL
   244 // CObexUtilsDialog::CancelProgressDialogL
   197 // -----------------------------------------------------------------------------
   245 // -----------------------------------------------------------------------------
   198 EXPORT_C void CObexUtilsDialog::CancelProgressDialogL()
   246 EXPORT_C void CObexUtilsDialog::CancelProgressDialog()
   199     {
   247     {
   200     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelProgressDialogL()"));
   248     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelProgressDialogL()"));
   201 
   249 
   202     if( iProgressDialog )
   250     if( iProgressDialog )
   203         {        
   251         {        
   204         iProgressDialog->SetCallback(NULL);
   252         iProgressDialog->Cancel();
   205         iProgressDialog->ProcessFinishedL();
   253         delete iProgressDialog;
   206         iProgressDialog = NULL;
   254         iProgressDialog = NULL;
   207 
   255         delete iObexDialogTimer;
   208         if ( iObexDialogTimer )
   256         iObexDialogTimer = NULL;
   209             {
       
   210             iObexDialogTimer->Cancel();
       
   211             delete iObexDialogTimer;
       
   212             iObexDialogTimer = NULL;
       
   213             }
       
   214         }  
   257         }  
   215         
   258         
   216     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelProgressDialogL() completed"));  
   259     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelProgressDialogL() completed"));  
   217     }
   260     }
   218 
   261 
   219 // -----------------------------------------------------------------------------
   262 // -----------------------------------------------------------------------------
   220 // CObexUtilsDialog::UpdateProgressDialogL
   263 // CObexUtilsDialog::UpdateProgressDialogL
   221 // -----------------------------------------------------------------------------
   264 // -----------------------------------------------------------------------------
   222 EXPORT_C void CObexUtilsDialog::UpdateProgressDialogL( TInt aValue, TInt aResId  )
   265 EXPORT_C void CObexUtilsDialog::UpdateProgressDialogL( TInt aProgressValue  )
   223     {
   266     {
   224     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialogL()"));
   267     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialogL()"));
   225 
   268 
   226     if ( iProgressDialog )
   269     if ( iProgressDialog )
   227         {
   270         {
   228         iProgressDialog->GetProgressInfoL()->SetAndDraw( aValue );
   271         HBufC* key = HBufC::NewL(KMaxDescriptionLength);
       
   272         CleanupStack::PushL(key);
       
   273 
       
   274         CHbSymbianVariantMap* map = CHbSymbianVariantMap::NewL();
       
   275         CleanupStack::PushL(map);
   229         
   276         
   230         HBufC* buf = StringLoader::LoadLC( aResId );
   277         key->Des().Copy(KProgressValue());
   231         iProgressDialog->SetTextL( buf->Des() );
   278         AddDataL( map, *key, &aProgressValue, CHbSymbianVariant::EInt );
   232         iProgressDialog->LayoutAndDraw();
   279 
   233         CleanupStack::PopAndDestroy( buf );
   280         HBufC* value = HBufC::NewL(KMaxDescriptionLength);
       
   281         CleanupStack::PushL(value);
       
   282         key->Des().Copy(KCurrentFileIndex());
       
   283         value->Des().AppendNum(iFileIndex);
       
   284         AddDataL( map, *key, value, CHbSymbianVariant::EDes );
       
   285         CleanupStack::PopAndDestroy(value);
       
   286         
       
   287         TInt ret = iProgressDialog->Update(*map);
       
   288         
       
   289         CleanupStack::PopAndDestroy(map);
       
   290         CleanupStack::PopAndDestroy(key);    
   234         }
   291         }
   235 
   292 
   236     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialogL() completed"));
   293     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialogL() completed"));
   237     }
   294     }
   238 
   295 
   239 // -----------------------------------------------------------------------------
   296 // -----------------------------------------------------------------------------
   240 // CObexUtilsDialog::DialogDismissedL
       
   241 // -----------------------------------------------------------------------------
       
   242 void CObexUtilsDialog::DialogDismissedL( TInt aButtonId )
       
   243     {
       
   244     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::DialogDismissedL()"));
       
   245 
       
   246     // The dialog has already been deleted by UI framework.
       
   247     //
       
   248     if( aButtonId == EAknSoftkeyCancel )
       
   249         {
       
   250         if ( iDialogObserverPtr )
       
   251             {
       
   252             iDialogObserverPtr->DialogDismissed( aButtonId );
       
   253             }
       
   254 
       
   255         if ( iObexDialogTimer )
       
   256             {
       
   257             iObexDialogTimer->Cancel();
       
   258             delete iObexDialogTimer;
       
   259             iObexDialogTimer = NULL;
       
   260             }
       
   261         }
       
   262 
       
   263     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::DialogDismissedL() completed"));
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 // CObexUtilsDialog::UpdateProgressDialog
   297 // CObexUtilsDialog::UpdateProgressDialog
   268 // -----------------------------------------------------------------------------
   298 // -----------------------------------------------------------------------------
   269 void CObexUtilsDialog::UpdateProgressDialog()
   299 void CObexUtilsDialog::UpdateProgressDialog()
   270     {
   300     {
   271     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialog()"));
   301     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialog()"));
   272 
   302 
   273     TRAPD( ignoredError, UpdateProgressDialogL( 
   303     TRAPD( ignoredError, UpdateProgressDialogL( 
   274         iProgressObserverPtr->GetProgressStatus(), iProgressDialogResId ) );
   304         iProgressObserverPtr->GetProgressStatus()) );
   275         
   305         
   276     if (ignoredError != KErrNone)
   306     if (ignoredError != KErrNone)
   277         {
   307         {
   278         FLOG(_L("Ignore this error"));
   308         FLOG(_L("Ignore this error"));
   279         }
   309         }
   288     
   318     
   289 // -----------------------------------------------------------------------------
   319 // -----------------------------------------------------------------------------
   290 // CObexUtilsDialog::LaunchQueryDialogL
   320 // CObexUtilsDialog::LaunchQueryDialogL
   291 // -----------------------------------------------------------------------------
   321 // -----------------------------------------------------------------------------
   292 //
   322 //
   293 EXPORT_C TInt CObexUtilsDialog::LaunchQueryDialogL( const TInt& aResourceID )
   323 EXPORT_C void CObexUtilsDialog::LaunchQueryDialogL( const TDesC& aConfirmText )
   294     {
   324     {
   295     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchQueryDialogL()"));
   325     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchQueryDialogL()"));
   296     
   326     if ( iMessageBox )
   297     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
   327         {
   298     CleanupStack::PushL( dlg );
   328         //todo: Already one dialog is displayed, currently not supported for 
   299     PrepareDialogExecuteL( aResourceID, dlg );
   329         //multiple dialogs at the same time.
   300     CleanupStack::Pop( dlg );
   330         User::Leave( KErrGeneral );
   301     TInt keypress = dlg->ExecuteLD( aResourceID );
   331         }
   302     
   332     iMessageBox = CreateAndShowMessageBoxL( CHbDeviceMessageBoxSymbian::EQuestion,
   303     return keypress;
   333             aConfirmText, this, 0 );
   304     }
   334     }
   305     
   335     
   306 // -----------------------------------------------------------------------------
   336 
   307 // CObexUtilsDialog::ShowNumberOfSendFileL
   337 // -----------------------------------------------------------------------------
   308 // -----------------------------------------------------------------------------
   338 // CObexUtilsUiDialog::ShowErrorNoteL
   309 //  
   339 // -----------------------------------------------------------------------------
   310     
   340 EXPORT_C void CObexUtilsDialog::ShowErrorNoteL( const TDesC& aTextId )
   311 EXPORT_C void CObexUtilsDialog::ShowNumberOfSendFileL( TInt aSentNum, TInt aTotalNum )
   341     {
   312     {
   342     FLOG(_L("[OBEXUTILS]\t CObexUtilsUiDialog::ShowErrorNoteL"));
   313     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::ShowNumberOfSendFile()"));
   343     if ( iMessageBox )
   314     
   344         {
   315     CAknInformationNote* myNote = new (ELeave) CAknInformationNote();
   345         //todo: Already one dialog is displayed, currently not supported for 
   316 
   346         //multiple dialogs at the same time.
   317     CArrayFix<TInt>* nums = new( ELeave ) CArrayFixFlat<TInt>(3);
   347         User::Leave( KErrGeneral );
   318     CleanupStack::PushL(nums);
   348         }
   319     nums->AppendL(aSentNum);  
   349     iMessageBox = CreateAndShowMessageBoxL( CHbDeviceMessageBoxSymbian::EWarning,
   320     nums->AppendL(aTotalNum);
   350                 aTextId, this, 0 );
   321     CleanupStack::Pop(nums);
   351     FLOG(_L("[OBEXUTILS]\t CObexUtilsUiDialog::ShowErrorNoteL completed"));
   322 
   352     }
   323     HBufC* stringholder = StringLoader::LoadLC( R_BT_SENT_IMAGE_NUMBER, *nums); 
   353 
   324     PrepareDialogExecuteL( R_BT_SENT_IMAGE_NUMBER, myNote );
   354 // -----------------------------------------------------------------------------
   325     myNote->ExecuteLD( *stringholder );
   355 // CObexUtilsUiDialog::ShowInformationNoteL
   326     CleanupStack::PopAndDestroy( stringholder );
   356 // -----------------------------------------------------------------------------
   327     }
   357 EXPORT_C void CObexUtilsDialog::ShowInformationNoteL( const TDesC& aTextId )
   328 
   358     {
   329 // -----------------------------------------------------------------------------
   359     FLOG(_L("[OBEXUTILS]\t CObexUtilsUiDialog::ShowInformationNoteL"));
   330 // CObexUtilsDialog::PrepareDialogExecuteL
   360     if ( iMessageBox )
   331 // -----------------------------------------------------------------------------
   361         {
   332 //
   362         //todo: Already one dialog is displayed, currently not supported for 
   333 void CObexUtilsDialog::PrepareDialogExecuteL( const TInt& aResourceID, CEikDialog* aDialog )
   363         //multiple dialogs at the same time.
   334     {
   364         User::Leave( KErrGeneral );
   335     if (iCoverDisplayEnabled)
   365         }
   336         {
   366     iMessageBox = CreateAndShowMessageBoxL( CHbDeviceMessageBoxSymbian::EInformation,
   337         TInt dialogIndex =
   367                     aTextId, this, 0 );
   338             ((aResourceID & KResourceNumberMask) - KFirstResourceOffset) + KEnumStart;
   368     FLOG(_L("[OBEXUTILS]\t CObexUtilsUiDialog::ShowInformationNoteL completed"));
   339         aDialog->PublishDialogL( dialogIndex, KObexUtilsCategory );
   369     }
   340         }
   370 
   341     }
   371 void CObexUtilsDialog::ProgressDialogCancelled(const CHbDeviceProgressDialogSymbian* aDialog)
   342 
   372     {
   343 // -----------------------------------------------------------------------------
   373     FLOG(_L("[BTSU]\t CObexUtilsDialog::ProgressDialogCancelled(), cancelled by user"));
   344 // CObexUtilsDialog::IsCoverDisplayL()
   374     (void) aDialog;
   345 // -----------------------------------------------------------------------------
   375     if ( iDialogObserverPtr )
   346 //
   376         {
   347 TBool CObexUtilsDialog::IsCoverDisplayL()
   377         iDialogObserverPtr->DialogDismissed(ECancelButton);
   348     {
   378         }
   349     TBool coverDisplay = EFalse;
   379     delete iWaitDialog;
   350 	FeatureManager::InitializeLibL();
   380     iWaitDialog = NULL;
   351 	if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
   381     }
   352 		{
   382 
   353 		coverDisplay = ETrue;
   383 // -----------------------------------------------------------------------------
   354 		}
   384 // CObexUtilsDialog::MessageBoxClosed
   355 	FeatureManager::UnInitializeLib();
   385 // -----------------------------------------------------------------------------
   356     return coverDisplay;
   386 void  CObexUtilsDialog::MessageBoxClosed(const CHbDeviceMessageBoxSymbian *aMessageBox, 
       
   387         CHbDeviceMessageBoxSymbian::TButtonId aButton)
       
   388     {
       
   389     FLOG(_L("[OBEXUTILS]\t CObexUtilsUiDialog::MessageBoxClosed"));
       
   390     (void)aMessageBox;
       
   391     delete iMessageBox;
       
   392     iMessageBox = NULL;
       
   393     if(iDialogObserverPtr)
       
   394         {
       
   395         //ETrue if user selects Yes, otherwise EFalse.
       
   396          iDialogObserverPtr->DialogDismissed( 
       
   397                  (aButton == CHbDeviceMessageBoxSymbian::EAcceptButton) ? 
       
   398                      EYesButton : ENoButton  );
       
   399         }
       
   400     FLOG(_L("[OBEXUTILS]\t CObexUtilsUiDialog::MessageBoxClosed completed"));
       
   401     }
       
   402 
       
   403 void CObexUtilsDialog::ProgressDialogClosed(const CHbDeviceProgressDialogSymbian* aDialog)
       
   404     {
       
   405     (void) aDialog;
       
   406     }
       
   407 
       
   408 void CObexUtilsDialog::DataReceived(CHbSymbianVariantMap& aData)
       
   409     {
       
   410     (void) aData;
       
   411     }
       
   412 
       
   413 void CObexUtilsDialog::DeviceDialogClosed(TInt aCompletionCode)
       
   414     {
       
   415     FLOG(_L("[BTSU]\t CObexUtilsDialog::DeviceDialogClosed()"));   
       
   416     (void) aCompletionCode;
       
   417 
       
   418     delete iObexDialogTimer;
       
   419     iObexDialogTimer = NULL;
       
   420     delete iProgressDialog;
       
   421     iProgressDialog = NULL;  
       
   422     
       
   423     TBool ok = HbTextResolverSymbian::Init(KLocFileName, KPath);
       
   424     if(ok)
       
   425         {
       
   426         TRAP_IGNORE(
       
   427                  HBufC* deviceName = HbTextResolverSymbian::LoadLC(KDeviceText,iDeviceName);
       
   428                  HBufC* sendText = HbTextResolverSymbian::LoadLC(KSendingCancelledText);
       
   429                  CHbDeviceNotificationDialogSymbian::NotificationL(
       
   430                          KNullDesC, deviceName->Des(), sendText->Des());
       
   431                  CleanupStack::PopAndDestroy( sendText );		 
       
   432                  CleanupStack::PopAndDestroy( deviceName );
       
   433                 );
       
   434         }
       
   435     else
       
   436         {
       
   437         CHbDeviceNotificationDialogSymbian::NotificationL(
       
   438                 KNullDesC, KDeviceText(), KSendingCancelledText());
       
   439         }
       
   440     if ( iDialogObserverPtr )
       
   441         {
       
   442         iDialogObserverPtr->DialogDismissed(ECancelButton);
       
   443         }
       
   444     }
       
   445 
       
   446 void CObexUtilsDialog::AddDataL(CHbSymbianVariantMap* aMap, const TDesC& aKey, 
       
   447         const TAny* aData, CHbSymbianVariant::TType aDataType)
       
   448     {
       
   449     CHbSymbianVariant* value = CHbSymbianVariant::NewL(aData, aDataType);
       
   450     CleanupStack::PushL( value );
       
   451     User::LeaveIfError( aMap->Add( aKey, value ) ); // aMap takes the ownership of value
       
   452     CleanupStack::Pop( value );
       
   453     }
       
   454 
       
   455 CHbDeviceMessageBoxSymbian* CObexUtilsDialog::CreateAndShowMessageBoxL(
       
   456         CHbDeviceMessageBoxSymbian::TType aType,
       
   457         const TDesC& aText, MHbDeviceMessageBoxObserver* aObserver,
       
   458         TInt aTimeout )
       
   459     {
       
   460     CHbDeviceMessageBoxSymbian* messageBox =
       
   461             CHbDeviceMessageBoxSymbian::NewL( aType );
       
   462     CleanupStack::PushL(messageBox);
       
   463     //ToDo: Need to use localised strings.
       
   464     messageBox->SetTextL(aText);
       
   465     messageBox->SetObserver(aObserver);
       
   466     messageBox->SetTimeout(aTimeout);
       
   467     messageBox->ShowL();
       
   468     CleanupStack::Pop(messageBox);
       
   469     return messageBox;
   357     }
   470     }
   358 
   471 
   359 //  End of File  
   472 //  End of File