src/NPRAppUi.cpp
changeset 0 0049171ecffb
equal deleted inserted replaced
-1:000000000000 0:0049171ecffb
       
     1 /*
       
     2  ============================================================================
       
     3  Name	: NPRAppUi.cpp
       
     4  Author	: John Kern
       
     5  
       
     6  Copyright (c) 2009 Symbian Foundation Ltd
       
     7  This component and the accompanying materials are made available
       
     8  under the terms of the License "Eclipse Public License v1.0"
       
     9  which accompanies this distribution, and is available
       
    10  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    11 
       
    12  Initial Contributors:
       
    13  - Symbian Foundation Ltd - initial contribution.
       
    14  - Symsource
       
    15  
       
    16  Contributors:
       
    17  - John Kern
       
    18  - Symsource
       
    19  
       
    20  Description : CNPRAppUi implementation
       
    21  ============================================================================
       
    22  */
       
    23 
       
    24 // INCLUDE FILES
       
    25 #include <aknmessagequerydialog.h>
       
    26 #include <s32file.h>
       
    27 #include <Xml/Parser.h> 
       
    28 #include <NPR_0xEEB0E481.rsg>
       
    29 
       
    30 #include "NPR_0xEEB0E481.hlp.hrh"
       
    31 #include "NPR.hrh"
       
    32 #include "NPR.pan"
       
    33 #include "NPRApplication.h"
       
    34 #include "NPRAppUi.h"
       
    35 #include "NPRAppEngine.h"
       
    36 #include "NPRListBoxView.h"
       
    37 #include "NPRStoryListBoxView.h"
       
    38 #include "NPRStationListBoxView.h"
       
    39 #include "NPRSearchStationListBoxView.h"
       
    40 #include "NPRBrowserAknView.h"
       
    41 
       
    42 
       
    43 _LIT( KFileName, "C:\\private\\EEB0E481\\NPR.txt" );
       
    44 _LIT( KText, "Hello World!");
       
    45 
       
    46 // ============================ MEMBER FUNCTIONS ===============================
       
    47 
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CNPRAppUi::ConstructL()
       
    51 // Symbian 2nd phase constructor can leave.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CNPRAppUi::ConstructL()
       
    55 	{
       
    56 	// Initialise app UI with standard value.
       
    57 	BaseConstructL(CAknAppUi::EAknEnableSkin);
       
    58 	
       
    59 	// Create a file to write the text to
       
    60 	TInt err = CCoeEnv::Static()->FsSession().MkDirAll(KFileName);
       
    61 	if ((KErrNone != err) && (KErrAlreadyExists != err))
       
    62 		{
       
    63 		Exit();
       
    64 		}
       
    65 
       
    66 	RFile file;
       
    67 	err = file.Replace(CCoeEnv::Static()->FsSession(), KFileName, EFileWrite);
       
    68 	CleanupClosePushL(file);
       
    69 	if (KErrNone != err)
       
    70 		{
       
    71 		CleanupStack::PopAndDestroy(1); // file
       
    72 		Exit();
       
    73 		}
       
    74 
       
    75 	RFileWriteStream outputFileStream(file);
       
    76 	CleanupClosePushL(outputFileStream);
       
    77 	outputFileStream << KText;
       
    78 	this->Document();
       
    79 	CleanupStack::PopAndDestroy(2); // outputFileStream, file
       
    80 
       
    81 	TRAP(err, this->iNPRAppEngine = CNPRAppEngine::NewL(*this));
       
    82 	if(err != KErrNone)
       
    83 		{
       
    84 		Exit();
       
    85 		}
       
    86 	
       
    87 	CNPRListBoxView* mainListBoxView = CNPRListBoxView::NewL();
       
    88 	AddViewL(mainListBoxView);
       
    89 
       
    90 	CNPRStoryListBoxView* storyListBoxView = CNPRStoryListBoxView::NewL();
       
    91 	AddViewL(storyListBoxView);
       
    92 
       
    93 	CNPRStationListBoxView* StationListBoxView = CNPRStationListBoxView::NewL();
       
    94 	AddViewL(StationListBoxView);
       
    95 
       
    96 	CNPRSearchStationListBoxView* searchStationListBoxView = CNPRSearchStationListBoxView::NewL();
       
    97 	AddViewL(searchStationListBoxView);
       
    98 	
       
    99 	CBrowserAknView* browserView = CBrowserAknView::NewL(*iNPRAppEngine);
       
   100 	AddViewL(browserView);
       
   101 
       
   102 	ActivateLocalViewL(TUid::Uid(ENPRListBoxViewId));
       
   103 	}
       
   104 // -----------------------------------------------------------------------------
       
   105 // CNPRAppUi::CNPRAppUi()
       
   106 // C++ default constructor can NOT contain any code, that might leave.
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 CNPRAppUi::CNPRAppUi()
       
   110 	{
       
   111 	// No implementation required
       
   112 	}
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CNPRAppUi::~CNPRAppUi()
       
   116 // Destructor.
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 CNPRAppUi::~CNPRAppUi()
       
   120 	{
       
   121 	delete iNPRAppEngine;
       
   122 	}
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CNPRAppUi::HandleCommandL()
       
   126 // Takes care of command handling.
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 void CNPRAppUi::HandleCommandL(TInt aCommand)
       
   130 	{
       
   131 	switch (aCommand)
       
   132 		{
       
   133 		case EEikCmdExit:
       
   134 		case EAknSoftkeyExit:
       
   135 			{
       
   136 			Exit();
       
   137 			}
       
   138 			break;
       
   139 		case EAbout:
       
   140 			{
       
   141 			CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog();
       
   142 			dlg->PrepareLC(R_ABOUT_QUERY_DIALOG);
       
   143 			HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE);
       
   144 			dlg->QueryHeading()->SetTextL(*title);
       
   145 			CleanupStack::PopAndDestroy(); //title
       
   146 			HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT);
       
   147 			dlg->SetMessageTextL(*msg);
       
   148 			CleanupStack::PopAndDestroy(); //msg
       
   149 			dlg->RunLD();
       
   150 			}
       
   151 			break;
       
   152 		default:
       
   153 			Panic(ENPRUi);
       
   154 			break;
       
   155 		}
       
   156 	}
       
   157 
       
   158 CNPRAppEngine& CNPRAppUi::Engine()
       
   159 	{
       
   160 	return *iNPRAppEngine;
       
   161 	}
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 //  Called by the framework when the application status pane
       
   165 //  size is changed.  Passes the new client rectangle to the
       
   166 //  AppView
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 void CNPRAppUi::HandleStatusPaneSizeChange()
       
   170 	{
       
   171 	//iAppView->SetRect(ClientRect());
       
   172 	}
       
   173 
       
   174 CArrayFix<TCoeHelpContext>* CNPRAppUi::HelpContextL() const
       
   175 	{
       
   176 #warning "Please see comment about help and UID3..."
       
   177 	// Note: Help will not work if the application uid3 is not in the
       
   178 	// protected range.  The default uid3 range for projects created
       
   179 	// from this template (0xE0000000 - 0xEFFFFFFF) are not in the protected range so that they
       
   180 	// can be self signed and installed on the device during testing.
       
   181 	// Once you get your official uid3 from Symbian Ltd. and find/replace
       
   182 	// all occurrences of uid3 in your project, the context help will
       
   183 	// work. Alternatively, a patch now exists for the versions of 
       
   184 	// HTML help compiler in SDKs and can be found here along with an FAQ:
       
   185 	// http://www3.symbian.com/faq.nsf/AllByDate/E9DF3257FD565A658025733900805EA2?OpenDocument
       
   186 	CArrayFixFlat<TCoeHelpContext>* array = new (ELeave) CArrayFixFlat<
       
   187 			TCoeHelpContext> (1);
       
   188 	CleanupStack::PushL(array);
       
   189 	array->AppendL(TCoeHelpContext(KUidNPRApp, KGeneral_Information));
       
   190 	CleanupStack::Pop(array);
       
   191 	return array;
       
   192 	}
       
   193 
       
   194 // End of File