hti/HtiFramework/src/HtiNotifier.cpp
branchRCL_3
changeset 59 8ad140f3dd41
parent 0 a03f92240627
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     1 /*
       
     2 * Copyright (c) 2009 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:  HtiNotifier implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "HtiNotifier.h"
       
    19 
       
    20 _LIT( KHtiError, "HtiError" );
       
    21 _LIT( KHtiOkButton, "Ok" );
       
    22 
       
    23 
       
    24 /**
       
    25 *
       
    26 * Helper function to convert Symbian os error codes
       
    27 * to readable format.
       
    28 *
       
    29 */
       
    30 LOCAL_C HBufC* SOSErr2DesL( TInt err )
       
    31 {
       
    32     TBuf<50> s;
       
    33     switch ( err )
       
    34     {
       
    35     case KErrNone:                  s.Append( _L("KErrNone") ); break;
       
    36     case KErrNotFound:              s.Append( _L("KErrNotFound") ); break;
       
    37     case KErrGeneral:               s.Append( _L("KErrGeneral") ); break;
       
    38     case KErrCancel:                s.Append( _L("KErrCancel") ); break;
       
    39     case KErrNoMemory:              s.Append( _L("KErrNoMemory") ); break;
       
    40     case KErrNotSupported:          s.Append( _L("KErrNotSupported") ); break;
       
    41     case KErrArgument:              s.Append( _L("KErrArgument") ); break;
       
    42     case KErrTotalLossOfPrecision:  s.Append( _L("KErrTotalLossOfPrecision") ); break;
       
    43     case KErrBadHandle:             s.Append( _L("KErrBadHandle") ); break;
       
    44     case KErrOverflow:              s.Append( _L("KErrOverflow") ); break;
       
    45     case KErrUnderflow:             s.Append( _L("KErrUnderflow") ); break;
       
    46     case KErrAlreadyExists:         s.Append( _L("KErrAlreadyExists") ); break;
       
    47     case KErrPathNotFound:          s.Append( _L("KErrPathNotFound") ); break;
       
    48     case KErrDied:                  s.Append( _L("KErrDied") ); break;
       
    49     case KErrInUse:                 s.Append( _L("KErrInUse") ); break;
       
    50     case KErrServerTerminated:      s.Append( _L("KErrServerTerminated") ); break;
       
    51     case KErrServerBusy:            s.Append( _L("KErrServerBusy") ); break;
       
    52     case KErrCompletion:            s.Append( _L("KErrCompletion") ); break;
       
    53     case KErrNotReady:              s.Append( _L("KErrNotReady") ); break;
       
    54     case KErrUnknown:               s.Append( _L("KErrUnknown") ); break;
       
    55     case KErrCorrupt:               s.Append( _L("KErrCorrupt") ); break;
       
    56     case KErrAccessDenied:          s.Append( _L("KErrAccessDenied") ); break;
       
    57     case KErrLocked:                s.Append( _L("KErrLocked") ); break;
       
    58     case KErrWrite:                 s.Append( _L("KErrWrite") ); break;
       
    59     case KErrDisMounted:            s.Append( _L("KErrDisMounted") ); break;
       
    60     case KErrEof:                   s.Append( _L("KErrEof") ); break;
       
    61     case KErrDiskFull:              s.Append( _L("KErrDiskFull") ); break;
       
    62     case KErrBadDriver:             s.Append( _L("KErrBadDriver") ); break;
       
    63     case KErrBadName:               s.Append( _L("KErrBadName") ); break;
       
    64     case KErrCommsLineFail:         s.Append( _L("KErrCommsLineFail") ); break;
       
    65     case KErrCommsFrame:            s.Append( _L("KErrCommsFrame") ); break;
       
    66     case KErrCommsOverrun:          s.Append( _L("KErrCommsOverrun") ); break;
       
    67     case KErrCommsParity:           s.Append( _L("KErrCommsParity") ); break;
       
    68     case KErrTimedOut:              s.Append( _L("KErrTimedOut") ); break;
       
    69     case KErrCouldNotConnect:       s.Append( _L("KErrCouldNotConnect") ); break;
       
    70     case KErrCouldNotDisconnect:    s.Append( _L("KErrCouldNotDisconnect") ); break;
       
    71     case KErrDisconnected:          s.Append( _L("KErrDisconnected") ); break;
       
    72     case KErrBadLibraryEntryPoint:  s.Append( _L("KErrBadLibraryEntryPoint") ); break;
       
    73     case KErrBadDescriptor:         s.Append( _L("KErrBadDescriptor") ); break;
       
    74     case KErrAbort:                 s.Append( _L("KErrAbort") ); break;
       
    75     case KErrTooBig:                s.Append( _L("KErrTooBig") ); break;
       
    76     case KErrDivideByZero:          s.Append( _L("KErrDivideByZero") ); break;
       
    77     case KErrBadPower:              s.Append( _L("KErrBadPower") ); break;
       
    78     case KErrDirFull:               s.Append( _L("KErrDirFull") ); break;
       
    79     case KErrHardwareNotAvailable:  s.Append( _L("KErrHardwareNotAvailable") ); break;
       
    80     case KErrSessionClosed:         s.Append( _L("KErrSessionClosed") ); break;
       
    81     case KErrPermissionDenied:      s.Append( _L("KErrPermissionDenied") ); break;
       
    82     case KErrExtensionNotSupported: s.Append( _L("KErrExtensionNotSupported") ); break;
       
    83     case KErrCommsBreak:            s.Append( _L("KErrCommsBreak") ); break;
       
    84     default:
       
    85             s.AppendFormat( _L("errorcode %d"), err );
       
    86             return s.AllocL();
       
    87     }
       
    88     s.AppendFormat( _L("(%d)"), err );
       
    89     return s.AllocL();
       
    90 }
       
    91 
       
    92 /**
       
    93 *
       
    94 * CHtiNotifier implementation
       
    95 *
       
    96 */
       
    97 void CHtiNotifier::ShowErrorL( const TDesC& aText )
       
    98 {
       
    99     RNotifier notifier;
       
   100     User::LeaveIfError( notifier.Connect() );
       
   101 
       
   102     TRequestStatus status;
       
   103     TInt button;
       
   104     notifier.Notify( KHtiError, aText,
       
   105                      KHtiOkButton, KNullDesC, button, status );
       
   106     User::WaitForRequest( status );
       
   107     notifier.Close();
       
   108 }
       
   109 
       
   110 void CHtiNotifier::ShowErrorL( const TDesC& aText, TInt aErr )
       
   111 {
       
   112     RNotifier notifier;
       
   113     User::LeaveIfError( notifier.Connect() );
       
   114 
       
   115     TBuf<KMaxHtiNotifierLength> errorMsg;
       
   116     errorMsg.Append( aText );
       
   117     errorMsg.Append( _L("\n") );
       
   118     HBufC* errString = SOSErr2DesL( aErr );
       
   119     errorMsg.Append( errString->Des() );
       
   120     delete errString;
       
   121 
       
   122     TRequestStatus status;
       
   123     TInt button;
       
   124     notifier.Notify( KHtiError, errorMsg,
       
   125                      KHtiOkButton, KNullDesC, button, status );
       
   126     User::WaitForRequest( status );
       
   127     notifier.Close();
       
   128 }
       
   129