vpnui/vpnmanagementui/src/vpnmanagementuilogcontainer.cpp
branchRCL_3
changeset 23 473321461bba
parent 22 9f4e37332ce5
child 24 e06095241a65
equal deleted inserted replaced
22:9f4e37332ce5 23:473321461bba
     1 /*
       
     2 * Copyright (c) 2003-2006 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: The container is responsible of showing log viewer.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <eikclbd.h>
       
    22 #include <AknIconArray.h>
       
    23 #include <aknlists.h>
       
    24 #include <aknmessagequerydialog.h> //for LOG details message query
       
    25 #include <vpnmanagementuirsc.rsg>
       
    26 #include "vpnuiloader.h"
       
    27 #include "vpnmanagementuilogcontainer.h"
       
    28 #include "vpnmanagementuidefs.h"
       
    29 #include "vpnmanagementui.hrh"
       
    30 #ifdef __SCALABLE_ICONS
       
    31 #include <AknsUtils.h>
       
    32 #include <vpnmanagementui.mbg>
       
    33 #endif //__SCALABLE_ICONS
       
    34 
       
    35 
       
    36 #ifdef __SERIES60_HELP
       
    37 #include <csxhelp/vpn.hlp.hrh> // for help context of VPN Management UI
       
    38 #endif //__SERIES60_HELP
       
    39 
       
    40 //CONSTANTS
       
    41 const TInt KVpnLogNumberOfIcons = 3;
       
    42 
       
    43 // ================= MEMBER FUNCTIONS =======================
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // CVpnManagementUiLogContainer::CVpnManagementUiLogContainer(
       
    47 // CVpnManagementUiLogView& aParent, CVpnUiLoader& aLoader)
       
    48 // Constructor with parent
       
    49 // ---------------------------------------------------------
       
    50 //
       
    51 CVpnManagementUiLogContainer::CVpnManagementUiLogContainer(
       
    52     CVpnManagementUiLogView& aParent, CVpnUiLoader& aLoader ) : 
       
    53     iParent ( aParent ), iLoader ( aLoader )
       
    54     {
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------
       
    58 // CVpnManagementUiLogContainer::~CVpnManagementUiLogContainer()
       
    59 // Destructor
       
    60 // ---------------------------------------------------------
       
    61 //
       
    62 CVpnManagementUiLogContainer::~CVpnManagementUiLogContainer()
       
    63     {
       
    64     if(iEventViewer)
       
    65         {
       
    66         delete iEventViewer;
       
    67         iEventViewer = NULL;
       
    68         }
       
    69     if(iLogList)
       
    70         {
       
    71         delete iLogList;
       
    72         iLogList = NULL;
       
    73         }
       
    74 	delete iListBox;
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------
       
    78 // CVpnManagementUiLogContainer::ConstructL(
       
    79 // const TRect& aRect, TInt& aCurrentPosition, TInt& aTopItem)
       
    80 // EPOC two phased constructor
       
    81 // ---------------------------------------------------------
       
    82 //
       
    83 void CVpnManagementUiLogContainer::ConstructL(
       
    84     const TRect& aRect, TInt& /*aCurrentPosition*/ )
       
    85     {
       
    86     CreateWindowL();
       
    87 	CreateListBoxL();
       
    88 
       
    89     ShowLogsL();
       
    90 	SetRect( aRect );
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CVpnManagementUiLogContainer::SizeChanged()
       
    95 // Called by framework when the view size is changed
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CVpnManagementUiLogContainer::SizeChanged()
       
    99     {
       
   100     iListBox->SetRect(Rect());
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------
       
   104 // CVpnManagementUiLogContainer::FocusChanged(TDrawNow aDrawNow)
       
   105 // ---------------------------------------------------------
       
   106 //
       
   107 void CVpnManagementUiLogContainer::FocusChanged(TDrawNow aDrawNow)
       
   108 	{
       
   109 	if ( iListBox ) 
       
   110 		{
       
   111 		iListBox->SetFocus( IsFocused(), aDrawNow );
       
   112 		}
       
   113 	}
       
   114 	
       
   115 // ---------------------------------------------------------
       
   116 // CVpnManagementUiLogContainer::HandleResourceChange
       
   117 // ---------------------------------------------------------
       
   118 //
       
   119 void CVpnManagementUiLogContainer::HandleResourceChange( TInt aType )
       
   120     {
       
   121     CCoeControl::HandleResourceChange(aType); 
       
   122     
       
   123     //Handle change in layout orientation
       
   124     if (aType == KEikDynamicLayoutVariantSwitch || aType == KAknsMessageSkinChange )
       
   125         {
       
   126         iListBox->HandleResourceChange(aType);
       
   127 		TRect mainPaneRect;
       
   128         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
       
   129         SetRect(mainPaneRect);
       
   130 		DrawNow();
       
   131 		}       
       
   132     }	
       
   133 
       
   134 // ---------------------------------------------------------
       
   135 // CVpnManagementUiLogContainer::HandleListBoxEventL(
       
   136 // CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
       
   137 // ---------------------------------------------------------
       
   138 //
       
   139 void CVpnManagementUiLogContainer::HandleListBoxEventL(
       
   140     CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
   141 	{
       
   142     switch(aEventType)
       
   143         {
       
   144         case EEventEnterKeyPressed: 
       
   145         case EEventItemSingleClicked:
       
   146             iParent.HandleCommandL(EVpnUiCmdLogDetails);        
       
   147             break;
       
   148         default:  
       
   149             //Do nothing          
       
   150             break;
       
   151         }        
       
   152 	}
       
   153 enum { EListBoxControl, ENumberOfControls };
       
   154 
       
   155 // ---------------------------------------------------------
       
   156 // CVpnManagementUiLogContainer::CountComponentControls() const
       
   157 // ---------------------------------------------------------
       
   158 //
       
   159 TInt CVpnManagementUiLogContainer::CountComponentControls() const
       
   160     {
       
   161 	// return number of controls inside this container
       
   162     return ENumberOfControls; // return nbr of controls inside this container
       
   163     }
       
   164 
       
   165 // ---------------------------------------------------------
       
   166 // CVpnManagementUiLogContainer::ComponentControl(TInt aIndex) const
       
   167 // ---------------------------------------------------------
       
   168 //
       
   169 CCoeControl* CVpnManagementUiLogContainer::ComponentControl(TInt aIndex) const
       
   170     {
       
   171     switch ( aIndex )
       
   172         {
       
   173         case 0:
       
   174 			return iListBox;
       
   175         default:
       
   176             return NULL;
       
   177         }
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------
       
   181 // CVpnManagementUiLogContainer::HandleControlEventL(
       
   182 //    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
       
   183 // Cannot be changed to non-leaving function. 
       
   184 // L-function is required by the class definition, even if empty.
       
   185 // ---------------------------------------------------------
       
   186 //
       
   187 void CVpnManagementUiLogContainer::HandleControlEventL(
       
   188     CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
       
   189     {
       
   190     }
       
   191 
       
   192 // ---------------------------------------------------------
       
   193 // CVpnManagementUiLogContainer::OfferKeyEventL(
       
   194 // const TKeyEvent& aKeyEvent, TEventCode aType)
       
   195 // Handles the key events OK button, arrow keys, delete key.
       
   196 // OK button show VPN log details,
       
   197 // if list is empty then arrow keys and OK inactive.
       
   198 // Delete active only if list not empty.
       
   199 // ---------------------------------------------------------
       
   200 //
       
   201 TKeyResponse CVpnManagementUiLogContainer::OfferKeyEventL(
       
   202     const TKeyEvent& aKeyEvent, TEventCode aType)
       
   203 	{
       
   204     TKeyResponse retval = EKeyWasNotConsumed;
       
   205 	if ( aType==EEventKey )
       
   206 		{
       
   207 		if ( (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) && // select or enter
       
   208              iListBox->CurrentItemIndex() > -1) //This is for empty list
       
   209             {
       
   210 	        // Selection key pressed.
       
   211             LogDetailsL(iListBox->CurrentItemIndex());
       
   212 
       
   213 			retval = EKeyWasConsumed;	
       
   214 			}
       
   215 
       
   216         else if ( aKeyEvent.iCode == EKeyUpArrow )
       
   217 			{
       
   218 			retval = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   219     		}
       
   220 		else if ( aKeyEvent.iCode == EKeyDownArrow )
       
   221 			{
       
   222             TEventProperties eventProperties;
       
   223             HBufC* eventText = NULL;
       
   224             TInt currentPosition = iListBox->CurrentItemIndex();
       
   225             if((iEventViewer != NULL) && (iLogList->Count() > 0))
       
   226                 {
       
   227                 iEventViewer->GetEventUsingEventNumber(eventText, iLogList->At(iLogList->Count() - 1).iEventNumber, eventProperties);
       
   228                 delete eventText;
       
   229                 }
       
   230             UpdateListBoxL(currentPosition);
       
   231    			retval = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   232 			}
       
   233         }
       
   234 	else
       
   235 		{
       
   236 		retval = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   237 		}
       
   238 
       
   239 
       
   240     return retval;
       
   241 	}
       
   242 
       
   243 // ---------------------------------------------------------
       
   244 // CVpnManagementUiLogContainer::CreateListBoxL()
       
   245 // Creates listbox, sets empty listbox text.
       
   246 // ---------------------------------------------------------
       
   247 //
       
   248 void CVpnManagementUiLogContainer::CreateListBoxL()
       
   249 	{
       
   250 	iListBox = new( ELeave ) CAknDoubleGraphicStyleListBox;
       
   251 	iListBox->SetContainerWindowL( *this );
       
   252 	iListBox->ConstructL( this, EAknListBoxSelectionList ); 
       
   253 	iListBox->CreateScrollBarFrameL( ETrue );
       
   254 	iListBox->ScrollBarFrame()->
       
   255         SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto );
       
   256 	iListBox->SetListBoxObserver(this);
       
   257 
       
   258 #ifdef __SCALABLE_ICONS
       
   259 
       
   260     CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( KVpnLogNumberOfIcons );
       
   261     CleanupStack::PushL( icons );
       
   262 
       
   263     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   264     
       
   265     TFileName fileName = GetIconFilenameL();
       
   266 
       
   267     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   268                                             KAknsIIDQgnPropVpnLogInfo,
       
   269                                             fileName, 
       
   270                                             EMbmVpnmanagementuiQgn_prop_vpn_log_info, 
       
   271                                             EMbmVpnmanagementuiQgn_prop_vpn_log_info_mask ) );
       
   272 
       
   273     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   274                                             KAknsIIDQgnPropVpnLogWarn,
       
   275                                             fileName, 
       
   276                                             EMbmVpnmanagementuiQgn_prop_vpn_log_warn, 
       
   277                                             EMbmVpnmanagementuiQgn_prop_vpn_log_warn_mask ) );
       
   278 
       
   279     icons->AppendL( AknsUtils::CreateGulIconL( skinInstance, 
       
   280                                             KAknsIIDQgnPropVpnLogError,
       
   281                                             fileName, 
       
   282                                             EMbmVpnmanagementuiQgn_prop_vpn_log_error, 
       
   283                                             EMbmVpnmanagementuiQgn_prop_vpn_log_error_mask ) );
       
   284   
       
   285     iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
       
   286 
       
   287     CleanupStack::Pop(); // icons
       
   288 #else
       
   289     CAknIconArray* icons = new(ELeave) CAknIconArray(KVpnLogNumberOfIcons);
       
   290     icons->ConstructFromResourceL(R_VPN_LOG_ICON_ARRAY);
       
   291 
       
   292  	iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
       
   293 
       
   294 #endif //__SCALABLE_ICONS
       
   295 
       
   296     EmptyViewTextL();
       
   297 	}
       
   298 
       
   299 // ---------------------------------------------------------
       
   300 // CVpnManagementUiLogContainer::EmptyViewTextL()
       
   301 // Reads text from resource to empty log view
       
   302 // and put text to the listbox.
       
   303 // ---------------------------------------------------------
       
   304 //
       
   305 void CVpnManagementUiLogContainer::EmptyViewTextL()
       
   306     {
       
   307     HBufC* stringHolder = StringLoader::LoadLC( R_VPN_LOG_EMPTY );
       
   308 	iListBox->View()->SetListEmptyTextL( *stringHolder );
       
   309 	CleanupStack::PopAndDestroy();  // stringHolder
       
   310     }
       
   311 
       
   312 // ---------------------------------------------------------
       
   313 // CVpnManagementUiLogContainer::RemoveAllFromListBoxL()
       
   314 // Removes all from listbox.
       
   315 // ---------------------------------------------------------
       
   316 //
       
   317 void CVpnManagementUiLogContainer::RemoveAllFromListBoxL()
       
   318     {
       
   319     MDesCArray* itemList = iListBox->Model()->ItemTextArray();
       
   320 	CDesCArray* itemArray = (CDesCArray*) itemList;
       
   321     itemArray->Reset();
       
   322     iListBox->HandleItemRemovalL();
       
   323     iListItemCount = 0;
       
   324     DrawNow();
       
   325     }
       
   326 
       
   327 // ---------------------------------------------------------
       
   328 // CVpnManagementUiLogContainer::DrawListBoxL(TInt aCurrentPosition, TInt aTopItem)
       
   329 // Draws listbox, fetches graphic icons for markable list
       
   330 // ---------------------------------------------------------
       
   331 //
       
   332 void CVpnManagementUiLogContainer::DrawListBoxL( 
       
   333     TInt aCurrentPosition, TInt aTopItem )
       
   334 	{
       
   335 
       
   336 	if (aCurrentPosition >= 0)
       
   337 		{
       
   338 		iListBox->SetTopItemIndex( aTopItem );
       
   339 		iListBox->SetCurrentItemIndex( aCurrentPosition );
       
   340 		}
       
   341 	ActivateL();
       
   342 	DrawNow();
       
   343 
       
   344 	}
       
   345 
       
   346 void CVpnManagementUiLogContainer::ShowLogsL() 
       
   347     {
       
   348     iListItemCount = 0;
       
   349 
       
   350     //Create CEventViewer object
       
   351     delete iEventViewer;
       
   352     iEventViewer = NULL;
       
   353     TRAPD(error, iEventViewer = CEventViewer::NewL());
       
   354     if (error != KErrNone)
       
   355         return;
       
   356 
       
   357     delete iLogList;
       
   358     iLogList = NULL;
       
   359     iLogList = new (ELeave) CArrayFixFlat<TEventProperties>(3);
       
   360 
       
   361    	CDesCArrayFlat* itemTextArray = static_cast<CDesCArrayFlat*>(iListBox->Model()->ItemTextArray());
       
   362 
       
   363 	itemTextArray->Reset();
       
   364 	iListBox->Reset();
       
   365 
       
   366     TEventProperties eventProperties;
       
   367     HBufC* eventText = NULL;
       
   368     
       
   369     //First item
       
   370     TBuf<100> itemName;
       
   371     TInt ret = iEventViewer->GetMostRecentEvent(eventText, eventProperties);
       
   372     if(ret==KErrNone)
       
   373         {
       
   374         CleanupStack::PushL(eventText);
       
   375 
       
   376         iLogList->AppendL(eventProperties);
       
   377 
       
   378         //append index of icon array
       
   379         itemName.AppendNum(GetIconArrayIndex(eventProperties.iCategory)); 
       
   380         
       
   381         itemName.Append(_L("\t"));
       
   382 
       
   383         TPtr eventTextDesc(eventText->Des());
       
   384         TInt length = eventTextDesc.Length();
       
   385         if(length > KMaxLogListLength)
       
   386             {
       
   387             eventTextDesc.Delete(KMaxLogListLength, length-KMaxLogListLength);
       
   388             }
       
   389         itemName.Append(eventTextDesc);
       
   390         CleanupStack::PopAndDestroy(); //eventText
       
   391         itemName.Append(_L("\t"));
       
   392         
       
   393         //Format time stamp for LOG view
       
   394         TBuf<2 * KMaxLengthTextDateString + 3> logEntry;
       
   395         TimeLogEntryL(logEntry, eventProperties.iTimeStamp);
       
   396 
       
   397         itemName.Append(logEntry);
       
   398 
       
   399         itemTextArray->AppendL(itemName);
       
   400 	    iListBox->HandleItemAdditionL();
       
   401         iListItemCount++;
       
   402         //Get rest of events    
       
   403         while (ret==KErrNone)
       
   404             {
       
   405             TInt currentPosition = iListBox->CurrentItemIndex();
       
   406             ret = UpdateListBoxL(currentPosition);
       
   407             }
       
   408 
       
   409         }
       
   410 
       
   411     }
       
   412 
       
   413 TInt CVpnManagementUiLogContainer::GetIconArrayIndex(TLogCategory2& aCategory)
       
   414     {
       
   415     //index of icon array
       
   416     if (aCategory == ELogInfo)
       
   417         return 0;     //index of icon array
       
   418     else if (aCategory == ELogWarning)
       
   419         return 1;    //index of icon array
       
   420     else if (aCategory == ELogError)
       
   421         return 2;    //index of icon array
       
   422     else
       
   423         return 2;
       
   424     }
       
   425 
       
   426 
       
   427 void CVpnManagementUiLogContainer::TimeLogEntryL(TDes& aDes, TTime aTime)
       
   428     {
       
   429      // Date
       
   430     HBufC* dateFormat = StringLoader::LoadLC(R_QTN_DATE_USUAL_WITH_ZERO);
       
   431     TBuf<KMaxLengthTextDateString> dateString;
       
   432     aTime.FormatL(dateString, *dateFormat);
       
   433     AknTextUtils::DisplayTextLanguageSpecificNumberConversion(dateString);
       
   434     CleanupStack::PopAndDestroy(); //dateFormat
       
   435 
       
   436     // Time
       
   437     dateFormat = StringLoader::LoadLC(R_QTN_TIME_USUAL_WITH_ZERO);
       
   438     TBuf<KMaxLengthTextDateString> timeString;
       
   439     aTime.FormatL(timeString, *dateFormat);
       
   440     AknTextUtils::DisplayTextLanguageSpecificNumberConversion(timeString);
       
   441     CleanupStack::PopAndDestroy(); //dateFormat
       
   442       
       
   443 //    TBuf<KMaxShortDateFormatSpec*2> dateBuffer; // KMaxShortDateFormatSpec is defined in e32std.h
       
   444 //    TBuf<KMaxTimeFormatSpec*2> timeBuffer; // KMaxTimeFormatSpec is defined in e32std.h
       
   445 
       
   446     TBuf<2 * KMaxLengthTextDateString + 3> logEntry;
       
   447     
       
   448     TTime now;
       
   449 	now.HomeTime();
       
   450     if ( (now.YearsFrom( aTime ).Int() > 0) ||
       
   451         (aTime.DayNoInYear() < now.DayNoInYear()) )
       
   452         {
       
   453         logEntry.Append(dateString);
       
   454         logEntry.Append(KVpnManagementUiSpaceHyphenSpace);
       
   455         }
       
   456 
       
   457     logEntry.Append(timeString);
       
   458     aDes = logEntry;
       
   459     }
       
   460 
       
   461 // ---------------------------------------------------------
       
   462 // CVpnManagementUiLogContainer::UpdateListBoxL(TInt& aCurrentPosition)
       
   463 // 
       
   464 // ---------------------------------------------------------
       
   465 //
       
   466 TInt CVpnManagementUiLogContainer::UpdateListBoxL(TInt& /*aCurrentPosition*/)
       
   467 	{ 
       
   468 	MDesCArray* itemList = iListBox->Model()->ItemTextArray();
       
   469 	CDesCArray* itemArray = ( CDesCArray* )itemList;
       
   470 
       
   471     TEventProperties eventProperties;
       
   472     HBufC* eventText = NULL;
       
   473     TBuf<100> itemName;
       
   474     
       
   475     //next item
       
   476     if(iEventViewer != NULL)
       
   477         {
       
   478         TInt ret = iEventViewer->GetPreviousEvent(eventText, eventProperties);
       
   479         if(ret==KErrNone)
       
   480             {
       
   481             CleanupStack::PushL(eventText);
       
   482             iLogList->AppendL(eventProperties);
       
   483 
       
   484             //append index of icon array       
       
   485             itemName.AppendNum(GetIconArrayIndex(eventProperties.iCategory)); 
       
   486 
       
   487             itemName.Append(_L("\t"));
       
   488 
       
   489             TPtr eventTextDesc(eventText->Des());
       
   490             TInt length = eventTextDesc.Length();
       
   491             if(length > KMaxLogListLength)
       
   492                 eventTextDesc.Delete(KMaxLogListLength, length-KMaxLogListLength);
       
   493             itemName.Append(eventTextDesc);
       
   494             CleanupStack::PopAndDestroy(); //eventText
       
   495             itemName.Append(_L("\t"));
       
   496 
       
   497             //Format time stamp for LOG view
       
   498             TBuf<2 * KMaxLengthTextDateString + 3> logEntry;
       
   499             TimeLogEntryL(logEntry, eventProperties.iTimeStamp);
       
   500 
       
   501             itemName.Append(logEntry);
       
   502 
       
   503             itemArray->AppendL(itemName);
       
   504             iListBox->HandleItemAdditionL();
       
   505             iListItemCount++;
       
   506             }
       
   507 
       
   508         iParent.SetMiddleSoftKeyL(ETrue);
       
   509         return ret;
       
   510  
       
   511         }
       
   512         
       
   513     iParent.SetMiddleSoftKeyL(ETrue);
       
   514     return KErrNotFound;
       
   515     }
       
   516 
       
   517 // ---------------------------------------------------------
       
   518 // CVpnManagementUiLogContainer::LogDetailsL()
       
   519 // Creates the log details message query
       
   520 // Appends strings from resource and eventviewer to one
       
   521 // message body text and displays it.
       
   522 // ---------------------------------------------------------
       
   523 //
       
   524 void CVpnManagementUiLogContainer::LogDetailsL(TInt aIndex)
       
   525     {
       
   526     TEventProperties eventProperties;
       
   527     eventProperties = iLogList->At(aIndex);
       
   528 
       
   529     HBufC* message = NULL;
       
   530     HBufC* eventText = NULL;
       
   531     iEventViewer->GetEventUsingEventNumber(eventText, eventProperties.iEventNumber, eventProperties);
       
   532   	CleanupStack::PushL( eventText );
       
   533 
       
   534     if(eventProperties.iCategory == ELogInfo)
       
   535         {
       
   536         // Info:
       
   537         message = StringLoader::LoadLC( R_VPN_DETAIL_LOG_ENTRY_INFO );
       
   538         }
       
   539 
       
   540     if(eventProperties.iCategory == ELogWarning)
       
   541         {
       
   542         // Warning:
       
   543         message = StringLoader::LoadLC( R_VPN_DETAIL_LOG_ENTRY_WARNING );
       
   544         }
       
   545 
       
   546     if(eventProperties.iCategory == ELogError)
       
   547         {
       
   548         // Error:
       
   549         message = StringLoader::LoadLC( R_VPN_DETAIL_LOG_ENTRY_ERROR );
       
   550         }
       
   551 
       
   552     __ASSERT_DEBUG(message != NULL, User::Invariant());
       
   553     
       
   554     HBufC* messageText = HBufC::NewLC(message->Length() + eventText->Length() + 2);
       
   555 
       
   556     messageText->Des().Append(*message); //Append category
       
   557     messageText->Des().Append(KVpnManagementUiSpace); 
       
   558     messageText->Des().Append(*eventText); //Append log entry message
       
   559 
       
   560     // Heading is the date and the time of the log entry
       
   561     //Format time stamp for LOG view
       
   562     TBuf<2 * KMaxLengthTextDateString + 3> logEntry;
       
   563     TimeLogEntryL(logEntry, eventProperties.iTimeStamp);
       
   564 
       
   565 	CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*messageText);
       
   566 
       
   567   	CleanupStack::PopAndDestroy(3); // message Text, message, eventText
       
   568 
       
   569     dlg->PrepareLC(R_MESSAGE_QUERY_DETAILS_VIEW);
       
   570 	dlg->QueryHeading()->SetTextL(logEntry);
       
   571 	dlg->RunLD();
       
   572     }
       
   573 
       
   574 // ---------------------------------------------------------
       
   575 // CVpnManagementUiLogContainer::ReadResourceL(HBufC& aText, TInt aResource);
       
   576 // Reads text from resource
       
   577 // ---------------------------------------------------------
       
   578 //
       
   579 void CVpnManagementUiLogContainer::ReadResourceL(HBufC& aText, TInt aResource)
       
   580 	{
       
   581 	HBufC* text = StringLoader::LoadLC( aResource );
       
   582 	aText.Des().Append(text->Des());
       
   583 	CleanupStack::PopAndDestroy();  // text
       
   584 	}
       
   585 
       
   586 // ---------------------------------------------------------
       
   587 // CVpnManagementUiLogContainer::ClearLogL()
       
   588 // Asks confirmation from user.
       
   589 // Clears VPN log view.
       
   590 // Calls eventviewer to clear log.
       
   591 // ---------------------------------------------------------
       
   592 //
       
   593 void CVpnManagementUiLogContainer::ClearLogL()
       
   594     {
       
   595     // Read query text from resource
       
   596     HBufC* temp;
       
   597     temp = StringLoader::LoadLC( R_VPN_QUEST_CLEAR_LOG );
       
   598 
       
   599     // Asks confirmation from user
       
   600     CAknQueryDialog* query = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
       
   601     TInt retval = query->ExecuteLD( R_CONFIRMATION_QUERY, *temp );
       
   602     CleanupStack::PopAndDestroy();  // temp
       
   603     if ( retval )
       
   604         {
       
   605         // Clear VPN log listbox
       
   606         RemoveAllFromListBoxL();
       
   607 
       
   608         // Calls eventviewer to clear log.
       
   609         iEventViewer->DeleteLogFile();
       
   610         }
       
   611         
       
   612         iParent.SetMiddleSoftKeyL(ETrue);
       
   613     }
       
   614 
       
   615 // ---------------------------------------------------------
       
   616 // CVpnManagementUiLogContainer::IconArrayResourceId
       
   617 // Loads Mark/Unmark icons from resource
       
   618 // ---------------------------------------------------------
       
   619 //
       
   620 TInt CVpnManagementUiLogContainer::IconArrayResourceId() const
       
   621     {
       
   622     return 0; //TVA
       
   623     }
       
   624 
       
   625 // ---------------------------------------------------------
       
   626 // CVpnManagementUiLogContainer::CreateIconArrayL
       
   627 // Creates Icon Array
       
   628 // ---------------------------------------------------------
       
   629 //
       
   630 CAknIconArray* CVpnManagementUiLogContainer::CreateIconArrayL() const
       
   631     {
       
   632 	CAknIconArray* icons = new (ELeave) CAknIconArray( KGranularity );
       
   633 	CleanupStack::PushL( icons );
       
   634     icons->ConstructFromResourceL( IconArrayResourceId() );
       
   635 	CleanupStack::Pop(); // icons
       
   636     return icons;
       
   637     }
       
   638 
       
   639 TFileName CVpnManagementUiLogContainer::GetIconFilenameL()
       
   640     {
       
   641     RFs& fsSession = CCoeEnv::Static()->FsSession(); 
       
   642 
       
   643     TDriveList driveList;
       
   644     User::LeaveIfError(fsSession.DriveList(driveList));
       
   645 
       
   646     TInt driveNumber;
       
   647     TDriveName drive = _L("a:");
       
   648 
       
   649     TFileName iconName;
       
   650     
       
   651     for (driveNumber = EDriveA, drive[0] = 'a';
       
   652          driveNumber <= EDriveZ;
       
   653          driveNumber++, drive[0]++)
       
   654         {
       
   655         if (!driveList[driveNumber])
       
   656             {
       
   657             continue;
       
   658             }
       
   659 
       
   660         TParse parse;
       
   661         parse.Set(drive, &KVpnLogIcons, NULL);
       
   662         iconName.Copy(parse.DriveAndPath()); 
       
   663         iconName.Append(parse.Name()); 
       
   664         iconName.Append(_L(".mif"));
       
   665                 
       
   666         TEntry entry;
       
   667         if (fsSession.Entry(iconName, entry) == KErrNone)
       
   668             {
       
   669             //icon founded
       
   670             break;
       
   671             }
       
   672         }
       
   673 
       
   674     return iconName;
       
   675     }
       
   676 
       
   677 // ---------------------------------------------------------
       
   678 // CVpnManagementUiLogContainer::GetHelpContext
       
   679 // This function is called when Help application is launched.  
       
   680 // (other items were commented in a header).
       
   681 // ---------------------------------------------------------
       
   682 //
       
   683 #ifdef __SERIES60_HELP
       
   684 void CVpnManagementUiLogContainer::GetHelpContext( 
       
   685     TCoeHelpContext& aContext ) const
       
   686     {
       
   687 	aContext.iMajor = KUidVpnManagementUi;
       
   688     aContext.iContext = KSET_HLP_VPN_LOG_VIEW;
       
   689     }
       
   690 #endif //__SERIES60_HELP
       
   691 
       
   692 // End of File