# HG changeset patch # User tahirm@symbian.org # Date 1248421562 -3600 # Node ID 0049171ecffb4422d7ddc80c138adce3328e4abc initial release diff -r 000000000000 -r 0049171ecffb .cproject --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.cproject Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,409 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r 0049171ecffb .project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.project Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,19 @@ + + + NPR + + + + + + com.nokia.carbide.cdt.builder.carbideCPPBuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + com.nokia.carbide.cdt.builder.carbideCPPBuilderNature + + diff -r 000000000000 -r 0049171ecffb Releases/Series3thEdition/13_07_09/NPR.SIS Binary file Releases/Series3thEdition/13_07_09/NPR.SIS has changed diff -r 000000000000 -r 0049171ecffb Releases/Series3thEdition/13_07_09/NPR.SISX Binary file Releases/Series3thEdition/13_07_09/NPR.SISX has changed diff -r 000000000000 -r 0049171ecffb Releases/Series3thEdition/14_07_09/NPR.sis Binary file Releases/Series3thEdition/14_07_09/NPR.sis has changed diff -r 000000000000 -r 0049171ecffb Releases/Series3thEdition/14_07_09/npr.sisx Binary file Releases/Series3thEdition/14_07_09/npr.sisx has changed diff -r 000000000000 -r 0049171ecffb Releases/Series3thEdition/15_07_09/NPR__armv5.sis Binary file Releases/Series3thEdition/15_07_09/NPR__armv5.sis has changed diff -r 000000000000 -r 0049171ecffb Releases/Series3thEdition/15_07_09/NPR_armv5.sisx Binary file Releases/Series3thEdition/15_07_09/NPR_armv5.sisx has changed diff -r 000000000000 -r 0049171ecffb Releases/Series5thEdtion/15_07_09/npr.sis Binary file Releases/Series5thEdtion/15_07_09/npr.sis has changed diff -r 000000000000 -r 0049171ecffb Releases/Series5thEdtion/15_07_09/npr.sisx Binary file Releases/Series5thEdtion/15_07_09/npr.sisx has changed diff -r 000000000000 -r 0049171ecffb data/NPR.rls --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/NPR.rls Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,51 @@ +/* + ============================================================================ + Name : NPR.rls + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : This is a localisation file for NPR A .rls file is the one and only place where the logical + strings to be localised are defined. + ============================================================================ + */ + +// LOCALISATION STRINGS + +// Caption string for app. +#define qtn_caption_string "NPR" + +// First item in "Options" menu pane +#define qtn_command1 "Message" + +// Second item in "Options" menu pane +#define qnt_npr_channel "channel" + +#define qtn_help "Help" + +#define qtn_about "About" + +// Third item in "Options" menu pane +#define qtn_exit "Exit" + +// When user requests ECommand1 event, text below is shown. +#define qtn_command1_text "Hello World!" + +#define qtn_loc_resource_file_1 "\\resource\\apps\\NPR_0xEEB0E481" + +#define qtn_about_dialog_title "About" + +#define qtn_about_dialog_text "NPR Version 1.0.0\n\nAuthor: John Kern\n\nSupport: johnk@symbian.org\n\n(c) This component and the accompanying materials are made available under the terms of the License \"Eclipse Public License v1.0\" which accompanies this distribution, and is available at the URL \"http://www.eclipse.org/legal/epl-v10.html\"." + +// End of File diff -r 000000000000 -r 0049171ecffb data/NPR.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/NPR.rss Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,636 @@ +/* + ============================================================================ + Name : NPR.rss + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : This file contains all the resources for the NPR + ============================================================================ + */ + +/* +============================================================================ + Name : NPR.rss + Author : John Kern + Copyright : This component and the accompanying materials are made available under the terms of the License "Eclipse Public License v1.0" which accompanies this distribution, and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". + Description : This file contains all the resources for the NPR. +============================================================================ +*/ +// RESOURCE IDENTIFIER +NAME NPRX // 4 letter ID + + +// INCLUDES +#include +#include +#include +#include +#include "NPR.hrh" +#include "NPR.rls" + +// RESOURCE DEFINITIONS +// ----------------------------------------------------------------------------- +// +// Define the resource file signature +// This resource should be empty. +// +// ----------------------------------------------------------------------------- +// +RESOURCE RSS_SIGNATURE + { + } + +// ----------------------------------------------------------------------------- +// +// Default Document Name +// +// ----------------------------------------------------------------------------- +// +RESOURCE TBUF r_default_document_name + { + buf="NPRX"; + } + +// ----------------------------------------------------------------------------- +// +// Define default menu and CBA key. +// +// ----------------------------------------------------------------------------- +// +RESOURCE EIK_APP_INFO + { + menubar = r_menubar; + cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT; + } + + +// ----------------------------------------------------------------------------- +// +// r_menubar +// Main menubar +// +// ----------------------------------------------------------------------------- +// +RESOURCE MENU_BAR r_menubar + { + titles = + { + MENU_TITLE { menu_pane = r_menu; } + }; + } + + +// ----------------------------------------------------------------------------- +// +// r_menu +// Menu for "Options" +// +// ----------------------------------------------------------------------------- +// +RESOURCE MENU_PANE r_menu + { + items = + { + // added the new Options menu command here + MENU_ITEM + { + command = ERequestNprCmd; + txt = qnt_npr_channel; + }, + MENU_ITEM + { + command = EAbout; + txt = qtn_about; + }, + MENU_ITEM + { + command = EAknSoftkeyExit; + txt = qtn_exit; + } + }; + } + +// ----------------------------------------------------------------------------- +// +// About dialog resource. +// +// ----------------------------------------------------------------------------- +// +RESOURCE DIALOG r_about_query_dialog + { + flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY; + items= + { + DLG_LINE + { + type = EAknCtPopupHeadingPane; + id = EAknMessageQueryHeaderId; + itemflags = EEikDlgItemNonFocusing; + control = AVKON_HEADING + { + }; + }, + DLG_LINE + { + type = EAknCtMessageQuery; + id = EAknMessageQueryContentId; + control = AVKON_MESSAGE_QUERY + { + }; + } + }; + } + + +// ----------------------------------------------------------------------------- +// +// Resources for messages. +// +// ----------------------------------------------------------------------------- +// +RESOURCE TBUF32 r_caption_string { buf=qtn_caption_string; } +RESOURCE TBUF32 r_about_dialog_title { buf=qtn_about_dialog_title; } +RESOURCE TBUF r_about_dialog_text { buf=qtn_about_dialog_text; } +RESOURCE TBUF r_command1_text { buf=qtn_command1_text; } + + +// ---------------------------------------------------------------------------- +// +// r_localisable_app_info +// +// ---------------------------------------------------------------------------- +// +RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info + { + short_caption = qtn_caption_string; + caption_and_icon = + CAPTION_AND_ICON_INFO + { + caption = qtn_caption_string; + + number_of_icons = 1; + icon_file = "\\resource\\apps\\NPR_0xEEB0E481.mif"; + }; + } + + +///////////////////////////////////////////////////////////////////// +//Main view +RESOURCE AVKON_VIEW r_nprlist_box_nprlist_box_view + { + cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT; + menubar = r_nprlist_box_options_menu; + toolbar = 0; + } +RESOURCE MENU_BAR r_nprlist_box_options_menu + { + titles = + { + MENU_TITLE { menu_pane = r_nprlist_box_menu; } + }; + } + +RESOURCE MENU_PANE r_nprlist_box_menu + { + items = + { + // added the new Options menu command here + MENU_ITEM + { + command = ESelect; + txt = "Select"; + } + }; + } + +RESOURCE STATUS_PANE_APP_MODEL r_nprlist_box_status_pane + { + panes = + { + SPANE_PANE + { + id = EEikStatusPaneUidTitle; + type = EAknCtTitlePane; + resource = r_nprlist_box_title_resource; + } + }; + } + +RESOURCE TITLE_PANE r_nprlist_box_title_resource + { + txt = "NPR"; + } + +RESOURCE LISTBOX r_nprlist_box_list_box + { + flags = EAknListBoxSelectionList; + } + +RESOURCE ARRAY r_nprlist_box_listbox_item1 + { + items = + { + LBUF + { + txt = "News"; + } + }; + } + +RESOURCE ARRAY r_nprlist_box_listbox_item2 + { + items = + { + LBUF + { + txt = "Stations"; + } + }; + } + +RESOURCE ARRAY r_nprlist_box_listbox_item3 + { + items = + { + LBUF + { + txt = "Programs"; + } + }; + } + +RESOURCE ARRAY r_nprlist_box_listbox_item4 + { + items = + { + LBUF + { + txt = "Playlists"; + } + }; + } + +RESOURCE ARRAY r_nprlist_box_listbox_item5 + { + items = + { + LBUF + { + txt = "Settings"; + } + }; + } + +///////////////////////////////////////////////////////////////////// +//Story view +RESOURCE AVKON_VIEW r_nprstory_list_box_nprstory_list_box_view + { + cba = R_AVKON_SOFTKEYS_OPTIONS_BACK; + menubar = r_nprstory_list_box_options_menu; + toolbar = 0; + } + +RESOURCE MENU_BAR r_nprstory_list_box_options_menu + { + titles = + { + MENU_TITLE { menu_pane = r_nprstory_list_box_menu; } + }; + } + +RESOURCE MENU_PANE r_nprstory_list_box_menu + { + items = + { + // added the new Options menu command here + MENU_ITEM + { + command = ESelect; + txt = "Select"; + } + }; + } + +RESOURCE STATUS_PANE_APP_MODEL r_nprstory_list_box_status_pane + { + panes = + { + SPANE_PANE + { + id = EEikStatusPaneUidTitle; + type = EAknCtTitlePane; + resource = r_nprstory_list_box_title_resource; + } + }; + } + +RESOURCE TITLE_PANE r_nprstory_list_box_title_resource + { + txt = "News"; + } + +RESOURCE LISTBOX r_nprstory_list_box_list_box + { + flags = EAknListBoxSelectionList; + } + + +///////////////////////////////////////////////////////////////////// +//Stations view +RESOURCE AVKON_VIEW r_nprstation_list_box_nprstation_list_box_view + { + cba = R_AVKON_SOFTKEYS_OPTIONS_BACK; + menubar = r_nprstation_list_box_options_menu; + toolbar = 0; + } + +RESOURCE MENU_BAR r_nprstation_list_box_options_menu + { + titles = + { + MENU_TITLE { menu_pane = r_nprlist_list_box_menu; } + }; + } + +RESOURCE MENU_PANE r_nprlist_list_box_menu + { + items = + { + // added the new Options menu command here + MENU_ITEM + { + command = EListen; + txt = "Listen"; + } + }; + } + +RESOURCE STATUS_PANE_APP_MODEL r_nprstation_list_box_status_pane + { + panes = + { + SPANE_PANE + { + id = EEikStatusPaneUidTitle; + type = EAknCtTitlePane; + resource = r_nprstation_list_box_title_resource; + } + }; + } +RESOURCE TITLE_PANE r_nprstation_list_box_title_resource + { + txt = "STATIONS"; + } + +RESOURCE LISTBOX r_nprstation_list_box_list_box + { + flags = EAknListBoxSelectionList; + } + + +///////////////////////////////////////////////////////////////////// +//Search stations view +RESOURCE AVKON_VIEW r_nprsearch_station_list_box_nprsearch_station_list_box_view + { + cba = R_AVKON_SOFTKEYS_OPTIONS_BACK; + menubar = r_nprsearch_station_list_box_options_menu; + toolbar = 0; + } +RESOURCE MENU_BAR r_nprsearch_station_list_box_options_menu + { + titles = + { + MENU_TITLE { menu_pane = r_nprsearch_station_list_box_menu; } + }; + } + +RESOURCE MENU_PANE r_nprsearch_station_list_box_menu + { + items = + { + // added the new Options menu command here + MENU_ITEM + { + command = ESelect; + txt = "Select"; + } + }; + } + +RESOURCE STATUS_PANE_APP_MODEL r_nprsearch_station_list_box_status_pane + { + panes = + { + SPANE_PANE + { + id = EEikStatusPaneUidTitle; + type = EAknCtTitlePane; + resource = r_nprsearch_station_list_box_title_resource; + } + }; + } +RESOURCE TITLE_PANE r_nprsearch_station_list_box_title_resource + { + txt = "Search station"; + } +RESOURCE LISTBOX r_nprsearch_station_list_box_list_box + { + flags = EAknListBoxSelectionList; + } + +RESOURCE ARRAY r_nprsearch_station_list_box_item1 + { + items = + { + LBUF + { + txt = "Search by ZIP code"; + } + }; + } + +RESOURCE ARRAY r_nprsearch_station_list_box_item2 + { + items = + { + LBUF + { + txt = "Current Location"; + } + }; + } + +RESOURCE ARRAY r_nprsearch_station_list_box_item3 + { + items = + { + LBUF + { + txt = "Search City name"; + } + }; + } + +RESOURCE ARRAY r_nprsearch_station_list_box_item4 + { + items = + { + LBUF + { + txt = "Show All"; + } + }; + } + +///////////////////////////////////////////////////////////////////// +//Query dialog +RESOURCE DIALOG R_ASK_NAME_DIALOG + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items= + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control= AVKON_DATA_QUERY + { + layout = EDataLayout; + control = EDWIN + { + flags= EEikEdwinNoHorizScrolling | EEikEdwinResizable; + maxlength = 5; + width = 4; + lines = 1; + default_input_mode = EAknEditorNumericInputMode; + }; + }; + } + }; + } + +//////////////////////////////////////////////////////////////////////// +//waiting dialog +RESOURCE DIALOG r_singular_wait_note + { + flags = EAknWaitNoteFlags; + buttons = R_AVKON_SOFTKEYS_EMPTY; + items = + { + DLG_LINE + { + type = EAknCtNote; + id = 10; + control = AVKON_NOTE + { + layout = EWaitLayout; + singular_label = ""; + plural_label = ""; + animation = R_QGN_GRAF_WAIT_BAR_ANIM; + }; + } + }; + } + +////////////////////////////////////////////////////////////////////////// +//Browser view +RESOURCE AVKON_VIEW r_akn_browser_view + { + cba = R_AVKON_SOFTKEYS_OPTIONS_BACK; + menubar = r_nprstation_list_box_options_menu; + toolbar = 0; + } + +//////////////////////////////////////////////////////////////// +//Story viewer +RESOURCE AVKON_VIEW r_nprstory_viewer_container_nprstory_viewer_container_view + { + cba = R_AVKON_SOFTKEYS_OPTIONS_BACK; + menubar = r_nprstory_viewer_container_options_menu; + toolbar = 0; + } + +RESOURCE MENU_BAR r_nprstory_viewer_container_options_menu + { + titles = + { + MENU_TITLE { menu_pane = r_nprstory_viewer_container_menu; } + }; + } + +RESOURCE MENU_PANE r_nprstory_viewer_container_menu + { + items = + { + // added the new Options menu command here + MENU_ITEM + { + command = EListen; + txt = "Listen"; + } + }; + } + +RESOURCE STATUS_PANE_APP_MODEL r_nprstory_viewer_container_status_pane + { + panes = + { + SPANE_PANE + { + id = EEikStatusPaneUidTitle; + type = EAknCtTitlePane; + resource = r_nprstory_viewer_container_title_resource; + } + }; + } + +RESOURCE TITLE_PANE r_nprstory_viewer_container_title_resource + { + txt = "News"; + } + +RESOURCE RTXTED r_nprstory_viewer_container_rich_text1 + { + numlines = 2; + default_case = EAknEditorTextCase; + allowed_case_modes = EAknEditorAllCaseModes; + numeric_keymap = EAknEditorStandardNumberModeKeymap; + default_input_mode = EAknEditorTextInputMode; + allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode | EAknEditorSecretAlphaInputMode | EAknEditorKatakanaInputMode | EAknEditorFullWidthTextInputMode | EAknEditorFullWidthNumericInputMode | EAknEditorFullWidthKatakanaInputMode | EAknEditorHiraganaKanjiInputMode | EAknEditorHalfWidthTextInputMode; + } + +RESOURCE TBUF r_nprstory_viewer_container_rich_text1_2 + { + buf = "Title"; + } + +RESOURCE RTXTED r_nprstory_viewer_container_rich_text2 + { + numlines = 0; + default_case = EAknEditorTextCase; + allowed_case_modes = EAknEditorAllCaseModes; + numeric_keymap = EAknEditorStandardNumberModeKeymap; + default_input_mode = EAknEditorTextInputMode; + allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode | EAknEditorSecretAlphaInputMode | EAknEditorKatakanaInputMode | EAknEditorFullWidthTextInputMode | EAknEditorFullWidthNumericInputMode | EAknEditorFullWidthKatakanaInputMode | EAknEditorHiraganaKanjiInputMode | EAknEditorHalfWidthTextInputMode; + } + +RESOURCE TBUF r_nprstory_viewer_container_rich_text2_2 + { + buf = "Body Text"; + } + +// End of File diff -r 000000000000 -r 0049171ecffb data/NPR_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/NPR_reg.rss Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,40 @@ +/* + ============================================================================ + Name : NPR_reg.rss + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : This file contains the application registration resource + ============================================================================ + */ + +#include "NPR.hrh" +#include "NPR.rls" +#include +#include + +UID2 KUidAppRegistrationResourceFile +UID3 _UID3 + +RESOURCE APP_REGISTRATION_INFO + { + app_file="NPR_0xEEB0E481"; + localisable_resource_file = qtn_loc_resource_file_1; + localisable_resource_id = R_LOCALISABLE_APP_INFO; + + embeddability=KAppNotEmbeddable; + newfile=KAppDoesNotSupportNewFile; + } + diff -r 000000000000 -r 0049171ecffb data/npr_news_stream.rm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/npr_news_stream.rm Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,1 @@ +rtsp://real.npr.org:80/real.npr.na-central/news.db.rm \ No newline at end of file diff -r 000000000000 -r 0049171ecffb data/npr_station_stream.rm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/npr_station_stream.rm Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,1 @@ +rtsp://a944.l1651832740.c16518.n.lr.akamaistream.net/live/D/944/16518/v0001/reflector:32740 \ No newline at end of file diff -r 000000000000 -r 0049171ecffb gfx/npr_symbian_generic.bmp Binary file gfx/npr_symbian_generic.bmp has changed diff -r 000000000000 -r 0049171ecffb gfx/npr_symbian_generic_mask.bmp Binary file gfx/npr_symbian_generic_mask.bmp has changed diff -r 000000000000 -r 0049171ecffb gfx/qgn_menu_NPR.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gfx/qgn_menu_NPR.svg Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r 0049171ecffb group/Icons_scalable_dc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/Icons_scalable_dc.mk Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,54 @@ +# ============================================================================ +# Name : Icons_scalable_dc.mk +# Part of : NPR +# +# Description: This is file for creating .mif file (scalable icon) +# +# ============================================================================ + + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\Z +else +ZDIR=$(EPOCROOT)epoc32\data\z +endif + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\NPR_0xEEB0E481.mif + +ICONDIR=..\gfx + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +# NOTE: if you have JUSTINTIME enabled for your S60 3rd FP1 or newer SDK +# and this command crashes, consider adding "/X" to the command line. +# See +# ---------------------------------------------------------------------------- + +RESOURCE : $(ICONTARGETFILENAME) + +$(ICONTARGETFILENAME) : $(ICONDIR)\qgn_menu_NPR.svg + mifconv $(ICONTARGETFILENAME) \ + /c32 $(ICONDIR)\qgn_menu_NPR.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing + diff -r 000000000000 -r 0049171ecffb group/NPR.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/NPR.mmp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,113 @@ +/* + ============================================================================ + Name : NPR.mmp + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : This is the project specification file for NPR + ============================================================================ + */ + +TARGET NPR_0xEEB0E481.exe +TARGETTYPE exe +UID 0x100039CE 0xEEB0E481 + +EPOCHEAPSIZE 0x8000 0xFA000 + +SOURCEPATH ..\src +SOURCE NPR.cpp +SOURCE NPRApplication.cpp +SOURCE NPRAppView.cpp +SOURCE NPRAppUi.cpp +SOURCE NPRDocument.cpp +SOURCE HttpClient.cpp +SOURCE NPRStoryXmlParser.cpp +SOURCE NPRStationXmlParser.cpp +SOURCE NPRAppEngine.cpp +SOURCE NPRStory.cpp +SOURCE NPRStation.cpp +SOURCE NPRListBox.cpp +SOURCE NPRListBoxView.cpp +SOURCE NPRStationListBox.cpp +SOURCE NPRStationListBoxView.cpp +SOURCE NPRSearchStationListBox.cpp +SOURCE NPRSearchStationListBoxView.cpp +SOURCE NPRStoryListBoxView.cpp +SOURCE NPRStoryListBox.cpp +SOURCE NPRBrowserAknView.cpp +SOURCE NPRBrowserContainer.cpp +SOURCE NPRHtmlCreator.cpp + +SOURCEPATH ..\data + +START RESOURCE NPR.rss +HEADER +TARGET NPR_0xEEB0E481 +TARGETPATH resource\apps +END //RESOURCE + +START RESOURCE NPR_reg.rss +TARGET NPR_0xEEB0E481_reg +TARGETPATH \private\10003a3f\apps +END //RESOURCE + +USERINCLUDE ..\inc +USERINCLUDE ..\help ..\data +SYSTEMINCLUDE \epoc32\include + +LIBRARY euser.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY eikcore.lib +LIBRARY avkon.lib +LIBRARY commonengine.lib +LIBRARY efsrv.lib +LIBRARY estor.lib +LIBRARY aknnotify.lib +LIBRARY eikctl.lib +LIBRARY eikcoctl.lib +LIBRARY apgrfx.lib +LIBRARY apmime.lib +LIBRARY commonui.lib +LIBRARY aknicon.lib +LIBRARY egul.lib +LIBRARY hlplch.lib +LIBRARY inetprotutil.lib +LIBRARY http.lib +LIBRARY bafl.lib +LIBRARY esock.lib +LIBRARY xmlframework.lib +LIBRARY etext.lib +LIBRARY BrowserEngine.lib + +LANG SC + +VENDORID 0 +SECUREID 0xEEB0E481 +CAPABILITY NetworkServices ReadUserData WriteDeviceData SwEvent + +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE_UDEBONLY +#endif + +START BITMAP list_icons.mbm +HEADER +TARGETPATH \resource\apps +SOURCEPATH ..\gfx +SOURCE c24,1 npr_symbian_generic.bmp +SOURCE c24,1 npr_symbian_generic_mask.bmp +END + +// End of File diff -r 000000000000 -r 0049171ecffb group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/bld.inf Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,41 @@ +/* + =========================================================================================== + Name : bld.inf + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : This file provides the information required for building the whole of a NPR. + =========================================================================================== + */ + +PRJ_PLATFORMS +WINSCW ARMV5 GCCE + +PRJ_EXPORTS +../testdata/pic1.jpg c:/data/npr/pic1.jpg +../testdata/pic2.jpg c:/data/npr/pic2.jpg +../testdata/pic3.jpg c:/data/npr/pic3.jpg +../testdata/pic4.jpg c:/data/npr/pic4.jpg +../testdata/pic5.jpg c:/data/npr/pic5.jpg +../testdata/pic6.jpg c:/data/npr/pic6.jpg + +PRJ_MMPFILES + +gnumakefile icons_scalable_dc.mk + +gnumakefile ..\help\build_help.mk + +NPR.mmp + diff -r 000000000000 -r 0049171ecffb help/Custom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/help/Custom.xml Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r 0049171ecffb help/NPR.cshlp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/help/NPR.cshlp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,19 @@ + + + + +0xEEB0E481 + + + + + temp\ + + + + NPR.xml + + NPR_0xEEB0E481.hlp + custom.xml + + diff -r 000000000000 -r 0049171ecffb help/NPR.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/help/NPR.xml Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,13 @@ + + + + + +NPRGeneral Information +General Information + +General Information +

Insert your help here.

+

+
+
diff -r 000000000000 -r 0049171ecffb help/NPR_0xEEB0E481.hlp Binary file help/NPR_0xEEB0E481.hlp has changed diff -r 000000000000 -r 0049171ecffb help/NPR_0xEEB0E481.hlp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/help/NPR_0xEEB0E481.hlp.hrh Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,15 @@ +// +// NPR_0xEEB0E481.hlp.hrh +// + +// +// File generated by cshlpcmp Version 011 +// + +#ifndef __NPR_0XEEB0E481_HLP_HRH__ +#define __NPR_0XEEB0E481_HLP_HRH__ + + +_LIT(KGeneral_Information,"General_Information"); + +#endif diff -r 000000000000 -r 0049171ecffb help/build_help.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/help/build_help.mk Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,46 @@ +# ============================================================================ +# Name : build_help.mk +# Part of : NPR +# ============================================================================ +# Name : build_help.mk +# Part of : NPR +# +# Description: This make file will build the application help file (.hlp) +# +# ============================================================================ + +do_nothing : + @rem do_nothing + +# build the help from the MAKMAKE step so the header file generated +# will be found by cpp.exe when calculating the dependency information +# in the mmp makefiles. + +MAKMAKE : NPR_0xEEB0E481.hlp +NPR_0xEEB0E481.hlp : NPR.xml NPR.cshlp Custom.xml + cshlpcmp NPR.cshlp +ifeq (WINSCW,$(findstring WINSCW, $(PLATFORM))) + md $(EPOCROOT)epoc32\$(PLATFORM)\c\resource\help + copy NPR_0xEEB0E481.hlp $(EPOCROOT)epoc32\$(PLATFORM)\c\resource\help +endif + +BLD : do_nothing + +CLEAN : + del NPR_0xEEB0E481.hlp + del NPR_0xEEB0E481.hlp.hrh + +LIB : do_nothing + +CLEANLIB : do_nothing + +RESOURCE : do_nothing + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo NPR_0xEEB0E481.hlp + +FINAL : do_nothing diff -r 000000000000 -r 0049171ecffb help/temp/NPR_0xEEB0E481.cshlp.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/help/temp/NPR_0xEEB0E481.cshlp.xml Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,25 @@ + + + + + + +NPRGeneral Information +General Information + + +

Insert your help here.

+

+ + + +General Information +General Information + + + + + + + + diff -r 000000000000 -r 0049171ecffb inc/HttpClient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/HttpClient.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,87 @@ +/* + ============================================================================ + Name : HttpClient.h + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : This file contains panic codes. + ============================================================================ + */ + +#ifndef __HTTP_CLIENT_H_ +#define __HTTP_CLIENT_H_ + +#include +#include +#include +#include +#include + +#include "NPRStoryXmlParser.h" + +class MHTTPObserver + { + public: + virtual void ResponseStatusL(TInt aStatusCode, const TDesC& aStatusText) = 0; + virtual void ResponseReceivedL(const TDesC8& aResponseBuffer) = 0; + }; + +/* + * This class implements the http request response sequence using RHTTPSession + * class. The IAP selection is not done silently and needs user input. + */ + +class CHttpClient : public CBase, + public MHTTPTransactionCallback, + public MHTTPDataSupplier + { +public: + static CHttpClient* NewL(MHTTPObserver& aObserver); + virtual ~CHttpClient(); + +public: + void SendRequestL(const TDesC& aUri); + + //From MHTTPTransactionCallback + void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent); + TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent &aEvent); + + //From MHTTPDataSupplier + TBool GetNextDataPart(TPtrC8& aDataPart); + void ReleaseData(); + TInt OverallDataSize(); + TInt Reset(); + +private: + void AddHeaderL(RHTTPHeaders aHeaders, TInt aHeaderField, const TDesC8& aHeaderValue); + void AddHeaderL(RHTTPHeaders aHeaders, TInt aHeaderField, const TDesC8& aHeaderValue, TInt aExtensionField, const TDesC8& aExtensionValue); + +private: + CHttpClient(MHTTPObserver& aObserver); + void ConstructL(); + +private: + RHTTPSession iHTTPSession; + MHTTPObserver& iObserver; + RSocketServ iSocketServ; + RConnection iConnection; + RHTTPTransaction iHttpTransaction; + RHTTPConnectionInfo iHttpConnInfo; + HBufC8* iResponseBuffer; // The buffers to hold the request and response bodies. + HBufC8* iUri; + TBool iTransactionActive; + }; + +#endif /* __HTTP_CLIENT_H_ */ diff -r 000000000000 -r 0049171ecffb inc/NPR.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPR.hrh Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,81 @@ +/* + ============================================================================ + Name : NPR.hrh + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description: + ============================================================================ + */ + +#ifndef __NPR_HRH__ +#define __NPR_HRH__ + +#define _UID3 0xEEB0E481 + +// NPR enumerate AppUi commands code +enum TNPRAppUiIds + { + EPlayCmd = 0x6001, // start value must not be 0 + EPauseCmd, + ERequestNprCmd, + EListen, + ESelect, + EShare, + EHelp, + EAbout, + ELoadPage + }; + +// NPR enumerate command codes +enum TNPRCommands + { + ENewsCmd = 0x0, + EStationsCmd, + EPlayStationStream, + EPlayNewsStream, + EPlaylist, + ESettings + }; + +// NPR enumerate topic codes +enum TNPRTopics + { + ENews = 0x0, + EStations, + EPrograms + }; + +// NPR enumerate search codes +enum TNPRStationSearch + { + EZipCode = 0x0, + ECurrentLocation, + ECityName, + EShowAll + }; + +// NPR enumerate aknview uid +enum TNPRViewUids + { + ENPRListBoxViewId = 0x1, + ENPRStationListBoxViewId, + ENPRSearchStationListBoxViewId, + ENPRStoryListBoxViewId, + ENPRBrowserViewId, + ENPRStoryViewerContainerViewId + }; + +#endif // __NPR_HRH__ diff -r 000000000000 -r 0049171ecffb inc/NPR.pan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPR.pan Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,36 @@ +/* + ============================================================================ + Name : NPR.pan + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + Symbian Foundation Ltd - initial contribution. + + Contributors: John Kern + Description : This file contains panic codes. + ============================================================================ + */ + +#ifndef __NPR_PAN__ +#define __NPR_PAN__ + +/** NPR application panic codes */ +enum TNPRPanics + { + ENPRUi = 1 + // add further panics here + }; + +inline void Panic(TNPRPanics aReason) + { + _LIT(applicationName, "NPR"); + User::Panic(applicationName, aReason); + } + +#endif // __NPR_PAN__ diff -r 000000000000 -r 0049171ecffb inc/NPRAppEngine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRAppEngine.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,75 @@ +/* + ============================================================================ + Name : NPRAppEngine.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description: + ============================================================================ + */ + +#ifndef __NPR_APP_ENGINE_H__ +#define __NPR_APP_ENGINE_H__ + +#include +#include "HttpClient.h" +#include "NPR.hrh" + +class CAknWaitDialog; +class CDocumentHandler; +class CNPRAppUi; +class CNPRStation; +class CNPRStories; + + +class CNPRAppEngine : public CBase, public MHTTPObserver + { +public: + static CNPRAppEngine* NewL(CNPRAppUi& aNPRAppUi); + virtual ~CNPRAppEngine(); + +public: + void SendNPRCommandL(const TNPRCommands aCommand, const TDesC& aField); + const RPointerArray* Stations(); + const RPointerArray* Stories(); + +public: + //From MHTTPObserver + void ResponseStatusL(TInt aStatusCode, const TDesC& aStatusText); + void ResponseReceivedL(const TDesC8& aResponseBuffer) ; + +private: + void SearchStationsL(const TDesC& aField); + void SearchNewsL(const TDesC& aField); + void LaunchFileL(const TDesC& aFilename); + void RefreshDocumentFileL(const TUid& aUid, const TDesC& aFileName); + void ShowWaitingDialogL(const TDesC& aText); + void DismissWaitingDialogL(); + +private: + CNPRAppEngine(CNPRAppUi& aNPRAppUi); + void ConstructL(); + +private: + CNPRAppUi& iNPRAppUi; + CHttpClient* iHttp; + TNPRCommands iNPRCommand; + CDocumentHandler* iDocHandler; + RPointerArray iStationArray; + RPointerArray iStoryArray; + CAknWaitDialog* iWaitDialog; + }; + +#endif // __NPR_APP_ENGINE_H__ + diff -r 000000000000 -r 0049171ecffb inc/NPRAppUi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRAppUi.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,116 @@ +/* + ============================================================================ + Name : NPRAppUi.h + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + - Symsource + + Contributors: + - John Kern + - Symsource + + Description : Declares UI class for application. + ============================================================================ + */ + +/* + ============================================================================ + Name : NPRAppUi.h + Author : John Kern + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + Symbian Foundation Ltd - initial contribution. + + Contributors: John Kern + Description : Declares UI class for application. + ============================================================================ + */ + +#ifndef __NPR_APP_UI_h__ +#define __NPR_APP_UI_h__ + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CNPRAppView; +class CNPRAppEngine; + +// CLASS DECLARATION +/** + * CNPRAppUi application UI class. + * Interacts with the user through the UI and request message processing + * from the handler class + */ +class CNPRAppUi : public CAknViewAppUi + { +public: + // Constructors and destructor + + /** + * ConstructL. + * 2nd phase constructor. + */ + void ConstructL(); + + /** + * CNPRAppUi. + * C++ default constructor. This needs to be public due to + * the way the framework constructs the AppUi + */ + CNPRAppUi(); + + /** + * ~CNPRAppUi. + * Virtual Destructor. + */ + virtual ~CNPRAppUi(); + + CNPRAppEngine& Engine(); + void ResponseStatusL(TInt aStatusCode, const TDesC& aStatusText); + void ResponseReceivedL(const TDesC8& aResponseBuffer) ; + +private: + // Functions from base classes + + /** + * From CEikAppUi, HandleCommandL. + * Takes care of command handling. + * @param aCommand Command to be handled. + */ + void HandleCommandL(TInt aCommand); + + /** + * HandleStatusPaneSizeChange. + * Called by the framework when the application status pane + * size is changed. + */ + void HandleStatusPaneSizeChange(); + + /** + * From CCoeAppUi, HelpContextL. + * Provides help context for the application. + * size is changed. + */ + CArrayFix* HelpContextL() const; + +private: + // Data + CNPRAppEngine* iNPRAppEngine; + }; + +#endif // __NPR_APP_UI_h__ +// End of File diff -r 000000000000 -r 0049171ecffb inc/NPRAppView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRAppView.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,102 @@ +/* + ============================================================================ + Name : NPRAppView.h + Author : John Kern + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + Symbian Foundation Ltd - initial contribution. + + Contributors: John Kern + Description : Declares view class for application. + ============================================================================ + */ + +#ifndef __NPRAPPVIEW_h__ +#define __NPRAPPVIEW_h__ + +// INCLUDES +#include + +// CLASS DECLARATION +class CNPRAppView : public CCoeControl + { +public: + // New methods + + /** + * NewL. + * Two-phased constructor. + * Create a CNPRAppView object, which will draw itself to aRect. + * @param aRect The rectangle this view will be drawn to. + * @return a pointer to the created instance of CNPRAppView. + */ + static CNPRAppView* NewL(const TRect& aRect); + + /** + * NewLC. + * Two-phased constructor. + * Create a CNPRAppView object, which will draw itself + * to aRect. + * @param aRect Rectangle this view will be drawn to. + * @return A pointer to the created instance of CNPRAppView. + */ + static CNPRAppView* NewLC(const TRect& aRect); + + /** + * ~CNPRAppView + * Virtual Destructor. + */ + virtual ~CNPRAppView(); + +public: + // Functions from base classes + + /** + * From CCoeControl, Draw + * Draw this CNPRAppView to the screen. + * @param aRect the rectangle of this view that needs updating + */ + void Draw(const TRect& aRect) const; + + /** + * From CoeControl, SizeChanged. + * Called by framework when the view size is changed. + */ + virtual void SizeChanged(); + + /** + * From CoeControl, HandlePointerEventL. + * Called by framework when a pointer touch event occurs. + * Note: although this method is compatible with earlier SDKs, + * it will not be called in SDKs without Touch support. + * @param aPointerEvent the information about this event + */ + virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); + +private: + // Constructors + + /** + * ConstructL + * 2nd phase constructor. + * Perform the second phase construction of a + * CNPRAppView object. + * @param aRect The rectangle this view will be drawn to. + */ + void ConstructL(const TRect& aRect); + + /** + * CNPRAppView. + * C++ default constructor. + */ + CNPRAppView(); + + }; + +#endif // __NPRAPPVIEW_h__ +// End of File diff -r 000000000000 -r 0049171ecffb inc/NPRApplication.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRApplication.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,69 @@ +/* + ============================================================================ + Name : NPRApplication.h + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + + Description : Declares main application class. + ============================================================================ + */ + + +#ifndef __NPR_APPLICATION_H__ +#define __NPR_APPLICATION_H__ + +// INCLUDES +#include +#include "NPR.hrh" + +// UID for the application; +// this should correspond to the uid defined in the mmp file +const TUid KUidNPRApp = + { + _UID3 + }; + +// CLASS DECLARATION + +/** + * CNPRApplication application class. + * Provides factory to create concrete document object. + * An instance of CNPRApplication is the application part of the + * AVKON application framework for the NPR example application. + */ +class CNPRApplication : public CAknApplication + { +public: + // Functions from base classes + + /** + * From CApaApplication, AppDllUid. + * @return Application's UID (KUidNPRApp). + */ + TUid AppDllUid() const; + +protected: + // Functions from base classes + + /** + * From CApaApplication, CreateDocumentL. + * Creates CNPRDocument document object. The returned + * pointer in not owned by the CNPRApplication object. + * @return A pointer to the created document object. + */ + CApaDocument* CreateDocumentL(); + }; + +#endif // __NPR_APPLICATION_H__ +// End of File diff -r 000000000000 -r 0049171ecffb inc/NPRBrowserAknView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRBrowserAknView.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,55 @@ +/* + =============================================================================== + Name : NPRBrowserAknView.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : AknView for containing Nokia browser control to show NPR's Story + ================================================================================ + */ + +#ifndef __NPR_BROWSER_AKN_VIEW_H__ +#define __NPR_BROWSER_AKN_VIEW_H__ + +#include + +class CBrowserContainer; +class CNPRAppEngine; + +class CBrowserAknView : public CAknView + { +public: + static CBrowserAknView* NewL(CNPRAppEngine& aEngine); + virtual ~CBrowserAknView(); + +public: + TUid Id() const; + void HandleCommandL(TInt aCommand); + +protected: + void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage); + void DoDeactivate(); + void HandleStatusPaneSizeChange(); + +private: + CBrowserAknView(CNPRAppEngine& aEngine); + void ConstructL(); + +private: + CBrowserContainer* iContainer; + CNPRAppEngine& iEngine; + }; + +#endif // __NPR_BROWSER_AKN_VIEW_H__ + diff -r 000000000000 -r 0049171ecffb inc/NPRBrowserContainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRBrowserContainer.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,65 @@ +/* + =============================================================================== + Name : NPRBrowserConatiner.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Container for Nokia browser control to show NPR's Story + ================================================================================ + */ + +#ifndef __NPR_BROWSER_H__ +#define __NPR_BROWSER_H__ + +#include +#include "BrCtlInterface.h" + +class CBrowserContainer : public CCoeControl, + public MCoeControlObserver, + public MBrCtlLoadEventObserver, + public MEikCommandObserver + { +public: + void ConstructL(const TRect& aRect); + ~CBrowserContainer(); + +public: + inline CBrCtlInterface* Browser() const {return iBrowser;} + void ProcessCommandL(TInt aCommandId); + void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); + TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); + + //From MBrCtlLoadEventObserver + void HandleBrowserLoadEventL(TBrCtlDefs::TBrCtlLoadEvent aLoadEvent, TUint aSize, TUint16 aTransactionId); + void Listen(); + +private: + void SizeChanged(); + TInt CountComponentControls() const; + CCoeControl* ComponentControl(TInt aIndex) const; + void Draw(const TRect& aRect) const; + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); + void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); + void HandleResourceChange(TInt aType); + +private: + CBrCtlInterface* iBrowser; + TUint iBrowserCaps; + TInt iCommandBase; + }; + +#endif // __NPR_BROWSER_H__ + + + diff -r 000000000000 -r 0049171ecffb inc/NPRDocument.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRDocument.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,106 @@ +/* + ============================================================================ + Name : NPRDocument.h + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : Declares document class for application. + ============================================================================ + */ + + +#ifndef __NPR_DOCUMENT_H__ +#define __NPR_DOCUMENT_H__ + +// INCLUDES +#include + +#include "NPRStory.h" + +// FORWARD DECLARATIONS +class CNPRAppUi; +class CEikApplication; + +// CLASS DECLARATION + +/** + * CNPRDocument application class. + * An instance of class CNPRDocument is the Document part of the + * AVKON application framework for the NPR example application. + */ +class CNPRDocument : public CAknDocument + { +public: + // Constructors and destructor + + /** + * NewL. + * Two-phased constructor. + * Construct a CNPRDocument for the AVKON application aApp + * using two phase construction, and return a pointer + * to the created object. + * @param aApp Application creating this document. + * @return A pointer to the created instance of CNPRDocument. + */ + static CNPRDocument* NewL(CEikApplication& aApp); + + /** + * NewLC. + * Two-phased constructor. + * Construct a CNPRDocument for the AVKON application aApp + * using two phase construction, and return a pointer + * to the created object. + * @param aApp Application creating this document. + * @return A pointer to the created instance of CNPRDocument. + */ + static CNPRDocument* NewLC(CEikApplication& aApp); + + /** + * ~CNPRDocument + * Virtual Destructor. + */ + virtual ~CNPRDocument(); + +public: + // Functions from base classes + + /** + * CreateAppUiL + * From CEikDocument, CreateAppUiL. + * Create a CNPRAppUi object and return a pointer to it. + * The object returned is owned by the Uikon framework. + * @return Pointer to created instance of AppUi. + */ + CEikAppUi* CreateAppUiL(); + +private: + // Constructors + + /** + * ConstructL + * 2nd phase constructor. + */ + void ConstructL(); + + /** + * CNPRDocument. + * C++ default constructor. + * @param aApp Application creating this document. + */ + CNPRDocument(CEikApplication& aApp); + }; + +#endif // __NPR_DOCUMENT_H__ +// End of File diff -r 000000000000 -r 0049171ecffb inc/NPRHtmlCreator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRHtmlCreator.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,73 @@ +/* + ============================================================================ + Name : NPRHtmlCreator.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - Symsource + + Description : HTML composer + ============================================================================ + */ + +#ifndef _NPR_HTML_CREATOR_H +#define _NPR_HTML_CREATOR_H + +// INCLUDES +#include +#include +#include + +// CLASS DECLARATION +class CNPRStory; + +/** + * CNPRHtmlCreator + * + */ +class CNPRHtmlCreator : public CBase + { +public: + /** + * Two-phased constructor. + */ + static CNPRHtmlCreator* NewL(); + + /** + * Two-phased constructor. + */ + static CNPRHtmlCreator* NewLC(); + + /** + * Destructor. + */ + ~CNPRHtmlCreator(); + +public: + /** + * Create the HTML file in the c:/data/npr directory + */ + void CreateHtmlFileL(CNPRStory* aStory); + +private: + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(); + +private: + //Member variables + RFs iFs; + static TInt iCurrentImage; + }; + +#endif // _NPR_HTML_CREATOR_H diff -r 000000000000 -r 0049171ecffb inc/NPRListBox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRListBox.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,94 @@ +/* + =============================================================================================== + Name : NPRListBox.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Container for Series60 single large style list box to show the NPR's main options + =============================================================================================== + */ + +#ifndef NPR_LIST_BOX_H +#define NPR_LIST_BOX_H + +#include +#include +#include + +class MEikCommandObserver; +class CAknSingleLargeStyleListBox; +class CEikTextListBox; + + +class CNPRListBox : public CCoeControl + { +public: + enum TControls + { + EListBox, + ELastControl + }; + enum TListBoxImages + { + EListBoxNpr_0xeeb0e481Qgn_menu_nprIndex = 0, + EListBoxFirstUserImageIndex + }; +public: + static CNPRListBox* NewL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver ); + static CNPRListBox* NewLC(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver ); + virtual ~CNPRListBox(); + +public: + void SendNewsQueryL(); + // from base class CCoeControl + TInt CountComponentControls() const; + CCoeControl* ComponentControl(TInt aIndex) const; + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); + void HandleResourceChange(TInt aType); + +protected: + // from base class CCoeControl + void SizeChanged(); + +public: + TInt CurrentItemIndex(); + static void AddListBoxItemL(CEikTextListBox* aListBox, const TDesC& aString); + static RArray< TInt >* GetSelectedListBoxItemsLC(CEikTextListBox* aListBox); + static void DeleteSelectedListBoxItemsL(CEikTextListBox* aListBox); + CAknSingleLargeStyleListBox* ListBox(); + static void CreateListBoxItemL(TDes& aBuffer, TInt aIconIndex, const TDesC& aMainText); + void AddListBoxResourceArrayItemL(TInt aResourceId, TInt aIconIndex); + void SetupListBoxIconsL(); + static CGulIcon* LoadAndScaleIconL(const TDesC& aFileName, TInt aBitmapId, TInt aMaskId, TSize* aSize, TScaleMode aScaleMode ); + TBool HandleMarkableListCommandL( TInt aCommand ); + +private: + void InitializeControlsL(); + void LayoutControls(); + + // from base class CCoeControl + void Draw(const TRect& aRect) const; + +private: + // constructors + CNPRListBox(); + void ConstructL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver); + +private: + CCoeControl* iFocusControl; + MEikCommandObserver* iCommandObserver; + CAknSingleLargeStyleListBox* iListBox; + }; + +#endif // NPR_LIST_BOX_H diff -r 000000000000 -r 0049171ecffb inc/NPRListBoxView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRListBoxView.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,67 @@ +/* + ============================================================================ + Name : NPRListBoxView.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : AknView for wrapping the container to show the NPR's main options + ============================================================================ + */ + +#ifndef __NPR_LIST_BOX_VIEW_H__ +#define __NPR_LIST_BOX_VIEW_H__ + +#include + +class CNPRListBox; +class CNPRAppEngine; + +/** + * Avkon view class for NPRListBoxView. It is register with the view server + * by the AppUi. It owns the container control. + * @class CNPRListBoxView NPRListBoxView.h + */ + +class CNPRListBoxView : public CAknView + { + +public: + static CNPRListBoxView* NewL(); + static CNPRListBoxView* NewLC(); + virtual ~CNPRListBoxView(); + +public: + // from base class CAknView + TUid Id() const; + void HandleCommandL( TInt aCommand ); + + CNPRListBox* CreateContainerL(); +protected: + // from base class CAknView + void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage); + void DoDeactivate(); + void HandleStatusPaneSizeChange(); + +private: + CNPRListBoxView(); + void ConstructL(); + +private: + void SetupStatusPaneL(); + void CleanupStatusPane(); +private: + CNPRListBox* iNPRListBox; + }; + +#endif // __NPR_LIST_BOX_VIEW_H__ diff -r 000000000000 -r 0049171ecffb inc/NPRSearchStationListBox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRSearchStationListBox.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,99 @@ +/* + =================================================================================================== + Name : NPRSearchStationListBox.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Container for Series60 single style list box to show the NPR's station search options + =================================================================================================== + */ + +#ifndef __NPR_SEARCH_STATION_LISTBOX_H__ +#define __NPR_SEARCH_STATION_LISTBOX_H__ + +#include +class MEikCommandObserver; +class CAknSingleLargeStyleListBox; +class CEikTextListBox; + +_LIT(KNPRZipQuery, "zip=%S"); +_LIT(KNPRCurrentLocationZip, "94102");//San Francisco ZIP codes + + +/** + * Container class for NPRSearchStationListBox + * + * @class CNPRSearchStationListBox NPRSearchStationListBox.h + */ +class CNPRSearchStationListBox : public CCoeControl + { +public: + enum TControls + { + EListBox, + ELastControl + }; + + enum TListBoxImages + { + EListBoxFirstUserImageIndex + }; +public: + static CNPRSearchStationListBox* NewL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver); + static CNPRSearchStationListBox* NewLC(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver); + virtual ~CNPRSearchStationListBox(); + +public: + TInt CurrentItemIndex(); + void SendStationQueryL(); + + // from base class CCoeControl + TInt CountComponentControls() const; + CCoeControl* ComponentControl(TInt aIndex) const; + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); + void HandleResourceChange(TInt aType); + + static void AddListBoxItemL(CEikTextListBox* aListBox, const TDesC& aString); + static RArray< TInt >* GetSelectedListBoxItemsLC(CEikTextListBox* aListBox); + static void DeleteSelectedListBoxItemsL(CEikTextListBox* aListBox); + CAknSingleStyleListBox* ListBox(); + static void CreateListBoxItemL(TDes& aBuffer, TInt aIconIndex, const TDesC& aMainText); + void AddListBoxResourceArrayItemL(TInt aResourceId, TInt aIconIndex); + void SetupListBoxIconsL(); + TBool HandleMarkableListCommandL(TInt aCommand); + +protected: + // from base class CCoeControl + void SizeChanged(); + +private: + // from base class CCoeControl + void Draw(const TRect& aRect) const; + +private: + void InitializeControlsL(); + void LayoutControls(); + +private: + // constructors + CNPRSearchStationListBox(); + void ConstructL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver); + +private: + CAknSingleStyleListBox* iListBox; + CCoeControl* iFocusControl; + MEikCommandObserver* iCommandObserver; + }; + +#endif // __NPR_SEARCH_STATION_LISTBOX_H__ diff -r 000000000000 -r 0049171ecffb inc/NPRSearchStationListBoxView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRSearchStationListBoxView.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,66 @@ +/* + =================================================================================================== + Name : NPRSearchStationListBoxView.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : AknView for wrapping the container to show the NPR's station search options + =================================================================================================== + */ + +#ifndef __NPR_SEARCH_STATION_LIST_BOX_VIEW_H__ +#define __NPR_SEARCH_STATION_LIST_BOX_VIEW_H__ + +#include +class CNPRSearchStationListBox; + +/** + * Avkon view class for NPRSearchStationListBoxView. It is register with the view server + * by the AppUi. It owns the container control. + * @class CNPRSearchStationListBoxView NPRSearchStationListBoxView.h + */ + +class CNPRSearchStationListBoxView : public CAknView + { +public: + static CNPRSearchStationListBoxView* NewL(); + static CNPRSearchStationListBoxView* NewLC(); + virtual ~CNPRSearchStationListBoxView(); + +public: + // from base class CAknView + TUid Id() const; + void HandleCommandL( TInt aCommand ); + CNPRSearchStationListBox* CreateContainerL(); + +protected: + // from base class CAknView + void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage); + void DoDeactivate(); + void HandleStatusPaneSizeChange(); + +private: + void SetupStatusPaneL(); + void CleanupStatusPane(); + +private: + // constructors + CNPRSearchStationListBoxView(); + void ConstructL(); + +private: + CNPRSearchStationListBox* iNPRSearchStationListBox; + }; + +#endif // __NPR_SEARCH_STATION_LIST_BOX_VIEW_H__ diff -r 000000000000 -r 0049171ecffb inc/NPRStation.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRStation.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,80 @@ +/* + ============================================================================ + Name : NPRStation.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Class to wrap all the Station fields + ============================================================================ + */ + +#ifndef __NPR_STATION_H__ +#define __NPR_STATION_H__ + +// INCLUDES +#include +#include + + +// CLASS DECLARATION + +/** + * CNPRStation + * + */ +class CNPRStation : public CBase + { +public: + /** + * Two-phased constructor. + */ + static CNPRStation* NewL(); + + /** + * Two-phased constructor. + */ + static CNPRStation* NewLC(); + + /** + * Destructor. + */ + ~CNPRStation(); + +public: + inline void SetStationId(TInt aId) {iStationId = aId;}; + inline TInt StationId() {return iStationId;}; + + void SetNameL(const TDesC8& aName); + inline const TDesC& Name() {return iName;}; + + void SetFrequencyL(const TDesC8& aFrequency); + inline const TDesC& Frequency() {return iFrequency;}; + + void SetMarketCityL(const TDesC8& aMarketCity); + inline const TDesC& MarketCity() {return iMarketCity;}; + +private: + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(); + +private: + TInt iStationId; + RBuf iName; + RBuf iFrequency; + RBuf iMarketCity; + }; + +#endif // __NPR_STATION_H__ diff -r 000000000000 -r 0049171ecffb inc/NPRStationListBox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRStationListBox.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,92 @@ +/* + ============================================================================ + Name : NPRStationListBox.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Container for Series60 double style list box to show the NPR's station list + ============================================================================ + */ + +#ifndef __NPR_STATION_LIST_BOX_H__ +#define __NPR_STATION_LIST_BOX_H__ + +#include + +class MEikCommandObserver; +class CAknDoubleStyle2ListBox; +class CEikTextListBox; +class CNPRStation; + +/** + * Container class for NPRStationListBox + * + * @class CNPRStationListBox NPRStationListBox.h + */ +class CNPRStationListBox : public CCoeControl + { +public: + enum TControls + { + EListBox, + ELastControl + }; + enum TListBoxImages + { + EListBoxFirstUserImageIndex + }; +public: + static CNPRStationListBox* NewL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver); + static CNPRStationListBox* NewLC(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver); + virtual ~CNPRStationListBox(); + +public: + void Listen(); + // from base class CCoeControl + TInt CountComponentControls() const; + CCoeControl* ComponentControl(TInt aIndex) const; + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); + void HandleResourceChange(TInt aType); + static void AddListBoxItemL(CEikTextListBox* aListBox, const TDesC& aString); + static RArray< TInt >* GetSelectedListBoxItemsLC( CEikTextListBox* aListBox); + static void DeleteSelectedListBoxItemsL(CEikTextListBox* aListBox); + CAknDoubleStyle2ListBox* ListBox(); + static void CreateListBoxItemL(TDes& aBuffer, const TDesC& aMainText, const TDesC& aSecondaryText); + void AddListBoxResourceArrayItemL(TInt aResourceId); + void SetupListBoxIconsL(); + TBool HandleMarkableListCommandL(TInt aCommand); + +protected: + // from base class CCoeControl + void SizeChanged(); + +private: + void InitializeControlsL(); + void LayoutControls(); + // from base class CCoeControl + void Draw( const TRect& aRect ) const; + +private: + // constructors + CNPRStationListBox(); + void ConstructL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver); + +private: + CAknDoubleStyle2ListBox* iListBox; + const RPointerArray* iStationArray; + CCoeControl* iFocusControl; + MEikCommandObserver* iCommandObserver; + }; + +#endif // __NPR_STATION_LIST_BOX_H__ diff -r 000000000000 -r 0049171ecffb inc/NPRStationListBoxView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRStationListBoxView.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,66 @@ +/* + ========================================================================================== + Name : NPRStationListBoxView.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : AknView for wrapping the container to show the NPR's station list + ========================================================================================== + */ + +#ifndef __NPR_STATION_LIST_BOX_VIEW_H__ +#define __NPR_STATION_LIST_BOX_VIEW_H__ + +#include +class CNPRStationListBox; + +/** + * Avkon view class for NPRStationListBoxView. It is register with the view server + * by the AppUi. It owns the container control. + * @class CNPRStationListBoxView NPRStationListBoxView.h + */ + +class CNPRStationListBoxView : public CAknView + { +public: + static CNPRStationListBoxView* NewL(); + static CNPRStationListBoxView* NewLC(); + virtual ~CNPRStationListBoxView(); + +public: + // from base class CAknView + TUid Id() const; + void HandleCommandL( TInt aCommand ); + CNPRStationListBox* CreateContainerL(); + +protected: + // from base class CAknView + void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage); + void DoDeactivate(); + void HandleStatusPaneSizeChange(); + +private: + void SetupStatusPaneL(); + void CleanupStatusPane(); + +private: + // constructors + CNPRStationListBoxView(); + void ConstructL(); + +private: + CNPRStationListBox* iNPRStationListBox; + }; + +#endif // __NPR_STATION_LIST_BOX_VIEW_H__ diff -r 000000000000 -r 0049171ecffb inc/NPRStationXmlParser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRStationXmlParser.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,86 @@ +/* + ============================================================================ + Name : NPRStationXmlParser.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Station xml parser + ============================================================================ + */ + +#ifndef __NPR_STATION_XML_PARSER_H__ +#define __NPR_STATION_XML_PARSER_H__ + +// INCLUDES +#include + +#include "NPRStation.h" + +using namespace Xml; +// CLASS DECLARATION + +/** + * CNPRStationXmlParser + * The SAX parser will use this handler and associated enums to create story objects. + */ + +// used by SAX parser. States of the XML response from NPR server. +enum TNPRStationParserState + { + ENPRStationStateIdle = 0, + ENPRStationStateStation, + ENPRStationStateStationEnd, + ENPRStationStateName, + ENPRStationStateNameEnd, + ENPRStationStateFrequency, + ENPRStationStateFrequencyEnd, + ENPRStationStateMarketCity, + ENPRStationStateMarketCityEnd + }; + +class CNPRStationXmlParser : public CBase, public MContentHandler + { +public: + static CNPRStationXmlParser* NewL(RPointerArray* aStationArray); + static CNPRStationXmlParser* NewLC(RPointerArray* aStationArray); + ~CNPRStationXmlParser(); + +public: + void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); + void OnEndDocumentL(TInt aErrorCode); + void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode); + void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); + void OnContentL(const TDesC8& aBytes, TInt aErrorCode); + void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode); + void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); + void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); + void OnSkippedEntityL(const RString& aName, TInt aErrorCode); + void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode); + void OnError(TInt aErrorCode); + TAny* GetExtendedInterface(const TInt32 aUid); + +private: + HBufC* Copy8To16LC(const TDesC8& aDes); + +private: + CNPRStationXmlParser(RPointerArray* aStationArray); + void ConstructL(); + +private: + CNPRStation *iCurrentStation; + TNPRStationParserState iState; + RPointerArray* iStationArray; //it doesn't take ownership, do not delete + }; + +#endif // __NPR_STATION_XML_PARSER_H__ diff -r 000000000000 -r 0049171ecffb inc/NPRStory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRStory.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,73 @@ +/* + ============================================================================ + Name : NPRStory.h + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : NPR's xml story parser + ============================================================================ + */ + +#ifndef __NPR_STORY_H__ +#define __NPR_STORY_H__ + +// INCLUDES +#include + +/** + * CNPRStory + * + */ +class CNPRStory : public CBase + { +public: + static CNPRStory* NewL(); + static CNPRStory* NewLC(); + ~CNPRStory(); + +public: + void SetStoryId(TInt aStoryId) {iStoryId = aStoryId;} + inline TInt StoryId() {return iStoryId;} + + void SetTitleL(const TDesC8& aTitle); + inline const TDesC& Title() {return iTitle;}; + + void SetTeaserL(const TDesC8& aTeaser); + inline const TDesC& Teaser() {return iTeaser;}; + + void SetTextL(const TDesC8& aText); + inline const TDesC& Text() {return iText;}; + + void SetMp3UrlL(const TDesC8& aMp3Url); + inline const TDesC& Mp3Url() {return iMp3Url;}; + + void SetThumbnailUrlL(const TDesC8& aThumbUrl); + inline const TDesC& ThumbnailUrl() {return iThumbnailUrl;}; + +private: + //Constructors + CNPRStory(); + void ConstructL(); + +private: + TInt iStoryId; + RBuf iTitle; + RBuf iTeaser; + RBuf iText; + RBuf iMp3Url; + RBuf iThumbnailUrl; + }; + +#endif // __NPR_STORY_H__ diff -r 000000000000 -r 0049171ecffb inc/NPRStoryListBox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRStoryListBox.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,100 @@ +/* + ============================================================================ + Name : NPRStoryListBox.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Container for Series60 double style list box to show the NPR's story list + ============================================================================ + */ + +#ifndef __NPR_STORY_LIST_BOX_H__ +#define __NPR_STORY_LIST_BOX_H__ + +#include +#include + + +class MEikCommandObserver; +class CAknDoubleLargeStyleListBox; +class CEikTextListBox; +class CNPRStory; +class CNPRHtmlCreator; + +/** + * Container class for NPRStoryListBox + * + * @class CNPRStoryListBox NPRStoryListBox.h + */ +class CNPRStoryListBox : public CCoeControl + { +public: + enum TControls + { + EListBox, + ELastControl + }; + enum TListBoxImages + { + EListBoxFirstUserImageIndex + }; + +public: + static CNPRStoryListBox* NewL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver); + static CNPRStoryListBox* NewLC(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver); + virtual ~CNPRStoryListBox(); + +public: + void ShowSelectedStoryL(); + // from base class CCoeControl + TInt CountComponentControls() const; + CCoeControl* ComponentControl(TInt aIndex) const; + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); + void HandleResourceChange(TInt aType); + static void AddListBoxItemL(CEikTextListBox* aListBox, const TDesC& aString); + static RArray< TInt >* GetSelectedListBoxItemsLC(CEikTextListBox* aListBox); + static void DeleteSelectedListBoxItemsL(CEikTextListBox* aListBox); + CAknDoubleLargeStyleListBox* ListBox(); + static void CreateListBoxItemL(TDes& aBuffer, TInt aIconIndex, const TDesC& aMainText, const TDesC& aSecondaryText); + void AddListBoxResourceArrayItemL(TInt aResourceId, TInt aIconIndex); + void SetupListBoxIconsL(); + TBool HandleMarkableListCommandL(TInt aCommand); + static CGulIcon* LoadAndScaleIconL(const TDesC& aFileName, TInt aBitmapId, TInt aMaskId, TSize* aSize, TScaleMode aScaleMode); + +protected: + // from base class CCoeControl + void SizeChanged(); + +private: + TInt CurrentItemIndex(); + void InitializeControlsL(); + void LayoutControls(); + + // from base class CCoeControl + void Draw( const TRect& aRect ) const; + +private: + // constructors + CNPRStoryListBox(); + void ConstructL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver); + +private: + CCoeControl* iFocusControl; + MEikCommandObserver* iCommandObserver; + CAknDoubleLargeStyleListBox* iListBox; + const RPointerArray* iStoryArray; + CNPRHtmlCreator* iHtmlCreator; + }; + +#endif // __NPR_STORY_LIST_BOX_H__ diff -r 000000000000 -r 0049171ecffb inc/NPRStoryListBoxView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRStoryListBoxView.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,66 @@ +/* + ========================================================================================== + Name : NPRStoryListBoxView.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : AknView for wrapping the container to show the NPR's story list + ========================================================================================== + */ + +#ifndef __NPR_STORY_LIST_BOX_VIEW_H__ +#define __NPR_STORY_LIST_BOX_VIEW_H__ + +#include + +class CNPRStoryListBox; + +/** + * Avkon view class for NPRStoryListBoxView. It is register with the view server + * by the AppUi. It owns the container control. + * @class CNPRStoryListBoxView NPRStoryListBoxView.h + */ +class CNPRStoryListBoxView : public CAknView + { +public: + static CNPRStoryListBoxView* NewL(); + static CNPRStoryListBoxView* NewLC(); + virtual ~CNPRStoryListBoxView(); + +public: + // from base class CAknView + TUid Id() const; + void HandleCommandL(TInt aCommand); + CNPRStoryListBox* CreateContainerL(); + +protected: + // from base class CAknView + void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage); + void DoDeactivate(); + void HandleStatusPaneSizeChange(); + +private: + void SetupStatusPaneL(); + void CleanupStatusPane(); + +private: + // constructors + CNPRStoryListBoxView(); + void ConstructL(); + +private: + CNPRStoryListBox* iNPRStoryListBox; + }; + +#endif // __NPR_STORY_LIST_BOX_VIEW_H__ diff -r 000000000000 -r 0049171ecffb inc/NPRStoryXmlParser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inc/NPRStoryXmlParser.h Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,95 @@ +/* + ============================================================================ + Name : NPRStoryXmlParser.h + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution + - Symsource + + Contributors: + - John Kern + - Symsource + + Description : Story xml parser + ============================================================================ + */ + +#ifndef __NPR_STORY_XML_PARSER_H__ +#define __NPR_STORY_XML_PARSER_H__ + +// INCLUDES +#include +#include + +#include "NPRStory.h" + +using namespace Xml; + +/** + * CNPRStoryXmlParser + * The SAX parser will use this handler and associated enums to create story objects. + */ + +// used by SAX parser. States of the XML response from NPR server. +enum TNPRNewsState + { + ENPRNewsStateIdle = 0, + ENPRNewsStateStory, + ENPRNewsStateTitle, + ENPRNewsStateTeaser, + ENPRNewsStateThumbnail, + ENPRNewsStateMedium, + ENPRNewsStateText, + ENPRNewsStateParagraph, + ENPRNewsStateDate, + ENPRNewsStateAudio, + ENPRNewsStateAudioMp3, + ENPRNewsStateAudioReal, + ENPRNewsStateAudioWM, + }; + +class CNPRStoryXmlParser : public CBase, public MContentHandler + { +public: + static CNPRStoryXmlParser* NewL(RPointerArray* aStoryArray); + static CNPRStoryXmlParser* NewLC(RPointerArray* aStoryArray); + ~CNPRStoryXmlParser(); + +public: + void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); + void OnEndDocumentL(TInt aErrorCode); + void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode); + void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); + void OnContentL(const TDesC8& aBytes, TInt aErrorCode); + void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode); + void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); + void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); + void OnSkippedEntityL(const RString& aName, TInt aErrorCode); + void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode); + void OnError(TInt aErrorCode); + TAny* GetExtendedInterface(const TInt32 aUid) ; + +private: + // Constructors and destructor + HBufC* Copy8To16LC(const TDesC8& aDes); + +private: + CNPRStoryXmlParser(RPointerArray* aStoryArray); + void ConstructL(); + +private: + CNPRStory* iCurrentStory; + TNPRNewsState iState; + RPointerArray* iStoryArray; //it doesn't take ownership, do not delete + HBufC8* iTagName; + TBool iStory; + }; + +#endif // __NPR_STORY_XML_PARSER_H__ diff -r 000000000000 -r 0049171ecffb sis/NPR_S60_3_X_v_1_0_0.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sis/NPR_S60_3_X_v_1_0_0.pkg Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,47 @@ +; Installation file for NPR application +; +; This is an auto-generated PKG file by Carbide. +; This file uses variables specific to Carbide builds that will not work +; on command-line builds. If you want to use this generated PKG file from the +; command-line tools you will need to modify the variables with the appropriate +; values: $(EPOCROOT), $(PLATFORM), $(TARGET) +; +;Language - standard language definitions +&EN + +; standard SIS file header +#{"NPR"},(0xEEB0E481),1,0,0 + +;Localised Vendor name +%{"Symbian Foundation"} + +;Unique Vendor name +:"Symbian Foundation" + +;Supports Series 60 v 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +;Files to install +;You should change the source paths to match that of your environment +; +"$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\NPR_0xEEB0E481.exe" -"!:\sys\bin\NPR_0xEEB0E481.exe" +"$(EPOCROOT)Epoc32\data\z\resource\apps\NPR_0xEEB0E481.rsc" -"!:\resource\apps\NPR_0xEEB0E481.rsc" +"$(EPOCROOT)Epoc32\data\z\private\10003a3f\apps\NPR_0xEEB0E481_reg.rsc" -"!:\private\10003a3f\import\apps\NPR_0xEEB0E481_reg.rsc" +"$(EPOCROOT)Epoc32\data\z\resource\apps\NPR_0xEEB0E481.mif" -"!:\resource\apps\NPR_0xEEB0E481.mif" +"..\help\NPR_0xEEB0E481.hlp" -"!:\resource\help\NPR_0xEEB0E481.hlp" +"$(EPOCROOT)Epoc32\data\z\resource\apps\list_icons.mbm" -"!:\resource\apps\list_icons.mbm" + +; Add any installation notes if applicable +;"NPR.txt" -"!:\private\EEB0E481\NPR.txt" +"..\testdata\pic1.jpg" -"c:\data\npr\pic1.jpg" +"..\testdata\pic2.jpg" -"c:\data\npr\pic2.jpg" +"..\testdata\pic3.jpg" -"c:\data\npr\pic3.jpg" +"..\testdata\pic4.jpg" -"c:\data\npr\pic4.jpg" +"..\testdata\pic5.jpg" -"c:\data\npr\pic5.jpg" +"..\testdata\pic6.jpg" -"c:\data\npr\pic6.jpg" + +;required for application to be covered by backup/restore facility +"..\sis\backup_registration.xml" -"!:\private\EEB0E481\backup_registration.xml" +"..\data\npr_news_stream.rm" -"!:\data\npr_news_stream.rm" +"..\data\npr_station_stream.rm" -"!:\data\npr_station_stream.rm" + diff -r 000000000000 -r 0049171ecffb sis/NPR_S60_3_X_v_1_0_0.sis Binary file sis/NPR_S60_3_X_v_1_0_0.sis has changed diff -r 000000000000 -r 0049171ecffb sis/NPR_S60_3_X_v_1_0_0.sisx Binary file sis/NPR_S60_3_X_v_1_0_0.sisx has changed diff -r 000000000000 -r 0049171ecffb sis/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sis/backup_registration.xml Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,5 @@ + + + + + diff -r 000000000000 -r 0049171ecffb src/HttpClient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HttpClient.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,278 @@ +/* + ============================================================================ + Name : HttpClient.cpp + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : Web client + ============================================================================ + */ + +#include +#include // HTTP + +#include "HttpClient.h" + +// HTTP header values +_LIT8(KUserAgent, "NPR 1.0"); // Name of the client app. +_LIT8(KAccept, "text/*"); // Accept any (but only) text content (errors may not be sent as "text/x-visto-ota-activation"). + +CHttpClient* CHttpClient::NewL(MHTTPObserver& aObserver) + { + CHttpClient* self = new (ELeave)CHttpClient(aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +CHttpClient::CHttpClient(MHTTPObserver& aObserver) + :iObserver(aObserver) + { + } + +CHttpClient::~CHttpClient() + { + if (iTransactionActive) + { + iHttpTransaction.Cancel(); + iTransactionActive = EFalse; + } + + iHTTPSession.Close(); + iConnection.Close(); + iSocketServ.Close(); + delete iResponseBuffer; + delete iUri; + } + +void CHttpClient::ConstructL() + { + // Open the Http session + iHTTPSession.OpenL(); + User::LeaveIfError(iSocketServ.Connect()); + User::LeaveIfError(iConnection.Open(iSocketServ)); + User::LeaveIfError(iConnection.Start()); + } + + +void CHttpClient::SendRequestL(const TDesC& aUri) + { + if(iUri) + { + delete iUri; + iUri = NULL; + } + + iUri = HBufC8::NewL(aUri.Length()); + TPtr8 uriPtr = iUri->Des(); + uriPtr.Copy(aUri); + + TUriParser8 uriParser; + User::LeaveIfError(uriParser.Parse(uriPtr)); + + TBuf8<256> buf; + buf.Copy(uriParser.UriDes()); + + RStringPool strPool = iHTTPSession.StringPool(); + iHttpConnInfo = iHTTPSession.ConnectionInfo(); + iHttpConnInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable() ), THTTPHdrVal(iSocketServ.Handle())); + iHttpConnInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ),THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection)))); + + if(iTransactionActive) + { + iHttpTransaction.Cancel(); + iHttpTransaction.Close(); + iTransactionActive = EFalse; + } + + // Create transaction + iHttpTransaction = iHTTPSession.OpenTransactionL( + uriParser, + *this, + iHTTPSession.StringPool().StringF(HTTP::EPOST, RHTTPSession::GetTable())); + iTransactionActive = ETrue; + + + // Set transaction headers. + RHTTPHeaders headers = iHttpTransaction.Request().GetHeaderCollection(); + AddHeaderL(headers, HTTP::EUserAgent, KUserAgent); + AddHeaderL(headers, HTTP::EAccept, KAccept); + + // Delete any previous response. + delete iResponseBuffer; + iResponseBuffer = NULL; + + // Set the body. + iHttpTransaction.Request().SetBody(*this); + + // Submit the request + iHttpTransaction.SubmitL(); + } + +/** +* Add a header to a header set +* +* @param aHeaders The header set to be modified +* @param aHeaderField The name of the header to be added +* @param aHeaderValue The value for the header to be added +*/ +void CHttpClient::AddHeaderL(RHTTPHeaders aHeaders, + TInt aHeaderField, + const TDesC8& aHeaderValue) + { + RStringPool stringPool = iHTTPSession.StringPool(); // Do not close this session here. + RStringF valStr = stringPool.OpenFStringL(aHeaderValue); + CleanupClosePushL(valStr); + THTTPHdrVal headerVal(valStr); + aHeaders.SetFieldL(stringPool.StringF(aHeaderField, RHTTPSession::GetTable()), headerVal); + CleanupStack::PopAndDestroy(); // valStr + } + +/** + * Add a header to a header set + * + * @param aHeaders The header set to be modified + * @param aHeaderField The name of the header to be added + * @param aHeaderValue The value for the header to be added + * @param aExtensionValue The extension value for the header + */ +void CHttpClient::AddHeaderL(RHTTPHeaders aHeaders, + TInt aHeaderField, + const TDesC8& aHeaderValue, + TInt aExtensionField, + const TDesC8& aExtensionValue) + { + RStringPool stringPool = iHTTPSession.StringPool(); // Do not close this session here. + RStringF valStr = stringPool.OpenFStringL(aHeaderValue); + CleanupClosePushL(valStr); + THTTPHdrVal headerVal(valStr); + RStringF extensionStr = stringPool.OpenFStringL(aExtensionValue); + CleanupClosePushL(extensionStr); + THTTPHdrVal extensionVal(extensionStr); + aHeaders.SetFieldL( + stringPool.StringF(aHeaderField, RHTTPSession::GetTable()), + headerVal, + stringPool.StringF(aExtensionField, RHTTPSession::GetTable()), + extensionVal); + CleanupStack::PopAndDestroy(2); // extensionStr, valStr + } + +void CHttpClient::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent) + { + switch (aEvent.iStatus){ + case THTTPEvent::EGotResponseHeaders: + { + // HTTP response headers have been received. + // Pass status information to observer. + RHTTPResponse resp = aTransaction.Response(); + // Get status code + TInt statusCode = resp.StatusCode(); + + // Get status text + RStringF statusStr = resp.StatusText(); + HBufC* statusBuf = HBufC::NewLC(statusStr.DesC().Length()); + statusBuf->Des().Copy(statusStr.DesC()); + + // Inform observer + iObserver.ResponseStatusL(statusCode, *statusBuf); + + CleanupStack::PopAndDestroy(statusBuf); + break; + } + case THTTPEvent::EGotResponseBodyData: + { + // Get text of response body + MHTTPDataSupplier* dataSupplier = aTransaction.Response().Body(); + TPtrC8 ptr; + dataSupplier->GetNextDataPart(ptr); + + // Append to iResponseBuffer + if (!iResponseBuffer) + { + iResponseBuffer = ptr.AllocL(); + } + else + { + iResponseBuffer = iResponseBuffer->ReAllocL(iResponseBuffer->Length() + ptr.Length()); + iResponseBuffer->Des().Append(ptr); + } + + // Release the body data + dataSupplier->ReleaseData(); + break; + } + case THTTPEvent::EResponseComplete: + iObserver.ResponseReceivedL(*iResponseBuffer); + break; + case THTTPEvent::ESucceeded: + case THTTPEvent::EFailed: + { + aTransaction.Close(); + iTransactionActive = EFalse; + break; + } + case THTTPEvent::ERedirectedPermanently: + break; + case THTTPEvent::ERedirectedTemporarily: + break; + default: + { + if (aEvent.iStatus < 0) + { + aTransaction.Close(); + iTransactionActive = EFalse; + } + break; + } + } + } + +TInt CHttpClient::MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& /*aEvent*/) + { + if(!aError) + { + aTransaction.Close(); + iTransactionActive = EFalse; + } + return KErrNone; + } + +TBool CHttpClient::GetNextDataPart(TPtrC8& /*aDataPart*/) + { + // Not implemented for now as assuming that chunked response won't be sent + // by the server + return ETrue; + } + +void CHttpClient::ReleaseData() + { + // Not implemented for now as assuming that chunked response won't be sent + // by the server + } + +TInt CHttpClient::OverallDataSize() + { + // Not implemented for now as assuming that chunked response won't be sent + // by the server + return 0; + } + +TInt CHttpClient::Reset() + { + // Not implemented for now as assuming that chunked response won't be sent + // by the server + return KErrNone; + } diff -r 000000000000 -r 0049171ecffb src/NPR.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPR.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,32 @@ +/* + ============================================================================ + Name : NPR.cpp + Author : John Kern + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + Symbian Foundation Ltd - initial contribution. + + Contributors: John Kern +Description : Main application class + ============================================================================ + */ + +// INCLUDE FILES +#include +#include "NPRApplication.h" + +LOCAL_C CApaApplication* NewApplication() + { + return new CNPRApplication; + } + +GLDEF_C TInt E32Main() + { + return EikStart::RunApplication(NewApplication); + } + diff -r 000000000000 -r 0049171ecffb src/NPRAppEngine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRAppEngine.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,226 @@ +/* + ============================================================================ + Name : NPRAppEngine.cpp + Author : Symsourcce + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : + ============================================================================ + */ + +#include +#include +#include + +#include "NPRAppEngine.h" +#include "NPRAppUi.h" +#include "NPRStationXmlParser.h" +#include "NPRStation.h" +#include "NPRStory.h" + +_LIT(KNPRQuery, "http://api.npr.org/query?id=1001&apiKey=MDAzNTk1Nzk0MDEyNDQ2NjI1NzgyNGExNg001"); +_LIT(KNPRApiKey, "MDAzNTk1Nzk0MDEyNDQ2NjI1NzgyNGExNg001"); +_LIT(KNPRStationQuery,"http://api.npr.org/stations?%S&apiKey=%S"); +_LIT(KSearching, "Searching..."); + +_LIT(KStationStreamFile, "c:\\data\\npr_station_stream.rm"); +_LIT(KNewsStreamFile, "c:\\data\\npr_news_stream.rm"); + +_LIT8(KDataTypeRAM,"audio/x-pn-realaudio-plugin"); +_LIT8(KXmlMimeType, "text/xml"); + + +CNPRAppEngine* CNPRAppEngine::NewL(CNPRAppUi& aNPRAppUi) + { + CNPRAppEngine* self = new (ELeave) CNPRAppEngine(aNPRAppUi); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CNPRAppEngine::CNPRAppEngine(CNPRAppUi& aNPRAppUi) + :iNPRAppUi(aNPRAppUi) + { + } + +CNPRAppEngine::~CNPRAppEngine() + { + delete iDocHandler; + delete iHttp; + iStationArray.ResetAndDestroy(); + iStationArray.Close(); + iStoryArray.ResetAndDestroy(); + iStoryArray.Close(); + if(iWaitDialog) + { + delete iWaitDialog; + iWaitDialog = NULL; + } + } + +void CNPRAppEngine::ConstructL() + { + this->iHttp = CHttpClient::NewL(*this); + // Create the document handler + iDocHandler = CDocumentHandler::NewL(CEikonEnv::Static()->Process()); + } + + +void CNPRAppEngine::SendNPRCommandL(const TNPRCommands aCommand, const TDesC& aField) + { + switch(aCommand) + { + case ENewsCmd: + { + SearchNewsL(aField); + ShowWaitingDialogL(KSearching()); + break; + } + case EStationsCmd: + { + SearchStationsL(aField); + ShowWaitingDialogL(KSearching()); + break; + } + case EPlayStationStream: + { + TFileName filename(KStationStreamFile); + LaunchFileL(filename); + break; + } + case EPlayNewsStream: + { + TFileName filename(KNewsStreamFile); + LaunchFileL(filename); + break; + } + default: + return; + } + } + +const RPointerArray* CNPRAppEngine::Stations() + { + return &iStationArray; + } + +const RPointerArray* CNPRAppEngine::Stories() + { + return &iStoryArray; + } + +void CNPRAppEngine::SearchStationsL(const TDesC& aField) + { + HBufC *uri = HBufC::NewLC(KNPRStationQuery().Length() + + aField.Length() + + KNPRApiKey().Length() + ); + TPtr uriPtr = uri->Des(); + uriPtr.Format(KNPRStationQuery,&aField, &KNPRApiKey()); + iHttp->SendRequestL(uriPtr); + CleanupStack::PopAndDestroy(uri); + iNPRCommand = EStationsCmd; + } + +void CNPRAppEngine::SearchNewsL(const TDesC& /*aField*/) + { + iHttp->SendRequestL(KNPRQuery()); + iNPRCommand = ENewsCmd; + } + +void CNPRAppEngine::ResponseStatusL(TInt /*aStatusCode*/, const TDesC& /*aStatusText*/) + { + DismissWaitingDialogL(); + } + +void CNPRAppEngine::ResponseReceivedL(const TDesC8& aResponseBuffer) + { + switch(iNPRCommand) + { + case ENewsCmd: + { + iStoryArray.ResetAndDestroy(); + CNPRStoryXmlParser* newsParser = CNPRStoryXmlParser::NewLC(&iStoryArray); + CParser* parser = CParser::NewLC(KXmlMimeType, *newsParser); + parser->ParseL(aResponseBuffer); + CleanupStack::PopAndDestroy(parser); + CleanupStack::PopAndDestroy(newsParser); + iNPRAppUi.ActivateLocalViewL(TUid::Uid(ENPRStoryListBoxViewId)); + break; + } + case EStationsCmd: + { + DismissWaitingDialogL(); + iStationArray.ResetAndDestroy(); + CNPRStationXmlParser* stationParser = CNPRStationXmlParser::NewLC(&iStationArray); + CParser* parser = CParser::NewLC(KXmlMimeType, *stationParser); + parser->ParseL(aResponseBuffer); + CleanupStack::PopAndDestroy(parser); + CleanupStack::PopAndDestroy(stationParser); + iNPRAppUi.ActivateLocalViewL(TUid::Uid(ENPRStationListBoxViewId)); + break; + } + default: + DismissWaitingDialogL(); + break; + } + } + +void CNPRAppEngine::LaunchFileL(const TDesC& aFilename) + { + TDataType dataType = TDataType(KDataTypeRAM()); + // Open a file in a standalone handler application + TRAPD(err,iDocHandler->OpenFileL(aFilename, dataType)); + + TUid handlerUid; + err = iDocHandler->HandlerAppUid(handlerUid); + if (!err) + { + RefreshDocumentFileL(handlerUid, aFilename); + } + } + +/** + * Refreshes the file opened in a standalone handler. Does nothing if the file + * has not been already opened. + */ +void CNPRAppEngine::RefreshDocumentFileL(const TUid& aUid, const TDesC& aFileName) + { + TApaTaskList taskList(CEikonEnv::Static()->WsSession()); + TApaTask task = taskList.FindApp(aUid); + + // If the standalone handler is already running, then update the file + if (task.Exists()) + { + User::LeaveIfError(task.SwitchOpenFile(aFileName)); + } + } + +void CNPRAppEngine::ShowWaitingDialogL(const TDesC& aText) + { + DismissWaitingDialogL(); + iWaitDialog = new(ELeave)CAknWaitDialog((REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), EFalse ); + iWaitDialog->SetTextL(aText); + iWaitDialog->ExecuteLD(R_SINGULAR_WAIT_NOTE); + } + +void CNPRAppEngine::DismissWaitingDialogL() + { + if(iWaitDialog) + { + iWaitDialog->ProcessFinishedL(); + iWaitDialog=NULL; + } + } diff -r 000000000000 -r 0049171ecffb src/NPRAppUi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRAppUi.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,194 @@ +/* + ============================================================================ + Name : NPRAppUi.cpp + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + - Symsource + + Contributors: + - John Kern + - Symsource + + Description : CNPRAppUi implementation + ============================================================================ + */ + +// INCLUDE FILES +#include +#include +#include +#include + +#include "NPR_0xEEB0E481.hlp.hrh" +#include "NPR.hrh" +#include "NPR.pan" +#include "NPRApplication.h" +#include "NPRAppUi.h" +#include "NPRAppEngine.h" +#include "NPRListBoxView.h" +#include "NPRStoryListBoxView.h" +#include "NPRStationListBoxView.h" +#include "NPRSearchStationListBoxView.h" +#include "NPRBrowserAknView.h" + + +_LIT( KFileName, "C:\\private\\EEB0E481\\NPR.txt" ); +_LIT( KText, "Hello World!"); + +// ============================ MEMBER FUNCTIONS =============================== + + +// ----------------------------------------------------------------------------- +// CNPRAppUi::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CNPRAppUi::ConstructL() + { + // Initialise app UI with standard value. + BaseConstructL(CAknAppUi::EAknEnableSkin); + + // Create a file to write the text to + TInt err = CCoeEnv::Static()->FsSession().MkDirAll(KFileName); + if ((KErrNone != err) && (KErrAlreadyExists != err)) + { + Exit(); + } + + RFile file; + err = file.Replace(CCoeEnv::Static()->FsSession(), KFileName, EFileWrite); + CleanupClosePushL(file); + if (KErrNone != err) + { + CleanupStack::PopAndDestroy(1); // file + Exit(); + } + + RFileWriteStream outputFileStream(file); + CleanupClosePushL(outputFileStream); + outputFileStream << KText; + this->Document(); + CleanupStack::PopAndDestroy(2); // outputFileStream, file + + TRAP(err, this->iNPRAppEngine = CNPRAppEngine::NewL(*this)); + if(err != KErrNone) + { + Exit(); + } + + CNPRListBoxView* mainListBoxView = CNPRListBoxView::NewL(); + AddViewL(mainListBoxView); + + CNPRStoryListBoxView* storyListBoxView = CNPRStoryListBoxView::NewL(); + AddViewL(storyListBoxView); + + CNPRStationListBoxView* StationListBoxView = CNPRStationListBoxView::NewL(); + AddViewL(StationListBoxView); + + CNPRSearchStationListBoxView* searchStationListBoxView = CNPRSearchStationListBoxView::NewL(); + AddViewL(searchStationListBoxView); + + CBrowserAknView* browserView = CBrowserAknView::NewL(*iNPRAppEngine); + AddViewL(browserView); + + ActivateLocalViewL(TUid::Uid(ENPRListBoxViewId)); + } +// ----------------------------------------------------------------------------- +// CNPRAppUi::CNPRAppUi() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CNPRAppUi::CNPRAppUi() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// CNPRAppUi::~CNPRAppUi() +// Destructor. +// ----------------------------------------------------------------------------- +// +CNPRAppUi::~CNPRAppUi() + { + delete iNPRAppEngine; + } + +// ----------------------------------------------------------------------------- +// CNPRAppUi::HandleCommandL() +// Takes care of command handling. +// ----------------------------------------------------------------------------- +// +void CNPRAppUi::HandleCommandL(TInt aCommand) + { + switch (aCommand) + { + case EEikCmdExit: + case EAknSoftkeyExit: + { + Exit(); + } + break; + case EAbout: + { + CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog(); + dlg->PrepareLC(R_ABOUT_QUERY_DIALOG); + HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE); + dlg->QueryHeading()->SetTextL(*title); + CleanupStack::PopAndDestroy(); //title + HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT); + dlg->SetMessageTextL(*msg); + CleanupStack::PopAndDestroy(); //msg + dlg->RunLD(); + } + break; + default: + Panic(ENPRUi); + break; + } + } + +CNPRAppEngine& CNPRAppUi::Engine() + { + return *iNPRAppEngine; + } + +// ----------------------------------------------------------------------------- +// Called by the framework when the application status pane +// size is changed. Passes the new client rectangle to the +// AppView +// ----------------------------------------------------------------------------- +// +void CNPRAppUi::HandleStatusPaneSizeChange() + { + //iAppView->SetRect(ClientRect()); + } + +CArrayFix* CNPRAppUi::HelpContextL() const + { +#warning "Please see comment about help and UID3..." + // Note: Help will not work if the application uid3 is not in the + // protected range. The default uid3 range for projects created + // from this template (0xE0000000 - 0xEFFFFFFF) are not in the protected range so that they + // can be self signed and installed on the device during testing. + // Once you get your official uid3 from Symbian Ltd. and find/replace + // all occurrences of uid3 in your project, the context help will + // work. Alternatively, a patch now exists for the versions of + // HTML help compiler in SDKs and can be found here along with an FAQ: + // http://www3.symbian.com/faq.nsf/AllByDate/E9DF3257FD565A658025733900805EA2?OpenDocument + CArrayFixFlat* array = new (ELeave) CArrayFixFlat< + TCoeHelpContext> (1); + CleanupStack::PushL(array); + array->AppendL(TCoeHelpContext(KUidNPRApp, KGeneral_Information)); + CleanupStack::Pop(array); + return array; + } + +// End of File diff -r 000000000000 -r 0049171ecffb src/NPRAppView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRAppView.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,129 @@ +/* + ============================================================================ + Name : NPRAppView.cpp + Author : John Kern + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + Symbian Foundation Ltd - initial contribution. + + Contributors: John Kern + Description : Application view implementation + ============================================================================ + */ + +// INCLUDE FILES +#include +#include "NPRAppView.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CNPRAppView::NewL() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CNPRAppView* CNPRAppView::NewL(const TRect& aRect) + { + CNPRAppView* self = CNPRAppView::NewLC(aRect); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CNPRAppView::NewLC() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CNPRAppView* CNPRAppView::NewLC(const TRect& aRect) + { + CNPRAppView* self = new (ELeave) CNPRAppView; + CleanupStack::PushL(self); + self->ConstructL(aRect); + return self; + } + +// ----------------------------------------------------------------------------- +// CNPRAppView::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CNPRAppView::ConstructL(const TRect& aRect) + { + // Create a window for this application view + CreateWindowL(); + + // Set the windows size + SetRect(aRect); + + // Activate the window, which makes it ready to be drawn + ActivateL(); + } + +// ----------------------------------------------------------------------------- +// CNPRAppView::CNPRAppView() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CNPRAppView::CNPRAppView() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// CNPRAppView::~CNPRAppView() +// Destructor. +// ----------------------------------------------------------------------------- +// +CNPRAppView::~CNPRAppView() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// CNPRAppView::Draw() +// Draws the display. +// ----------------------------------------------------------------------------- +// +void CNPRAppView::Draw(const TRect& /*aRect*/) const + { + // Get the standard graphics context + CWindowGc& gc = SystemGc(); + + // Gets the control's extent + TRect drawRect(Rect()); + + // Clears the screen + gc.Clear(drawRect); + + } + +// ----------------------------------------------------------------------------- +// CNPRAppView::SizeChanged() +// Called by framework when the view size is changed. +// ----------------------------------------------------------------------------- +// +void CNPRAppView::SizeChanged() + { + DrawNow(); + } + +// ----------------------------------------------------------------------------- +// CNPRAppView::HandlePointerEventL() +// Called by framework to handle pointer touch events. +// Note: although this method is compatible with earlier SDKs, +// it will not be called in SDKs without Touch support. +// ----------------------------------------------------------------------------- +// +void CNPRAppView::HandlePointerEventL(const TPointerEvent& aPointerEvent) + { + + // Call base class HandlePointerEventL() + CCoeControl::HandlePointerEventL(aPointerEvent); + } + +// End of File diff -r 000000000000 -r 0049171ecffb src/NPRApplication.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRApplication.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,52 @@ +/* + ============================================================================ + Name : NPRApplication.cpp + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + + Description : This file contains panic codes. + ============================================================================ + */ + + +// INCLUDE FILES +#include "NPR.hrh" +#include "NPRDocument.h" +#include "NPRApplication.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CNPRApplication::CreateDocumentL() +// Creates CApaDocument object +// ----------------------------------------------------------------------------- +// +CApaDocument* CNPRApplication::CreateDocumentL() + { + // Create an NPR document, and return a pointer to it + return CNPRDocument::NewL(*this); + } + +// ----------------------------------------------------------------------------- +// CNPRApplication::AppDllUid() +// Returns application UID +// ----------------------------------------------------------------------------- +// +TUid CNPRApplication::AppDllUid() const + { + // Return the UID for the NPR application + return KUidNPRApp; + } + +// End of File diff -r 000000000000 -r 0049171ecffb src/NPRBrowserAknView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRBrowserAknView.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,103 @@ +/* + =============================================================================== + Name : NPRBrowserAknView.cpp + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : AknView for containing Nokia browser control to show NPR's Story + ================================================================================ + */ + +#include +#include +#include "NPR.hrh" +#include "NPRBrowserAknView.h" +#include "NPRBrowserContainer.h" +#include "NPRAppUi.h" + + +CBrowserAknView* CBrowserAknView::NewL(CNPRAppEngine& aEngine) + { + CBrowserAknView* p = new (ELeave) CBrowserAknView(aEngine); + CleanupStack::PushL(p); + p->ConstructL(); + CleanupStack::Pop(p); + return p; + } + +CBrowserAknView::CBrowserAknView(CNPRAppEngine& aEngine) + : iEngine(aEngine) + { + } + +CBrowserAknView::~CBrowserAknView() + { + delete iContainer; + } + + +void CBrowserAknView::ConstructL() + { + BaseConstructL(R_AKN_BROWSER_VIEW); + iContainer = new (ELeave) CBrowserContainer(); + iContainer->ConstructL(ClientRect()); + iContainer->SetMopParent( this ); + } + +TUid CBrowserAknView::Id() const + { + return TUid::Uid(ENPRBrowserViewId); + } + +void CBrowserAknView::HandleCommandL(TInt aCommand) + { + switch(aCommand) + { + case EListen: + { + iContainer->Listen(); + break; + } + case EAknSoftkeyBack: + { + static_cast(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRStoryListBoxViewId)); + break; + } + default: + { + iContainer->ProcessCommandL(aCommand); + break; + } + } + } + + +void CBrowserAknView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) + { + AppUi()->AddToStackL(*this, iContainer); + iContainer->MakeVisible(ETrue); + iContainer->ActivateL(); + iContainer->ProcessCommandL(ELoadPage); + } + +void CBrowserAknView::DoDeactivate() + { + iContainer->MakeVisible(EFalse); + AppUi()->RemoveFromViewStack(*this, iContainer); + } + +void CBrowserAknView::HandleStatusPaneSizeChange() + { + CAknView::HandleStatusPaneSizeChange(); + } diff -r 000000000000 -r 0049171ecffb src/NPRBrowserContainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRBrowserContainer.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,153 @@ +/* + =============================================================================== + Name : NPRBrowserConatiner.cpp + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Container for Nokia browser control to show NPR's Story + ================================================================================ + */ + +#include +#include +#include +#include + +#include "NPRBrowserContainer.h" +#include "npr.hrh" +#include "NPRAppUi.h" +#include "NPRAppEngine.h" + + +_LIT(KStoryHtmlFile, "file:///c:\\data\\npr\\story.html"); + +void CBrowserContainer::ConstructL(const TRect& aRect) + { + CreateWindowL(); + SetRect(aRect); + + iCommandBase = TBrCtlDefs::ECommandIdBase; + iBrowserCaps = TBrCtlDefs::ECapabilityDisplayScrollBar | TBrCtlDefs::ECapabilityLoadHttpFw | + TBrCtlDefs::ECapabilityGraphicalHistory | TBrCtlDefs::ECapabilityGraphicalPage; + + iBrowser = CreateBrowserControlL(this, Rect(), iBrowserCaps, iCommandBase, NULL, NULL, NULL, NULL, NULL); + + TRAP_IGNORE(iBrowser->SetBrowserSettingL(TBrCtlDefs::ESettingsAutoLoadImages,1)); + iBrowser->AddLoadEventObserverL(this); + iBrowser->ActivateL(); + } + +CBrowserContainer::~CBrowserContainer() + { + if (iBrowser) + iBrowser->RemoveLoadEventObserver(this); + delete iBrowser; + } + +void CBrowserContainer::SizeChanged() + { + if(iBrowser) + { + iBrowser->SetRect(Rect()); + } + } + +TInt CBrowserContainer::CountComponentControls() const + { + if(iBrowser) + return 1; + return 0; + } + +CCoeControl* CBrowserContainer::ComponentControl(TInt aIndex) const + { + switch(aIndex) + { + case 0: + return iBrowser; // Could be NULL + default: + return NULL; + } + } + +void CBrowserContainer::Draw(const TRect& /*aRect*/) const + { + CWindowGc& gc=SystemGc(); // graphics context we draw to + gc.Clear(); + } + +void CBrowserContainer::HandleControlEventL(CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/) + { + } + +TKeyResponse CBrowserContainer::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) + { + return EKeyWasNotConsumed; + } + + +void CBrowserContainer::HandleResourceChange(TInt aType) + { + CCoeControl::HandleResourceChange(aType); + SetRect(CEikonEnv::Static()->EikAppUi()->ClientRect()); + } + +void CBrowserContainer::ProcessCommandL(TInt aCommandId) + { + switch(aCommandId) + { + case ELoadPage: + if (iBrowser!=NULL) + iBrowser->LoadUrlL(KStoryHtmlFile()); + break; + default: + if (aCommandId >= iCommandBase && aCommandId < iCommandBase + TBrCtlDefs::ECommandIdWMLBase && iBrowser) + { + iBrowser->HandleCommandL(aCommandId); + } + + if (aCommandId >= iCommandBase + TBrCtlDefs::ECommandIdWMLBase && aCommandId < iCommandBase + TBrCtlDefs::ECommandIdRange && iBrowser) + { + iBrowser->HandleCommandL(aCommandId); + } + break; + } + } + +TKeyResponse CBrowserContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) + { + if(iBrowser) + { + return iBrowser->OfferKeyEventL(aKeyEvent, aType); + } + return EKeyWasConsumed; + } + +void CBrowserContainer::DynInitMenuPaneL(TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/) + { + } + +void CBrowserContainer::HandleBrowserLoadEventL(TBrCtlDefs::TBrCtlLoadEvent aLoadEvent, TUint /*aSize*/, TUint16 /*aTransactionId*/) + { + if(aLoadEvent == TBrCtlDefs::EEventLoadFinished) + { + iBrowser->DrawNow(); + } + } + + +void CBrowserContainer::Listen() + { + static_cast(CEikonEnv::Static()->EikAppUi())->Engine().SendNPRCommandL(EPlayNewsStream, KNullDesC()); + } diff -r 000000000000 -r 0049171ecffb src/NPRDocument.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRDocument.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,97 @@ +/* + ============================================================================ + Name : NPRDocument.cpp + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : Declares document class for application. + ============================================================================ + */ + +// INCLUDE FILES +#include "NPRAppUi.h" +#include "NPRDocument.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CNPRDocument::NewL() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CNPRDocument* CNPRDocument::NewL(CEikApplication& aApp) + { + CNPRDocument* self = NewLC(aApp); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// CNPRDocument::NewLC() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CNPRDocument* CNPRDocument::NewLC(CEikApplication& aApp) + { + CNPRDocument* self = new (ELeave) CNPRDocument(aApp); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// CNPRDocument::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CNPRDocument::ConstructL() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// CNPRDocument::CNPRDocument() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +CNPRDocument::CNPRDocument(CEikApplication& aApp) : + CAknDocument(aApp) + { + // No implementation required + } + +// --------------------------------------------------------------------------- +// CNPRDocument::~CNPRDocument() +// Destructor. +// --------------------------------------------------------------------------- +// +CNPRDocument::~CNPRDocument() + { + // No implementation required + } + +// --------------------------------------------------------------------------- +// CNPRDocument::CreateAppUiL() +// Constructs CreateAppUi. +// --------------------------------------------------------------------------- +// +CEikAppUi* CNPRDocument::CreateAppUiL() + { + // Create the application user interface, and return a pointer to it; + // the framework takes ownership of this object + return new (ELeave) CNPRAppUi; + } + +// End of File diff -r 000000000000 -r 0049171ecffb src/NPRHtmlCreator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRHtmlCreator.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,106 @@ +/* + ============================================================================ + Name : NPRHtmlCreator.cpp + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - Symsource + + Description : HTML composer + ============================================================================ + */ + +#include "NPRHtmlCreator.h" +#include "NPRStory.h" + +//Constants +_LIT(KPath, "c:\\data\\npr\\story.html"); +_LIT8(KHtml, "

%S

%S"); + +TInt CNPRHtmlCreator::iCurrentImage=6; + +CNPRHtmlCreator* CNPRHtmlCreator::NewLC() + { + CNPRHtmlCreator* self = new (ELeave) CNPRHtmlCreator(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CNPRHtmlCreator* CNPRHtmlCreator::NewL() + { + CNPRHtmlCreator* self = CNPRHtmlCreator::NewLC(); + CleanupStack::Pop(); // self; + return self; + } + +CNPRHtmlCreator::~CNPRHtmlCreator() + { + iFs.Close(); + } + + +void CNPRHtmlCreator::ConstructL() + { + User::LeaveIfError(iFs.Connect()); + } + +void CNPRHtmlCreator::CreateHtmlFileL(CNPRStory* aStory) + { + TInt err = iFs.MkDirAll(KPath); + if ((KErrNone != err) && (KErrAlreadyExists != err)) + { + User::Leave(err); + } + + //Open the file, replacing if necessary + RFile file; + User::LeaveIfError(file.Replace(iFs,KPath,EFileWrite)); + CleanupClosePushL(file); + + HBufC8* title=HBufC8::NewLC(aStory->Title().Length()); + title->Des().Copy(aStory->Title()); + + TInt textLength=aStory->Text().Length(); + HBufC8* text; + if (textLength!=0) + { + text=HBufC8::NewLC(textLength); + text->Des().Copy(aStory->Text()); + } + else + { + //There was no story, so just display the teaser + textLength=aStory->Teaser().Length(); + text=HBufC8::NewLC(textLength); + text->Des().Copy(aStory->Teaser()); + } + + HBufC8 *buf = HBufC8::NewLC(KHtml().Length() + + title->Length() + + textLength +1 + ); + + --iCurrentImage; + if (iCurrentImage<=0) + { + iCurrentImage=6; + } + + TPtr8 ptr = buf->Des(); + ptr.Format(KHtml,title, iCurrentImage,text); + + //Write into the file + User::LeaveIfError(file.Write(ptr)); + CleanupStack::PopAndDestroy(3); //buf,teaser,title + CleanupStack::PopAndDestroy(&file); + } diff -r 000000000000 -r 0049171ecffb src/NPRListBox.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRListBox.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,485 @@ +/* + =============================================================================================== + Name : NPRListBox.cpp + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Container for Series60 single large style list box to show the NPR's main options + =============================================================================================== + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "NPRListBox.h" +#include "NPRListBoxView.h" +#include "NPR.hrh" +#include "NPRAppUi.h" +#include "NPRAppEngine.h" + +_LIT(KNPR_0xEEB0E481File, "\\resource\\apps\\NPR_0xEEB0E481.mif"); +_LIT ( KStringHeader, "%d\t%S" ); + +/** + * First phase of Symbian two-phase construction. Should not + * contain any code that could leave. + */ +CNPRListBox::CNPRListBox() + { + iListBox = NULL; + } + +/** + * Destroy child controls. + */ +CNPRListBox::~CNPRListBox() + { + delete iListBox; + iListBox = NULL; + } + +/** + * Construct the control (first phase). + * Creates an instance and initializes it. + * Instance is not left on cleanup stack. + * @param aRect bounding rectangle + * @param aParent owning parent, or NULL + * @param aCommandObserver command observer + * @return initialized instance of CNPRListBox + */ +CNPRListBox* CNPRListBox::NewL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver ) + { + CNPRListBox* self = CNPRListBox::NewLC(aRect, aParent, aCommandObserver); + CleanupStack::Pop( self ); + return self; + } + +/** + * Construct the control (first phase). + * Creates an instance and initializes it. + * Instance is left on cleanup stack. + * @param aRect The rectangle for this window + * @param aParent owning parent, or NULL + * @param aCommandObserver command observer + * @return new instance of CNPRListBox + */ +CNPRListBox* CNPRListBox::NewLC(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver) + { + CNPRListBox* self = new (ELeave) CNPRListBox(); + CleanupStack::PushL(self); + self->ConstructL(aRect, aParent, aCommandObserver); + return self; + } + +/** + * Construct the control (second phase). + * Creates a window to contain the controls and activates it. + * @param aRect bounding rectangle + * @param aCommandObserver command observer + * @param aParent owning parent, or NULL + */ +void CNPRListBox::ConstructL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver) + { + if ( aParent == NULL ) + { + CreateWindowL(); + } + else + { + SetContainerWindowL( *aParent ); + } + iFocusControl = NULL; + iCommandObserver = aCommandObserver; + InitializeControlsL(); + SetRect( aRect ); + ActivateL(); + } + +/** +* Return the number of controls in the container (override) +* @return count +*/ +TInt CNPRListBox::CountComponentControls() const + { + return ( int ) ELastControl; + } + +/** +* Get the control with the given index (override) +* @param aIndex Control index [0...n) (limited by #CountComponentControls) +* @return Pointer to control +*/ +CCoeControl* CNPRListBox::ComponentControl( TInt aIndex ) const + { + switch ( aIndex ) + { + case EListBox: + return iListBox; + } + return NULL; + } + +/** + * Handle resizing of the container. This implementation will lay out + * full-sized controls like list boxes for any screen size, and will layout + * labels, editors, etc. to the size they were given in the UI designer. + * This code will need to be modified to adjust arbitrary controls to + * any screen size. + */ +void CNPRListBox::SizeChanged() + { + CCoeControl::SizeChanged(); + LayoutControls(); + } + +/** + * Layout components as specified in the UI Designer + */ +void CNPRListBox::LayoutControls() + { + iListBox->SetExtent( TPoint( 0, 0 ), iListBox->MinimumSize() ); + } + +/** + * Handle key events. + */ +TKeyResponse CNPRListBox::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) + { + if ( aKeyEvent.iCode == EKeyLeftArrow + || aKeyEvent.iCode == EKeyRightArrow ) + { + return EKeyWasNotConsumed; + } + + if ( aKeyEvent.iCode == EKeyDevice3) + { + TInt index = CurrentItemIndex(); + switch(index) + { + case ENews: + { + SendNewsQueryL(); + break; + } + case EStations: + { + static_cast(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRSearchStationListBoxViewId)); + break; + } + case EPrograms: + case EPlaylist: + case ESettings: + break; + default: + break; + } + } + + if ( iFocusControl != NULL + && iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed ) + { + return EKeyWasConsumed; + } + return CCoeControl::OfferKeyEventL( aKeyEvent, aType ); + } + +/** + * Initialize each control upon creation. + */ +void CNPRListBox::InitializeControlsL() + { + iListBox = new ( ELeave ) CAknSingleLargeStyleListBox; + iListBox->SetContainerWindowL( *this ); + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_NPRLIST_BOX_LIST_BOX ); + iListBox->ConstructFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + + // the listbox owns the items in the list and will free them + iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); + + // setup the icon array so graphics-style boxes work + SetupListBoxIconsL(); + + // add list items + AddListBoxResourceArrayItemL( R_NPRLIST_BOX_LISTBOX_ITEM1, + EListBoxNpr_0xeeb0e481Qgn_menu_nprIndex ); + AddListBoxResourceArrayItemL( R_NPRLIST_BOX_LISTBOX_ITEM2, + EListBoxNpr_0xeeb0e481Qgn_menu_nprIndex ); + AddListBoxResourceArrayItemL( R_NPRLIST_BOX_LISTBOX_ITEM3, + EListBoxNpr_0xeeb0e481Qgn_menu_nprIndex ); + AddListBoxResourceArrayItemL( R_NPRLIST_BOX_LISTBOX_ITEM4, + EListBoxNpr_0xeeb0e481Qgn_menu_nprIndex ); + AddListBoxResourceArrayItemL( R_NPRLIST_BOX_LISTBOX_ITEM5, + EListBoxNpr_0xeeb0e481Qgn_menu_nprIndex ); + + iListBox->SetFocus( ETrue ); + iFocusControl = iListBox; + } + +/** + * Handle global resource changes, such as scalable UI or skin events (override) + */ +void CNPRListBox::HandleResourceChange( TInt aType ) + { + CCoeControl::HandleResourceChange( aType ); + SetRect( iAvkonViewAppUi->View( TUid::Uid( ENPRListBoxViewId ) )->ClientRect() ); + } + +/** + * Draw container contents. + */ +void CNPRListBox::Draw(const TRect& aRect) const + { + CWindowGc& gc = SystemGc(); + gc.Clear( aRect ); + } + +/** + * Add a list box item to a list. + */ +void CNPRListBox::AddListBoxItemL( + CEikTextListBox* aListBox, + const TDesC& aString ) + { + CTextListBoxModel* model = aListBox->Model(); + CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() ); + itemArray->AppendL( aString ); + aListBox->HandleItemAdditionL(); + } + +/** + * Get the array of selected item indices, with respect to the list model. + * The array is sorted in ascending order. + * The array should be destroyed with two calls to CleanupStack::PopAndDestroy(), + * the first with no argument (referring to the internal resource) and the + * second with the array pointer. + * @return newly allocated array, which is left on the cleanup stack; + * or NULL for empty list. + */ +RArray< TInt >* CNPRListBox::GetSelectedListBoxItemsLC( CEikTextListBox* aListBox ) + { + CAknFilteredTextListBoxModel* model = + static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() ); + if ( model->NumberOfItems() == 0 ) + return NULL; + + // get currently selected indices + const CListBoxView::CSelectionIndexArray* selectionIndexes = + aListBox->SelectionIndexes(); + TInt selectedIndexesCount = selectionIndexes->Count(); + if ( selectedIndexesCount == 0 ) + return NULL; + + // copy the indices and sort numerically + RArray* orderedSelectedIndices = + new (ELeave) RArray< TInt >( selectedIndexesCount ); + + // push the allocated array + CleanupStack::PushL( orderedSelectedIndices ); + + // dispose the array resource + CleanupClosePushL( *orderedSelectedIndices ); + + // see if the search field is enabled + CAknListBoxFilterItems* filter = model->Filter(); + if ( filter != NULL ) + { + // when filtering enabled, translate indices back to underlying model + for ( TInt idx = 0; idx < selectedIndexesCount; idx++ ) + { + TInt filteredItem = ( *selectionIndexes ) [ idx ]; + TInt actualItem = filter->FilteredItemIndex ( filteredItem ); + orderedSelectedIndices->InsertInOrder( actualItem ); + } + } + else + { + // the selection indices refer directly to the model + for ( TInt idx = 0; idx < selectedIndexesCount; idx++ ) + orderedSelectedIndices->InsertInOrder( ( *selectionIndexes ) [ idx ] ); + } + + return orderedSelectedIndices; + } + +/** + * Delete the selected item or items from the list box. + */ +void CNPRListBox::DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox ) + { + CAknFilteredTextListBoxModel* model = + static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() ); + if ( model->NumberOfItems() == 0 ) + return; + + RArray< TInt >* orderedSelectedIndices = GetSelectedListBoxItemsLC( aListBox ); + if ( !orderedSelectedIndices ) + return; + + // Delete selected items from bottom up so indices don't change on us + CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() ); + TInt currentItem = 0; + + for ( TInt idx = orderedSelectedIndices->Count(); idx-- > 0; ) + { + currentItem = ( *orderedSelectedIndices )[ idx ]; + itemArray->Delete ( currentItem ); + } + + // dispose the array resources + CleanupStack::PopAndDestroy(); + + // dispose the array pointer + CleanupStack::PopAndDestroy( orderedSelectedIndices ); + + // refresh listbox's cursor now that items are deleted + AknListBoxUtils::HandleItemRemovalAndPositionHighlightL( + aListBox, currentItem, ETrue ); + } + +/** + * Get the listbox. + */ +CAknSingleLargeStyleListBox* CNPRListBox::ListBox() + { + return iListBox; + } + +/** + * Create a list box item with the given column values. + */ +void CNPRListBox::CreateListBoxItemL( TDes& aBuffer, + TInt aIconIndex, + const TDesC& aMainText ) + { + aBuffer.Format( KStringHeader(), aIconIndex, &aMainText ); + } + +/** + * Add an item to the list by reading the text items from the array resource + * and setting a single image property (if available) from an index + * in the list box's icon array. + * @param aResourceId id of an ARRAY resource containing the textual + * items in the columns + * @param aIconIndex the index in the icon array, or -1 + */ +void CNPRListBox::AddListBoxResourceArrayItemL( TInt aResourceId, TInt aIconIndex ) + { + CDesCArray* array = iCoeEnv->ReadDesCArrayResourceL( aResourceId ); + CleanupStack::PushL( array ); + // This is intended to be large enough, but if you get + // a USER 11 panic, consider reducing string sizes. + TBuf<512> listString; + CreateListBoxItemL( listString, aIconIndex, ( *array ) [ 0 ] ); + AddListBoxItemL( iListBox, listString ); + CleanupStack::PopAndDestroy( array ); + } + +/** + * Set up the list's icon array. + */ +void CNPRListBox::SetupListBoxIconsL() + { + /* + CArrayPtr< CGulIcon >* icons = NULL; + icons = new (ELeave) CAknIconArray( 1 ); + CleanupStack::PushL( icons ); + CGulIcon* icon; + // for EListBoxNpr_0xeeb0e481Qgn_menu_nprIndex + icon = LoadAndScaleIconL( + KNPR_0xEEB0E481File, EMbmNpr_0xeeb0e481Qgn_menu_npr, -1, + NULL, EAspectRatioPreserved ); + CleanupStack::PushL( icon ); + icons->AppendL( icon ); + CleanupStack::Pop( icon ); + CleanupStack::Pop( icons ); + + if ( icons != NULL ) + { + iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); + } + */ + } + +/** + * Handle commands relating to markable lists. + */ +TBool CNPRListBox::HandleMarkableListCommandL(TInt /*aCommand*/) + { + return EFalse; + } + +/** + * This routine loads and scales a bitmap or icon. + * + * @param aFileName the MBM or MIF filename + * @param aBitmapId the bitmap id + * @param aMaskId the mask id or -1 for none + * @param aSize the TSize for the icon, or NULL to use real size + * @param aScaleMode one of the EAspectRatio* enums when scaling + * + */ +CGulIcon* CNPRListBox::LoadAndScaleIconL( + const TDesC& aFileName, + TInt aBitmapId, + TInt aMaskId, + TSize* aSize, + TScaleMode aScaleMode ) + { + CFbsBitmap* bitmap; + CFbsBitmap* mask; + AknIconUtils::CreateIconL( bitmap, mask, aFileName, aBitmapId, aMaskId ); + + TSize size; + if ( aSize == NULL ) + { + // Use size from the image header. In case of SVG, + // we preserve the image data for a while longer, since ordinarily + // it is disposed at the first GetContentDimensions() or SetSize() call. + AknIconUtils::PreserveIconData( bitmap ); + AknIconUtils::GetContentDimensions( bitmap, size ); + } + else + { + size = *aSize; + } + + AknIconUtils::SetSize( bitmap, size, aScaleMode ); + AknIconUtils::SetSize( mask, size, aScaleMode ); + + if ( aSize == NULL ) + { + AknIconUtils::DestroyIconData( bitmap ); + } + + return CGulIcon::NewL( bitmap, mask ); + } + +TInt CNPRListBox::CurrentItemIndex() + { + return iListBox->CurrentItemIndex(); + } + +void CNPRListBox::SendNewsQueryL() + { + static_cast(CEikonEnv::Static()->EikAppUi())->Engine().SendNPRCommandL(ENewsCmd, KNullDesC()); + } diff -r 000000000000 -r 0049171ecffb src/NPRListBoxView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRListBoxView.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,236 @@ +/* + ============================================================================ + Name : NPRListBoxView.cpp + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : AknView to wrap the Series60 container to show the NPR's main options + ============================================================================ + */ + +#include +#include +#include +#include + +#include "NPR.hrh" +#include "NPRListBoxView.h" +#include "NPRListBox.h" +#include "NPRAppUi.h" +#include "NPRAppEngine.h" + + +/** + * Symbian two-phase constructor. + * This creates an instance then calls the second-phase constructor + * without leaving the instance on the cleanup stack. + * @return new instance of CNPRListBoxView + */ +CNPRListBoxView* CNPRListBoxView::NewL() + { + CNPRListBoxView* self = CNPRListBoxView::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +/** + * Symbian two-phase constructor. + * This creates an instance, pushes it on the cleanup stack, + * then calls the second-phase constructor. + * @return new instance of CNPRListBoxView + */ +CNPRListBoxView* CNPRListBoxView::NewLC() + { + CNPRListBoxView* self = new ( ELeave ) CNPRListBoxView(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +/** + * First phase of Symbian two-phase construction. Should not contain any + * code that could leave. + */ +CNPRListBoxView::CNPRListBoxView() + :iNPRListBox(NULL) + { + } + +/** + * The view's destructor removes the container from the control + * stack and destroys it. + */ +CNPRListBoxView::~CNPRListBoxView() + { + delete iNPRListBox; + iNPRListBox = NULL; + } + + +/** + * Second-phase constructor for view. + * Initialize contents from resource. + */ +void CNPRListBoxView::ConstructL() + { + BaseConstructL( R_NPRLIST_BOX_NPRLIST_BOX_VIEW ); + } + +/** + * @return The UID for this view + */ +TUid CNPRListBoxView::Id() const + { + return TUid::Uid( ENPRListBoxViewId ); + } + +/** + * Handle a command for this view (override) + * @param aCommand command id to be handled + */ +void CNPRListBoxView::HandleCommandL(TInt aCommand) + { + TBool commandHandled = EFalse; + switch(aCommand) + { // code to dispatch to the AknView's menu and CBA commands is generated here + case ESelect: + { + commandHandled = ETrue; + TInt index = iNPRListBox->CurrentItemIndex(); + switch(index) + { + case ENews: + { + iNPRListBox->SendNewsQueryL(); + break; + } + case EStations: + { + static_cast(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRSearchStationListBoxViewId)); + break; + } + case EPrograms: + break; + default: + break; + } + break; + } + default: + break; + } + + + if (!commandHandled) + { + if ( aCommand == EAknSoftkeyExit ) + { + AppUi()->HandleCommandL( EEikCmdExit ); + } + } + } + +/** + * Handles user actions during activation of the view, + * such as initializing the content. + */ +void CNPRListBoxView::DoActivateL( + const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/ ) + { + SetupStatusPaneL(); + + if ( iNPRListBox == NULL ) + { + iNPRListBox = CreateContainerL(); + iNPRListBox->SetMopParent( this ); + AppUi()->AddToStackL( *this, iNPRListBox ); + } + } + +/** + */ +void CNPRListBoxView::DoDeactivate() + { + CleanupStatusPane(); + + if ( iNPRListBox != NULL ) + { + AppUi()->RemoveFromViewStack( *this, iNPRListBox ); + delete iNPRListBox; + iNPRListBox = NULL; + } + } + +/** + * Handle status pane size change for this view (override) + */ +void CNPRListBoxView::HandleStatusPaneSizeChange() + { + CAknView::HandleStatusPaneSizeChange(); + + // this may fail, but we're not able to propagate exceptions here + TVwsViewId view; + AppUi()->GetActiveViewId( view ); + if ( view.iViewUid == Id() ) + { + TInt result; + TRAP( result, SetupStatusPaneL() ); + } + } + +void CNPRListBoxView::SetupStatusPaneL() + { + // reset the context pane + TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); + CEikStatusPaneBase::TPaneCapabilities subPaneContext = + StatusPane()->PaneCapabilities( contextPaneUid ); + if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) + { + CAknContextPane* context = static_cast< CAknContextPane* > ( + StatusPane()->ControlL( contextPaneUid ) ); + context->SetPictureToDefaultL(); + } + + // setup the title pane + TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); + CEikStatusPaneBase::TPaneCapabilities subPaneTitle = + StatusPane()->PaneCapabilities( titlePaneUid ); + if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) + { + CAknTitlePane* title = static_cast< CAknTitlePane* >( + StatusPane()->ControlL( titlePaneUid ) ); + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_NPRLIST_BOX_TITLE_RESOURCE ); + title->SetFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + } + +void CNPRListBoxView::CleanupStatusPane() + { + } + + +/** + * Creates the top-level container for the view. You may modify this method's + * contents and the CNPRListBox::NewL() signature as needed to initialize the + * container, but the signature for this method is fixed. + * @return new initialized instance of CNPRListBox + */ +CNPRListBox* CNPRListBoxView::CreateContainerL() + { + return CNPRListBox::NewL( ClientRect(), NULL, this ); + } diff -r 000000000000 -r 0049171ecffb src/NPRSearchStationListBox.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRSearchStationListBox.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,458 @@ +/* + =================================================================================================== + Name : NPRSearchStationListBox.cpp + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Container for Series60 single style list box to show the NPR's station search options + =================================================================================================== + */ + +#include +#include +#include +#include +#include +#include + +#include "NPRSearchStationListBox.h" +#include "NPRSearchStationListBoxView.h" +#include "NPR.hrh" +#include "NPRAppUi.h" +#include "NPRAppEngine.h" + +TInt ShowQueryDialogL(const TDesC& aTitle, TDes& aBuffer) + { + CAknTextQueryDialog* Dialog = CAknTextQueryDialog::NewL(aBuffer,CAknQueryDialog::ENoTone); + Dialog->PrepareLC(R_ASK_NAME_DIALOG); + Dialog->SetPromptL(aTitle); + return Dialog->RunLD(); + } + +/** + * First phase of Symbian two-phase construction. Should not + * contain any code that could leave. + */ +CNPRSearchStationListBox::CNPRSearchStationListBox() + { + iListBox = NULL; + } + +/** + * Destroy child controls. + */ +CNPRSearchStationListBox::~CNPRSearchStationListBox() + { + delete iListBox; + iListBox = NULL; + } + +/** + * Construct the control (first phase). + * Creates an instance and initializes it. + * Instance is not left on cleanup stack. + * @param aRect bounding rectangle + * @param aParent owning parent, or NULL + * @param aCommandObserver command observer + * @return initialized instance of CNPRSearchStationListBox + */ +CNPRSearchStationListBox* CNPRSearchStationListBox::NewL( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + CNPRSearchStationListBox* self = CNPRSearchStationListBox::NewLC( + aRect, + aParent, + aCommandObserver ); + CleanupStack::Pop( self ); + return self; + } + +/** + * Construct the control (first phase). + * Creates an instance and initializes it. + * Instance is left on cleanup stack. + * @param aRect The rectangle for this window + * @param aParent owning parent, or NULL + * @param aCommandObserver command observer + * @return new instance of CNPRSearchStationListBox + */ +CNPRSearchStationListBox* CNPRSearchStationListBox::NewLC( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + CNPRSearchStationListBox* self = new ( ELeave ) CNPRSearchStationListBox(); + CleanupStack::PushL( self ); + self->ConstructL( aRect, aParent, aCommandObserver ); + return self; + } + +/** + * Construct the control (second phase). + * Creates a window to contain the controls and activates it. + * @param aRect bounding rectangle + * @param aCommandObserver command observer + * @param aParent owning parent, or NULL + */ +void CNPRSearchStationListBox::ConstructL( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + if ( aParent == NULL ) + { + CreateWindowL(); + } + else + { + SetContainerWindowL( *aParent ); + } + iFocusControl = NULL; + iCommandObserver = aCommandObserver; + InitializeControlsL(); + SetRect( aRect ); + ActivateL(); + } + +/** +* Return the number of controls in the container (override) +* @return count +*/ +TInt CNPRSearchStationListBox::CountComponentControls() const + { + return ( int ) ELastControl; + } + +/** +* Get the control with the given index (override) +* @param aIndex Control index [0...n) (limited by #CountComponentControls) +* @return Pointer to control +*/ +CCoeControl* CNPRSearchStationListBox::ComponentControl( TInt aIndex ) const + { + switch ( aIndex ) + { + case EListBox: + return iListBox; + } + return NULL; + } + +/** + * Handle resizing of the container. This implementation will lay out + * full-sized controls like list boxes for any screen size, and will layout + * labels, editors, etc. to the size they were given in the UI designer. + * This code will need to be modified to adjust arbitrary controls to + * any screen size. + */ +void CNPRSearchStationListBox::SizeChanged() + { + CCoeControl::SizeChanged(); + LayoutControls(); + } + +/** + * Layout components as specified in the UI Designer + */ +void CNPRSearchStationListBox::LayoutControls() + { + iListBox->SetExtent( TPoint( 0, 0 ), iListBox->MinimumSize() ); + } + +void CNPRSearchStationListBox::SendStationQueryL() + { + TInt index = CurrentItemIndex(); + switch(index) + { + case EZipCode: + { + TBuf<16> zipCode; + ShowQueryDialogL(_L("ZIP Code"),zipCode); + if(zipCode.Length() != 0) + { + TBuf<32> zipCodeFormat; + zipCodeFormat.Format(KNPRZipQuery,&zipCode); + static_cast(CEikonEnv::Static()->EikAppUi())->Engine().SendNPRCommandL(EStationsCmd, zipCodeFormat); + } + break; + } + case ECurrentLocation: + { + TBuf<32> zipCodeFormat; + zipCodeFormat.Format(KNPRZipQuery,&KNPRCurrentLocationZip()); + static_cast(CEikonEnv::Static()->EikAppUi())->Engine().SendNPRCommandL(EStationsCmd, zipCodeFormat); + break; + } + case ECityName: + { + break; + } + case EShowAll: + { + break; + } + default: + break; + } + } + +/** + * Handle key events. + */ +TKeyResponse CNPRSearchStationListBox::OfferKeyEventL( + const TKeyEvent& aKeyEvent, + TEventCode aType ) + { + if ( aKeyEvent.iCode == EKeyLeftArrow + || aKeyEvent.iCode == EKeyRightArrow ) + { + // Listbox takes all events even if it doesn't use them + return EKeyWasNotConsumed; + } + + if ( aKeyEvent.iCode == EKeyDevice3) + { + SendStationQueryL(); + } + + if ( iFocusControl != NULL + && iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed ) + { + return EKeyWasConsumed; + } + return CCoeControl::OfferKeyEventL( aKeyEvent, aType ); + } + +/** + * Initialize each control upon creation. + */ +void CNPRSearchStationListBox::InitializeControlsL() + { + iListBox = new ( ELeave ) CAknSingleStyleListBox; + iListBox->SetContainerWindowL( *this ); + { + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_NPRSEARCH_STATION_LIST_BOX_LIST_BOX ); + iListBox->ConstructFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + // the listbox owns the items in the list and will free them + iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); + + // setup the icon array so graphics-style boxes work + SetupListBoxIconsL(); + + + // add list items + // add list items + AddListBoxResourceArrayItemL(R_NPRSEARCH_STATION_LIST_BOX_ITEM1, EListBoxFirstUserImageIndex ); + AddListBoxResourceArrayItemL(R_NPRSEARCH_STATION_LIST_BOX_ITEM2, EListBoxFirstUserImageIndex ); + AddListBoxResourceArrayItemL(R_NPRSEARCH_STATION_LIST_BOX_ITEM3, EListBoxFirstUserImageIndex ); + AddListBoxResourceArrayItemL(R_NPRSEARCH_STATION_LIST_BOX_ITEM4, EListBoxFirstUserImageIndex ); + + + iListBox->SetFocus( ETrue ); + iFocusControl = iListBox; + + } + +/** + * Handle global resource changes, such as scalable UI or skin events (override) + */ +void CNPRSearchStationListBox::HandleResourceChange( TInt aType ) + { + CCoeControl::HandleResourceChange( aType ); + SetRect( iAvkonViewAppUi->View( TUid::Uid( ENPRSearchStationListBoxViewId ) )->ClientRect() ); + } + +/** + * Draw container contents. + */ +void CNPRSearchStationListBox::Draw( const TRect& aRect ) const + { + CWindowGc& gc = SystemGc(); + gc.Clear( aRect ); + } + +/** + * Add a list box item to a list. + */ +void CNPRSearchStationListBox::AddListBoxItemL( + CEikTextListBox* aListBox, + const TDesC& aString ) + { + CTextListBoxModel* model = aListBox->Model(); + CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() ); + itemArray->AppendL( aString ); + aListBox->HandleItemAdditionL(); + } + +/** + * Get the array of selected item indices, with respect to the list model. + * The array is sorted in ascending order. + * The array should be destroyed with two calls to CleanupStack::PopAndDestroy(), + * the first with no argument (referring to the internal resource) and the + * second with the array pointer. + * @return newly allocated array, which is left on the cleanup stack; + * or NULL for empty list. + */ +RArray< TInt >* CNPRSearchStationListBox::GetSelectedListBoxItemsLC( CEikTextListBox* aListBox ) + { + CAknFilteredTextListBoxModel* model = + static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() ); + if ( model->NumberOfItems() == 0 ) + return NULL; + + // get currently selected indices + const CListBoxView::CSelectionIndexArray* selectionIndexes = + aListBox->SelectionIndexes(); + TInt selectedIndexesCount = selectionIndexes->Count(); + if ( selectedIndexesCount == 0 ) + return NULL; + + // copy the indices and sort numerically + RArray* orderedSelectedIndices = + new (ELeave) RArray< TInt >( selectedIndexesCount ); + + // push the allocated array + CleanupStack::PushL( orderedSelectedIndices ); + + // dispose the array resource + CleanupClosePushL( *orderedSelectedIndices ); + + // see if the search field is enabled + CAknListBoxFilterItems* filter = model->Filter(); + if ( filter != NULL ) + { + // when filtering enabled, translate indices back to underlying model + for ( TInt idx = 0; idx < selectedIndexesCount; idx++ ) + { + TInt filteredItem = ( *selectionIndexes ) [ idx ]; + TInt actualItem = filter->FilteredItemIndex ( filteredItem ); + orderedSelectedIndices->InsertInOrder( actualItem ); + } + } + else + { + // the selection indices refer directly to the model + for ( TInt idx = 0; idx < selectedIndexesCount; idx++ ) + orderedSelectedIndices->InsertInOrder( ( *selectionIndexes ) [ idx ] ); + } + + return orderedSelectedIndices; + } + +/** + * Delete the selected item or items from the list box. + */ +void CNPRSearchStationListBox::DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox ) + { + CAknFilteredTextListBoxModel* model = + static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() ); + if ( model->NumberOfItems() == 0 ) + return; + + RArray< TInt >* orderedSelectedIndices = GetSelectedListBoxItemsLC( aListBox ); + if ( !orderedSelectedIndices ) + return; + + // Delete selected items from bottom up so indices don't change on us + CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() ); + TInt currentItem = 0; + + for ( TInt idx = orderedSelectedIndices->Count(); idx-- > 0; ) + { + currentItem = ( *orderedSelectedIndices )[ idx ]; + itemArray->Delete ( currentItem ); + } + + // dispose the array resources + CleanupStack::PopAndDestroy(); + + // dispose the array pointer + CleanupStack::PopAndDestroy( orderedSelectedIndices ); + + // refresh listbox's cursor now that items are deleted + AknListBoxUtils::HandleItemRemovalAndPositionHighlightL( + aListBox, currentItem, ETrue ); + } + +/** + * Get the listbox. + */ +CAknSingleStyleListBox* CNPRSearchStationListBox::ListBox() + { + return iListBox; + } + +/** + * Create a list box item with the given column values. + */ +void CNPRSearchStationListBox::CreateListBoxItemL( TDes& aBuffer, + TInt aIconIndex, + const TDesC& aMainText ) + { + _LIT ( KStringHeader, "%d\t%S" ); + + aBuffer.Format( KStringHeader(), aIconIndex, &aMainText ); + } + +/** + * Add an item to the list by reading the text items from the array resource + * and setting a single image property (if available) from an index + * in the list box's icon array. + * @param aResourceId id of an ARRAY resource containing the textual + * items in the columns + * @param aIconIndex the index in the icon array, or -1 + */ +void CNPRSearchStationListBox::AddListBoxResourceArrayItemL( TInt aResourceId, TInt aIconIndex ) + { + CDesCArray* array = iCoeEnv->ReadDesCArrayResourceL( aResourceId ); + CleanupStack::PushL( array ); + // This is intended to be large enough, but if you get + // a USER 11 panic, consider reducing string sizes. + TBuf<512> listString; + CreateListBoxItemL( listString, aIconIndex, ( *array ) [ 0 ] ); + AddListBoxItemL( iListBox, listString ); + CleanupStack::PopAndDestroy( array ); + } + +/** + * Set up the list's icon array. + */ +void CNPRSearchStationListBox::SetupListBoxIconsL() + { + CArrayPtr< CGulIcon >* icons = NULL; + + if ( icons != NULL ) + { + iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); + } + } + +/** + * Handle commands relating to markable lists. + */ +TBool CNPRSearchStationListBox::HandleMarkableListCommandL( TInt /*aCommand*/) + { + TBool result = EFalse; + return result; + } + +TInt CNPRSearchStationListBox::CurrentItemIndex() + { + return iListBox->CurrentItemIndex(); + } diff -r 000000000000 -r 0049171ecffb src/NPRSearchStationListBoxView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRSearchStationListBoxView.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,211 @@ +/* + =================================================================================================== + Name : NPRSearchStationListBoxView.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : AknView for wrapping the container to show the NPR's station search options + =================================================================================================== + */ + +#include +#include +#include +#include +#include + +#include "NPR.hrh" +#include "NPRSearchStationListBoxView.h" +#include "NPRSearchStationListBox.h" +#include "NPRAppUi.h" +#include "NPRAppEngine.h" + +/** + * First phase of Symbian two-phase construction. Should not contain any + * code that could leave. + */ +CNPRSearchStationListBoxView::CNPRSearchStationListBoxView() + { + iNPRSearchStationListBox = NULL; + } + +/** + * The view's destructor removes the container from the control + * stack and destroys it. + */ +CNPRSearchStationListBoxView::~CNPRSearchStationListBoxView() + { + delete iNPRSearchStationListBox; + iNPRSearchStationListBox = NULL; + } + +/** + * Symbian two-phase constructor. + * This creates an instance then calls the second-phase constructor + * without leaving the instance on the cleanup stack. + * @return new instance of CNPRSearchStationListBoxView + */ +CNPRSearchStationListBoxView* CNPRSearchStationListBoxView::NewL() + { + CNPRSearchStationListBoxView* self = CNPRSearchStationListBoxView::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +/** + * Symbian two-phase constructor. + * This creates an instance, pushes it on the cleanup stack, + * then calls the second-phase constructor. + * @return new instance of CNPRSearchStationListBoxView + */ +CNPRSearchStationListBoxView* CNPRSearchStationListBoxView::NewLC() + { + CNPRSearchStationListBoxView* self = new ( ELeave ) CNPRSearchStationListBoxView(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + + +/** + * Second-phase constructor for view. + * Initialize contents from resource. + */ +void CNPRSearchStationListBoxView::ConstructL() + { + BaseConstructL( R_NPRSEARCH_STATION_LIST_BOX_NPRSEARCH_STATION_LIST_BOX_VIEW ); + } + +/** + * @return The UID for this view + */ +TUid CNPRSearchStationListBoxView::Id() const + { + return TUid::Uid( ENPRSearchStationListBoxViewId ); + } + +/** + * Handle a command for this view (override) + * @param aCommand command id to be handled + */ +void CNPRSearchStationListBoxView::HandleCommandL( TInt aCommand ) + { + switch(aCommand) + { // code to dispatch to the AknView's menu and CBA commands is generated here + case ESelect: + { + iNPRSearchStationListBox->SendStationQueryL(); + break; + } + case EAknSoftkeyBack: + { + static_cast(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRListBoxViewId)); + break; + } + default: + break; + } + } + +/** + * Handles user actions during activation of the view, + * such as initializing the content. + */ +void CNPRSearchStationListBoxView::DoActivateL( + const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/ ) + { + SetupStatusPaneL(); + if ( iNPRSearchStationListBox == NULL ) + { + iNPRSearchStationListBox = CreateContainerL(); + iNPRSearchStationListBox->SetMopParent( this ); + AppUi()->AddToStackL( *this, iNPRSearchStationListBox ); + } + } + +/** + */ +void CNPRSearchStationListBoxView::DoDeactivate() + { + CleanupStatusPane(); + + if ( iNPRSearchStationListBox != NULL ) + { + AppUi()->RemoveFromViewStack( *this, iNPRSearchStationListBox ); + delete iNPRSearchStationListBox; + iNPRSearchStationListBox = NULL; + } + } + +/** + * Handle status pane size change for this view (override) + */ +void CNPRSearchStationListBoxView::HandleStatusPaneSizeChange() + { + CAknView::HandleStatusPaneSizeChange(); + + // this may fail, but we're not able to propagate exceptions here + TVwsViewId view; + AppUi()->GetActiveViewId( view ); + if ( view.iViewUid == Id() ) + { + TInt result; + TRAP( result, SetupStatusPaneL() ); + } + } + +void CNPRSearchStationListBoxView::SetupStatusPaneL() + { + // reset the context pane + TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); + CEikStatusPaneBase::TPaneCapabilities subPaneContext = + StatusPane()->PaneCapabilities( contextPaneUid ); + if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) + { + CAknContextPane* context = static_cast< CAknContextPane* > ( + StatusPane()->ControlL( contextPaneUid ) ); + context->SetPictureToDefaultL(); + } + + // setup the title pane + TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); + CEikStatusPaneBase::TPaneCapabilities subPaneTitle = + StatusPane()->PaneCapabilities( titlePaneUid ); + if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) + { + CAknTitlePane* title = static_cast< CAknTitlePane* >( + StatusPane()->ControlL( titlePaneUid ) ); + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_NPRSEARCH_STATION_LIST_BOX_TITLE_RESOURCE ); + title->SetFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + } + +void CNPRSearchStationListBoxView::CleanupStatusPane() + { + } + +/** + * Creates the top-level container for the view. You may modify this method's + * contents and the CNPRSearchStationListBox::NewL() signature as needed to initialize the + * container, but the signature for this method is fixed. + * @return new initialized instance of CNPRSearchStationListBox + */ +CNPRSearchStationListBox* CNPRSearchStationListBoxView::CreateContainerL() + { + return CNPRSearchStationListBox::NewL( ClientRect(), NULL, this ); + } diff -r 000000000000 -r 0049171ecffb src/NPRStation.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRStation.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,93 @@ +/* + ============================================================================ + Name : NPRStation.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Class to wrap all the Station fields + ============================================================================ + */ + +#include "NPRStation.h" + + +CNPRStation* CNPRStation::NewLC() + { + CNPRStation* self = new (ELeave) CNPRStation(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CNPRStation* CNPRStation::NewL() + { + CNPRStation* self = CNPRStation::NewLC(); + CleanupStack::Pop(); // self; + return self; + } + +CNPRStation::~CNPRStation() + { + iName.Close(); + iFrequency.Close(); + iMarketCity.Close(); + } + +void CNPRStation::ConstructL() + { + } + +void CNPRStation::SetNameL(const TDesC8& aName) + { + HBufC* temp = HBufC::NewLC(aName.Length()); + // copy from 8 to 16 bit descriptor. + temp->Des().Copy(aName); + + if(iName.MaxLength() < temp->Length()) + { + iName.ReAlloc(temp->Length()); + } + iName.Copy(temp->Des()); + CleanupStack::PopAndDestroy(); + } + +void CNPRStation::SetFrequencyL(const TDesC8& aFrequency) + { + HBufC* temp = HBufC::NewLC(aFrequency.Length()); + // copy from 8 to 16 bit descriptor. + temp->Des().Copy(aFrequency); + + if(iFrequency.MaxLength() < temp->Length()) + { + iFrequency.ReAlloc(temp->Length()); + } + iFrequency.Copy(temp->Des()); + CleanupStack::PopAndDestroy(); + } + +void CNPRStation::SetMarketCityL(const TDesC8& aMarketCity) + { + HBufC* temp = HBufC::NewLC(aMarketCity.Length()); + // copy from 8 to 16 bit descriptor. + temp->Des().Copy(aMarketCity); + + if(iMarketCity.MaxLength() < temp->Length()) + { + iMarketCity.ReAlloc(temp->Length()); + } + iMarketCity.Copy(temp->Des()); + CleanupStack::PopAndDestroy(); + } + + diff -r 000000000000 -r 0049171ecffb src/NPRStationListBox.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRStationListBox.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,415 @@ +/* + ============================================================================ + Name : NPRStationListBox.cpp + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Container for Series60 double style list box to show the NPR's station list + ============================================================================ + */ + +#include +#include +#include + +#include "NPRStationListBox.h" +#include "NPRStationListBoxView.h" +#include "NPR.hrh" +#include "NPRStation.h" +#include "NPRAppUi.h" +#include "NPRAppEngine.h" + +const TInt KFrequencyTab = 20; +/** + * First phase of Symbian two-phase construction. Should not + * contain any code that could leave. + */ +CNPRStationListBox::CNPRStationListBox() + { + iListBox = NULL; + iStationArray = static_cast(CEikonEnv::Static()->EikAppUi())->Engine().Stations(); + } +/** + * Destroy child controls. + */ +CNPRStationListBox::~CNPRStationListBox() + { + delete iListBox; + iListBox = NULL; + } + +/** + * Construct the control (first phase). + * Creates an instance and initializes it. + * Instance is not left on cleanup stack. + * @param aRect bounding rectangle + * @param aParent owning parent, or NULL + * @param aCommandObserver command observer + * @return initialized instance of CNPRStationListBox + */ +CNPRStationListBox* CNPRStationListBox::NewL( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + CNPRStationListBox* self = CNPRStationListBox::NewLC( + aRect, + aParent, + aCommandObserver ); + CleanupStack::Pop( self ); + return self; + } + +/** + * Construct the control (first phase). + * Creates an instance and initializes it. + * Instance is left on cleanup stack. + * @param aRect The rectangle for this window + * @param aParent owning parent, or NULL + * @param aCommandObserver command observer + * @return new instance of CNPRStationListBox + */ +CNPRStationListBox* CNPRStationListBox::NewLC( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + CNPRStationListBox* self = new ( ELeave ) CNPRStationListBox(); + CleanupStack::PushL( self ); + self->ConstructL( aRect, aParent, aCommandObserver ); + return self; + } + +/** + * Construct the control (second phase). + * Creates a window to contain the controls and activates it. + * @param aRect bounding rectangle + * @param aCommandObserver command observer + * @param aParent owning parent, or NULL + */ +void CNPRStationListBox::ConstructL( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + if ( aParent == NULL ) + { + CreateWindowL(); + } + else + { + SetContainerWindowL( *aParent ); + } + iFocusControl = NULL; + iCommandObserver = aCommandObserver; + InitializeControlsL(); + SetRect( aRect ); + ActivateL(); + } + +/** +* Return the number of controls in the container (override) +* @return count +*/ +TInt CNPRStationListBox::CountComponentControls() const + { + return ( int ) ELastControl; + } + +/** +* Get the control with the given index (override) +* @param aIndex Control index [0...n) (limited by #CountComponentControls) +* @return Pointer to control +*/ +CCoeControl* CNPRStationListBox::ComponentControl( TInt aIndex ) const + { + switch ( aIndex ) + { + case EListBox: + return iListBox; + } + return NULL; + } + +/** + * Handle resizing of the container. This implementation will lay out + * full-sized controls like list boxes for any screen size, and will layout + * labels, editors, etc. to the size they were given in the UI designer. + * This code will need to be modified to adjust arbitrary controls to + * any screen size. + */ +void CNPRStationListBox::SizeChanged() + { + CCoeControl::SizeChanged(); + LayoutControls(); + } + +/** + * Layout components as specified in the UI Designer + */ +void CNPRStationListBox::LayoutControls() + { + iListBox->SetExtent( TPoint( 0, 0 ), iListBox->MinimumSize() ); + } + +void CNPRStationListBox::Listen() + { + static_cast(CEikonEnv::Static()->EikAppUi())->Engine().SendNPRCommandL(EPlayStationStream, KNullDesC()); + } + +/** + * Handle key events. + */ +TKeyResponse CNPRStationListBox::OfferKeyEventL( + const TKeyEvent& aKeyEvent, + TEventCode aType ) + { + if ( aKeyEvent.iCode == EKeyLeftArrow + || aKeyEvent.iCode == EKeyRightArrow ) + { + // Listbox takes all events even if it doesn't use them + return EKeyWasNotConsumed; + } + + if ( iFocusControl != NULL + && iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed ) + { + return EKeyWasConsumed; + } + return CCoeControl::OfferKeyEventL( aKeyEvent, aType ); + } + +/** + * Initialize each control upon creation. + */ +void CNPRStationListBox::InitializeControlsL() + { + iListBox = new ( ELeave ) CAknDoubleStyle2ListBox; + iListBox->SetContainerWindowL( *this ); + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_NPRSTATION_LIST_BOX_LIST_BOX); + iListBox->ConstructFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + // the listbox owns the items in the list and will free them + iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); + iListBox->CreateScrollBarFrameL(ETrue); + iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto); + + // setup the icon array so graphics-style boxes work + SetupListBoxIconsL(); + + // add list items + for(TInt i=0; iCount(); i++) + { + TInt nameLength = (*iStationArray)[i]->Name().Length(); + TBuf<64> namePlusFrequency((*iStationArray)[i]->Name()); + if((*iStationArray)[i]->Frequency().Length()!=0) + { + for(TInt j=0; jFrequency()); + } + TBuf<128> listString; + CreateListBoxItemL(listString, namePlusFrequency, (*iStationArray)[i]->MarketCity()); + AddListBoxItemL(iListBox, listString); + } + + iListBox->SetFocus( ETrue ); + iFocusControl = iListBox; + } + +/** + * Handle global resource changes, such as scalable UI or skin events (override) + */ +void CNPRStationListBox::HandleResourceChange( TInt aType ) + { + CCoeControl::HandleResourceChange( aType ); + SetRect( iAvkonViewAppUi->View( TUid::Uid( ENPRStationListBoxViewId ) )->ClientRect() ); + } + +/** + * Draw container contents. + */ +void CNPRStationListBox::Draw( const TRect& aRect ) const + { + CWindowGc& gc = SystemGc(); + gc.Clear( aRect ); + } + +/** + * Add a list box item to a list. + */ +void CNPRStationListBox::AddListBoxItemL( + CEikTextListBox* aListBox, + const TDesC& aString ) + { + CTextListBoxModel* model = aListBox->Model(); + CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() ); + itemArray->AppendL( aString ); + aListBox->HandleItemAdditionL(); + } + +/** + * Get the array of selected item indices, with respect to the list model. + * The array is sorted in ascending order. + * The array should be destroyed with two calls to CleanupStack::PopAndDestroy(), + * the first with no argument (referring to the internal resource) and the + * second with the array pointer. + * @return newly allocated array, which is left on the cleanup stack; + * or NULL for empty list. + */ +RArray< TInt >* CNPRStationListBox::GetSelectedListBoxItemsLC( CEikTextListBox* aListBox ) + { + CAknFilteredTextListBoxModel* model = + static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() ); + if ( model->NumberOfItems() == 0 ) + return NULL; + + // get currently selected indices + const CListBoxView::CSelectionIndexArray* selectionIndexes = + aListBox->SelectionIndexes(); + TInt selectedIndexesCount = selectionIndexes->Count(); + if ( selectedIndexesCount == 0 ) + return NULL; + + // copy the indices and sort numerically + RArray* orderedSelectedIndices = + new (ELeave) RArray< TInt >( selectedIndexesCount ); + + // push the allocated array + CleanupStack::PushL( orderedSelectedIndices ); + + // dispose the array resource + CleanupClosePushL( *orderedSelectedIndices ); + + // see if the search field is enabled + CAknListBoxFilterItems* filter = model->Filter(); + if ( filter != NULL ) + { + // when filtering enabled, translate indices back to underlying model + for ( TInt idx = 0; idx < selectedIndexesCount; idx++ ) + { + TInt filteredItem = ( *selectionIndexes ) [ idx ]; + TInt actualItem = filter->FilteredItemIndex ( filteredItem ); + orderedSelectedIndices->InsertInOrder( actualItem ); + } + } + else + { + // the selection indices refer directly to the model + for ( TInt idx = 0; idx < selectedIndexesCount; idx++ ) + orderedSelectedIndices->InsertInOrder( ( *selectionIndexes ) [ idx ] ); + } + + return orderedSelectedIndices; + } + +/** + * Delete the selected item or items from the list box. + */ +void CNPRStationListBox::DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox ) + { + CAknFilteredTextListBoxModel* model = + static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() ); + if ( model->NumberOfItems() == 0 ) + return; + + RArray< TInt >* orderedSelectedIndices = GetSelectedListBoxItemsLC( aListBox ); + if ( !orderedSelectedIndices ) + return; + + // Delete selected items from bottom up so indices don't change on us + CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() ); + TInt currentItem = 0; + + for ( TInt idx = orderedSelectedIndices->Count(); idx-- > 0; ) + { + currentItem = ( *orderedSelectedIndices )[ idx ]; + itemArray->Delete ( currentItem ); + } + + // dispose the array resources + CleanupStack::PopAndDestroy(); + + // dispose the array pointer + CleanupStack::PopAndDestroy( orderedSelectedIndices ); + + // refresh listbox's cursor now that items are deleted + AknListBoxUtils::HandleItemRemovalAndPositionHighlightL( + aListBox, currentItem, ETrue ); + } + +/** + * Get the listbox. + */ +CAknDoubleStyle2ListBox* CNPRStationListBox::ListBox() + { + return iListBox; + } + +/** + * Create a list box item with the given column values. + */ +void CNPRStationListBox::CreateListBoxItemL( TDes& aBuffer, + const TDesC& aMainText, + const TDesC& aSecondaryText ) + { + _LIT ( KStringHeader, "\t%S\t%S" ); + + aBuffer.Format( KStringHeader(), &aMainText, &aSecondaryText ); + } + +/** + * Add an item to the list by reading the text items from the array resource + * and setting a single image property (if available) from an index + * in the list box's icon array. + * @param aResourceId id of an ARRAY resource containing the textual + * items in the columns + * + */ +void CNPRStationListBox::AddListBoxResourceArrayItemL( TInt aResourceId ) + { + CDesCArray* array = iCoeEnv->ReadDesCArrayResourceL( aResourceId ); + CleanupStack::PushL( array ); + // This is intended to be large enough, but if you get + // a USER 11 panic, consider reducing string sizes. + TBuf<512> listString; + CreateListBoxItemL( listString, ( *array ) [ 0 ], ( *array ) [ 1 ] ); + AddListBoxItemL( iListBox, listString ); + CleanupStack::PopAndDestroy( array ); + } + +/** + * Set up the list's icon array. + */ +void CNPRStationListBox::SetupListBoxIconsL() + { + CArrayPtr< CGulIcon >* icons = NULL; + + if(icons != NULL) + { + iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons); + } + } + +/** + * Handle commands relating to markable lists. + */ +TBool CNPRStationListBox::HandleMarkableListCommandL(TInt /*aCommand*/) + { + TBool result = EFalse; + return result; + } diff -r 000000000000 -r 0049171ecffb src/NPRStationListBoxView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRStationListBoxView.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,212 @@ +/* + ========================================================================================== + Name : NPRStationListBoxView.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : AknView for wrapping the container to show the NPR's station list + ========================================================================================== + */ + +#include +#include +#include +#include + +#include "NPR.hrh" +#include "NPRStationListBoxView.h" +#include "NPRStationListBox.h" +#include "NPRAppUi.h" +#include "NPRAppEngine.h" + +/** + * First phase of Symbian two-phase construction. Should not contain any + * code that could leave. + */ +CNPRStationListBoxView::CNPRStationListBoxView() + { + iNPRStationListBox = NULL; + } + +/** + * The view's destructor removes the container from the control + * stack and destroys it. + */ +CNPRStationListBoxView::~CNPRStationListBoxView() + { + delete iNPRStationListBox; + iNPRStationListBox = NULL; + } + +/** + * Symbian two-phase constructor. + * This creates an instance then calls the second-phase constructor + * without leaving the instance on the cleanup stack. + * @return new instance of CNPRStationListBoxView + */ +CNPRStationListBoxView* CNPRStationListBoxView::NewL() + { + CNPRStationListBoxView* self = CNPRStationListBoxView::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +/** + * Symbian two-phase constructor. + * This creates an instance, pushes it on the cleanup stack, + * then calls the second-phase constructor. + * @return new instance of CNPRStationListBoxView + */ +CNPRStationListBoxView* CNPRStationListBoxView::NewLC() + { + CNPRStationListBoxView* self = new ( ELeave ) CNPRStationListBoxView(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +/** + * Second-phase constructor for view. + * Initialize contents from resource. + */ +void CNPRStationListBoxView::ConstructL() + { + BaseConstructL( R_NPRSTATION_LIST_BOX_NPRSTATION_LIST_BOX_VIEW); + } + +/** + * @return The UID for this view + */ +TUid CNPRStationListBoxView::Id() const + { + return TUid::Uid( ENPRStationListBoxViewId ); + } + +/** + * Handle a command for this view (override) + * @param aCommand command id to be handled + */ +void CNPRStationListBoxView::HandleCommandL( TInt aCommand ) + { + TBool commandHandled = EFalse; + switch(aCommand) + {// code to dispatch to the AknView's menu and CBA commands is generated here + case EListen: + { + iNPRStationListBox->Listen(); + commandHandled = ETrue; + break; + } + case EAknSoftkeyBack: + { + static_cast(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRSearchStationListBoxViewId)); + commandHandled = ETrue; + break; + } + default: + break; + } + } + +/** + * Handles user actions during activation of the view, + * such as initializing the content. + */ +void CNPRStationListBoxView::DoActivateL( + const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/ ) + { + SetupStatusPaneL(); + if ( iNPRStationListBox == NULL ) + { + iNPRStationListBox = CreateContainerL(); + iNPRStationListBox->SetMopParent( this ); + AppUi()->AddToStackL( *this, iNPRStationListBox ); + } + } + +/** + */ +void CNPRStationListBoxView::DoDeactivate() + { + CleanupStatusPane(); + if ( iNPRStationListBox != NULL ) + { + AppUi()->RemoveFromViewStack( *this, iNPRStationListBox ); + delete iNPRStationListBox; + iNPRStationListBox = NULL; + } + } + +/** + * Handle status pane size change for this view (override) + */ +void CNPRStationListBoxView::HandleStatusPaneSizeChange() + { + CAknView::HandleStatusPaneSizeChange(); + + // this may fail, but we're not able to propagate exceptions here + TVwsViewId view; + AppUi()->GetActiveViewId( view ); + if ( view.iViewUid == Id() ) + { + TInt result; + TRAP( result, SetupStatusPaneL() ); + } + } + +void CNPRStationListBoxView::SetupStatusPaneL() + { + // reset the context pane + TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); + CEikStatusPaneBase::TPaneCapabilities subPaneContext = + StatusPane()->PaneCapabilities( contextPaneUid ); + if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) + { + CAknContextPane* context = static_cast< CAknContextPane* > ( + StatusPane()->ControlL( contextPaneUid ) ); + context->SetPictureToDefaultL(); + } + + // setup the title pane + TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); + CEikStatusPaneBase::TPaneCapabilities subPaneTitle = + StatusPane()->PaneCapabilities( titlePaneUid ); + if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) + { + CAknTitlePane* title = static_cast< CAknTitlePane* >( + StatusPane()->ControlL( titlePaneUid ) ); + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_NPRSTATION_LIST_BOX_TITLE_RESOURCE); + title->SetFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + + } + +void CNPRStationListBoxView::CleanupStatusPane() + { + } + +/** + * Creates the top-level container for the view. You may modify this method's + * contents and the CNPRStationListBox::NewL() signature as needed to initialize the + * container, but the signature for this method is fixed. + * @return new initialized instance of CNPRStationListBox + */ +CNPRStationListBox* CNPRStationListBoxView::CreateContainerL() + { + return CNPRStationListBox::NewL( ClientRect(), NULL, this ); + } diff -r 000000000000 -r 0049171ecffb src/NPRStationXmlParser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRStationXmlParser.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,210 @@ +/* + ============================================================================ + Name : NPRStationXmlParser.cpp + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Station xml parser + ============================================================================ + */ + +#include "NPRDocument.h" +#include "NPRStationXmlParser.h" +#include "NPRStation.h" + +CNPRStationXmlParser* CNPRStationXmlParser::NewLC(RPointerArray* aStationArray) + { + CNPRStationXmlParser* self = new (ELeave) CNPRStationXmlParser(aStationArray); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CNPRStationXmlParser* CNPRStationXmlParser::NewL(RPointerArray* aStationArray) + { + CNPRStationXmlParser* self = CNPRStationXmlParser::NewLC(aStationArray); + CleanupStack::Pop(); // self; + return self; + } + +CNPRStationXmlParser::CNPRStationXmlParser(RPointerArray* aStationArray) +:iStationArray(aStationArray) + { + // No implementation required + } + +CNPRStationXmlParser::~CNPRStationXmlParser() + { + } + +void CNPRStationXmlParser::ConstructL() + { + iState = ENPRStationStateIdle; + } + +void CNPRStationXmlParser::OnStartDocumentL(const RDocumentParameters& /* aDocParam */, TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +void CNPRStationXmlParser::OnEndDocumentL(TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +HBufC* CNPRStationXmlParser::Copy8To16LC(const TDesC8& aDes) + { + HBufC* buf16 = HBufC::NewLC(aDes.Length()); + buf16->Des().Copy(aDes); + return buf16; + } + +void CNPRStationXmlParser::OnStartElementL( + const RTagInfo& aElement, + const RAttributeArray& aAttributes, + TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + const TDesC8& tagName = aElement.LocalName().DesC(); + if (tagName.CompareF(_L8("station"))==0) + { + iState = ENPRStationStateStation; + iCurrentStation = CNPRStation::NewL(); + // find the story Id attribute + TInt count = aAttributes.Count(); + for (TInt i = 0 ; i < count ; i++) + { + const RAttribute& attribute = aAttributes[i]; + const RTagInfo& nameInfo = attribute.Attribute(); + + const TDesC8& localName8 = nameInfo.LocalName().DesC(); + const TDesC8& value8 = attribute.Value().DesC(); + + HBufC* localName16 = Copy8To16LC(localName8); + HBufC* value16 = Copy8To16LC(value8); + if (localName16->CompareF(_L("id")) == 0 ) + { + TLex lex(value16->Des()); + TInt v = 0; + lex.Val(v); + iCurrentStation->SetStationId( v ); + } + CleanupStack::PopAndDestroy(2); // value16 and localName16 + } + } + else if (tagName.CompareF(_L8("name"))==0 && iState == ENPRStationStateStation) + { + iState = ENPRStationStateName; + } + else if (tagName.CompareF(_L8("frequency"))==0 && iState == ENPRStationStateNameEnd) + { + iState = ENPRStationStateFrequency; + } + else if (tagName.CompareF(_L8("marketCity"))==0 && iState == ENPRStationStateFrequencyEnd) + { + iState = ENPRStationStateMarketCity; + } + } + +void CNPRStationXmlParser::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode ) + { + User::LeaveIfError(aErrorCode); + const TDesC8& tagName = aElement.LocalName().DesC(); + if (tagName.CompareF(_L8("station"))== 0 && iState == ENPRStationStateMarketCityEnd) + { + iState = ENPRStationStateIdle; + iStationArray->AppendL(iCurrentStation); + iCurrentStation = NULL; + } + else if (tagName.CompareF(_L8("name"))== 0 && iState == ENPRStationStateName) + { + iState = ENPRStationStateNameEnd; + } + else if (tagName.CompareF(_L8("frequency"))== 0 && iState == ENPRStationStateFrequency) + { + iState = ENPRStationStateFrequencyEnd; + } + else if (tagName.CompareF(_L8("marketCity"))== 0 && iState == ENPRStationStateMarketCity) + { + iState = ENPRStationStateMarketCityEnd; + } + } + +void CNPRStationXmlParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + + switch(iState) + { + case ENPRStationStateName: + { + iCurrentStation->SetNameL(aBytes); + break; + } + case ENPRStationStateFrequency: + { + iCurrentStation->SetFrequencyL(aBytes); + break; + } + case ENPRStationStateMarketCity: + { + iCurrentStation->SetMarketCityL(aBytes); + break; + } + + default: + iState = iState; // for debugging. + break; + } + } + +void CNPRStationXmlParser::OnStartPrefixMappingL( + const RString& /* aPrefix */, + const RString& /* aUri */, + TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +void CNPRStationXmlParser::OnEndPrefixMappingL(const RString& /* aPrefix */, TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +void CNPRStationXmlParser::OnIgnorableWhiteSpaceL(const TDesC8& /* aBytes */, TInt /* aErrorCode*/ ) + { + } + +void CNPRStationXmlParser::OnSkippedEntityL(const RString& /* aName */, TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +void CNPRStationXmlParser::OnProcessingInstructionL( + const TDesC8& /* aTarget */ , + const TDesC8& /* aData */ , + TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +void CNPRStationXmlParser::OnError(TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +TAny* CNPRStationXmlParser::GetExtendedInterface(const TInt32 /* aUid */ ) + { + return NULL; + } diff -r 000000000000 -r 0049171ecffb src/NPRStory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRStory.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,138 @@ +/* + ============================================================================ + Name : NPRStory.cpp + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution. + + Contributors: + - John Kern + - Symsource + + Description : NPR's xml story parser + ============================================================================ + */ + +#include "NPRStory.h" + +const int KUrlLength = 256; + +CNPRStory* CNPRStory::NewLC() + { + CNPRStory* self = new (ELeave) CNPRStory(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CNPRStory* CNPRStory::NewL() + { + CNPRStory* self = CNPRStory::NewLC(); + CleanupStack::Pop(); // self; + return self; + } + +CNPRStory::CNPRStory() +:iTitle(NULL),iTeaser(NULL),iMp3Url(NULL) + { + // No implementation required + } + +CNPRStory::~CNPRStory() + { + iTitle.Close(); + iTeaser.Close(); + iText.Close(); + iMp3Url.Close(); + iThumbnailUrl.Close(); + } + +void CNPRStory::ConstructL() + { + } + +void CNPRStory::SetTitleL(const TDesC8& aTitle) + { + HBufC* temp = HBufC::NewLC(aTitle.Length()); + // copy from 8 to 16 bit descriptor. + temp->Des().Copy(aTitle); + + if(iTitle.MaxLength() < temp->Length()) + { + iTitle.ReAlloc(temp->Length()); + } + iTitle.Copy(temp->Des()); + CleanupStack::PopAndDestroy(); + } + +void CNPRStory::SetTeaserL(const TDesC8& aTeaser) + { + HBufC* temp = HBufC::NewLC(aTeaser.Length()); + // copy from 8 to 16 bit descriptor. + temp->Des().Copy(aTeaser); + + // append it + const TInt newLength = iTeaser.Length() + temp->Length(); + if(iTeaser.MaxLength() < newLength) + { + iTeaser.ReAlloc(newLength); + } + iTeaser.Append(temp->Des()); + CleanupStack::PopAndDestroy(); + } + +void CNPRStory::SetTextL(const TDesC8& aText) + { + HBufC* temp = HBufC::NewLC(aText.Length()); + // copy from 8 to 16 bit descriptor. + temp->Des().Copy(aText); + // append it + + const TInt newLength = iText.Length() + temp->Length(); + if(iText.MaxLength() < newLength) + { + iText.ReAlloc(newLength); + } + iText.Append(temp->Des()); + + CleanupStack::PopAndDestroy(); + } + +// The XML parser will call this multiple times to construct the mp3url. +void CNPRStory::SetMp3UrlL(const TDesC8& aMp3Url) + { + HBufC* temp = HBufC::NewLC(aMp3Url.Length()); + // copy from 8 to 16 bit descriptor. + temp->Des().Copy(aMp3Url); + + // append it + const TInt newLength = iMp3Url.Length() + temp->Length(); + if(iMp3Url.MaxLength() < newLength) + { + iMp3Url.ReAlloc(newLength); + } + iMp3Url.Append(temp->Des()); + CleanupStack::PopAndDestroy(); + } + +void CNPRStory::SetThumbnailUrlL(const TDesC8& aThumbUrl) + { + HBufC* temp = HBufC::NewLC(aThumbUrl.Length()); + // copy from 8 to 16 bit descriptor. + temp->Des().Copy(aThumbUrl); + + if(iThumbnailUrl.MaxLength() < temp->Length()) + { + iThumbnailUrl.ReAlloc(temp->Length()); + } + iThumbnailUrl.Copy(temp->Des()); + CleanupStack::PopAndDestroy(); + } +//End of file diff -r 000000000000 -r 0049171ecffb src/NPRStoryListBox.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRStoryListBox.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,496 @@ +/* + ============================================================================ + Name : NPRStoryListBox.cpp + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : Container for Series60 double style list box to show the NPR's story list + ============================================================================ + */ + +#include +#include +#include +#include +#include + +#include "NPRStoryListBox.h" +#include "NPRStoryListBoxView.h" +#include "NPR.hrh" +#include "NPRAppUi.h" +#include "NPRAppEngine.h" +#include "NPRHtmlCreator.h" + +_LIT(KStringHeader, "%d\t%S\t%S" ); +_LIT(KTestUiFile, "\\resource\\apps\\list_icons.mbm"); + +/** + * Construct the control (first phase). + * Creates an instance and initializes it. + * Instance is not left on cleanup stack. + * @param aRect bounding rectangle + * @param aParent owning parent, or NULL + * @param aCommandObserver command observer + * @return initialized instance of CNPRStoryListBox + */ +CNPRStoryListBox* CNPRStoryListBox::NewL( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + CNPRStoryListBox* self = CNPRStoryListBox::NewLC( + aRect, + aParent, + aCommandObserver ); + CleanupStack::Pop( self ); + return self; + } + +/** + * Construct the control (first phase). + * Creates an instance and initializes it. + * Instance is left on cleanup stack. + * @param aRect The rectangle for this window + * @param aParent owning parent, or NULL + * @param aCommandObserver command observer + * @return new instance of CNPRStoryListBox + */ +CNPRStoryListBox* CNPRStoryListBox::NewLC( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + CNPRStoryListBox* self = new ( ELeave ) CNPRStoryListBox(); + CleanupStack::PushL( self ); + self->ConstructL( aRect, aParent, aCommandObserver ); + return self; + } + +/** + * First phase of Symbian two-phase construction. Should not + * contain any code that could leave. + */ +CNPRStoryListBox::CNPRStoryListBox() + { + iListBox = NULL; + iStoryArray = static_cast(CEikonEnv::Static()->EikAppUi())->Engine().Stories(); + } +/** + * Destroy child controls. + */ +CNPRStoryListBox::~CNPRStoryListBox() + { + delete iHtmlCreator; + delete iListBox; + iListBox = NULL; + } + +/** + * Construct the control (second phase). + * Creates a window to contain the controls and activates it. + * @param aRect bounding rectangle + * @param aCommandObserver command observer + * @param aParent owning parent, or NULL + */ +void CNPRStoryListBox::ConstructL( + const TRect& aRect, + const CCoeControl* aParent, + MEikCommandObserver* aCommandObserver ) + { + if ( aParent == NULL ) + { + CreateWindowL(); + } + else + { + SetContainerWindowL( *aParent ); + } + iFocusControl = NULL; + iCommandObserver = aCommandObserver; + iHtmlCreator = CNPRHtmlCreator::NewL(); + + InitializeControlsL(); + SetRect( aRect ); + ActivateL(); + } + +/** +* Return the number of controls in the container (override) +* @return count +*/ +TInt CNPRStoryListBox::CountComponentControls() const + { + return ( int ) ELastControl; + } + +/** +* Get the control with the given index (override) +* @param aIndex Control index [0...n) (limited by #CountComponentControls) +* @return Pointer to control +*/ +CCoeControl* CNPRStoryListBox::ComponentControl( TInt aIndex ) const + { + switch(aIndex) + { + case EListBox: + return iListBox; + } + return NULL; + } + +/** + * Handle resizing of the container. This implementation will lay out + * full-sized controls like list boxes for any screen size, and will layout + * labels, editors, etc. to the size they were given in the UI designer. + * This code will need to be modified to adjust arbitrary controls to + * any screen size. + */ +void CNPRStoryListBox::SizeChanged() + { + CCoeControl::SizeChanged(); + LayoutControls(); + } + +/** + * Layout components as specified in the UI Designer + */ +void CNPRStoryListBox::LayoutControls() + { + iListBox->SetExtent( TPoint( 0, 0 ), iListBox->MinimumSize() ); + } + +/** + * Handle key events. + */ +TKeyResponse CNPRStoryListBox::OfferKeyEventL( + const TKeyEvent& aKeyEvent, + TEventCode aType ) + { + if ( aKeyEvent.iCode == EKeyLeftArrow + || aKeyEvent.iCode == EKeyRightArrow ) + { + // Listbox takes all events even if it doesn't use them + return EKeyWasNotConsumed; + } + + if ( iFocusControl != NULL && aKeyEvent.iCode == EKeyDevice3) + { + ShowSelectedStoryL(); + return EKeyWasConsumed; + } + + if ( iFocusControl != NULL + && iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed ) + { + return EKeyWasConsumed; + } + return CCoeControl::OfferKeyEventL( aKeyEvent, aType ); + } + +/** + * Initialize each control upon creation. + */ +void CNPRStoryListBox::InitializeControlsL() + { + iListBox = new ( ELeave ) CAknDoubleLargeStyleListBox; + iListBox->SetContainerWindowL( *this ); + { + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_NPRSTORY_LIST_BOX_LIST_BOX ); + iListBox->ConstructFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + // the listbox owns the items in the list and will free them + iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); + iListBox->CreateScrollBarFrameL(ETrue); + iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto); + + SetupListBoxIconsL(); + // add list items + for(TInt i=0; iCount(); i++) + { + HBufC* story = HBufC::NewLC(KStringHeader().Length() + + (*iStoryArray)[i]->Title().Length() + + (*iStoryArray)[i]->Teaser().Length() + ); + TPtr storyPtr = story->Des(); + CreateListBoxItemL(storyPtr, TInt(0), (*iStoryArray)[i]->Title(), (*iStoryArray)[i]->Teaser()); + AddListBoxItemL(iListBox, storyPtr); + CleanupStack::PopAndDestroy(story); + } + + iListBox->SetFocus( ETrue ); + iFocusControl = iListBox; + } + +/** + * Handle global resource changes, such as scalable UI or skin events (override) + */ +void CNPRStoryListBox::HandleResourceChange( TInt aType ) + { + CCoeControl::HandleResourceChange( aType ); + SetRect( iAvkonViewAppUi->View( TUid::Uid( ENPRStoryListBoxViewId ) )->ClientRect() ); + } + +/** + * Draw container contents. + */ +void CNPRStoryListBox::Draw( const TRect& aRect ) const + { + CWindowGc& gc = SystemGc(); + gc.Clear( aRect ); + } + +/** + * Add a list box item to a list. + */ +void CNPRStoryListBox::AddListBoxItemL( + CEikTextListBox* aListBox, + const TDesC& aString ) + { + CTextListBoxModel* model = aListBox->Model(); + CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() ); + itemArray->AppendL( aString ); + aListBox->HandleItemAdditionL(); + } + +/** + * Get the array of selected item indices, with respect to the list model. + * The array is sorted in ascending order. + * The array should be destroyed with two calls to CleanupStack::PopAndDestroy(), + * the first with no argument (referring to the internal resource) and the + * second with the array pointer. + * @return newly allocated array, which is left on the cleanup stack; + * or NULL for empty list. + */ +RArray< TInt >* CNPRStoryListBox::GetSelectedListBoxItemsLC( CEikTextListBox* aListBox ) + { + CAknFilteredTextListBoxModel* model = + static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() ); + if ( model->NumberOfItems() == 0 ) + return NULL; + + // get currently selected indices + const CListBoxView::CSelectionIndexArray* selectionIndexes = + aListBox->SelectionIndexes(); + TInt selectedIndexesCount = selectionIndexes->Count(); + if ( selectedIndexesCount == 0 ) + return NULL; + + // copy the indices and sort numerically + RArray* orderedSelectedIndices = + new (ELeave) RArray< TInt >( selectedIndexesCount ); + + // push the allocated array + CleanupStack::PushL( orderedSelectedIndices ); + + // dispose the array resource + CleanupClosePushL( *orderedSelectedIndices ); + + // see if the search field is enabled + CAknListBoxFilterItems* filter = model->Filter(); + if ( filter != NULL ) + { + // when filtering enabled, translate indices back to underlying model + for ( TInt idx = 0; idx < selectedIndexesCount; idx++ ) + { + TInt filteredItem = ( *selectionIndexes ) [ idx ]; + TInt actualItem = filter->FilteredItemIndex ( filteredItem ); + orderedSelectedIndices->InsertInOrder( actualItem ); + } + } + else + { + // the selection indices refer directly to the model + for ( TInt idx = 0; idx < selectedIndexesCount; idx++ ) + orderedSelectedIndices->InsertInOrder( ( *selectionIndexes ) [ idx ] ); + } + + return orderedSelectedIndices; + } + +/** + * Delete the selected item or items from the list box. + */ +void CNPRStoryListBox::DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox ) + { + CAknFilteredTextListBoxModel* model = + static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() ); + if ( model->NumberOfItems() == 0 ) + return; + + RArray< TInt >* orderedSelectedIndices = GetSelectedListBoxItemsLC( aListBox ); + if ( !orderedSelectedIndices ) + return; + + // Delete selected items from bottom up so indices don't change on us + CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() ); + TInt currentItem = 0; + + for ( TInt idx = orderedSelectedIndices->Count(); idx-- > 0; ) + { + currentItem = ( *orderedSelectedIndices )[ idx ]; + itemArray->Delete ( currentItem ); + } + + // dispose the array resources + CleanupStack::PopAndDestroy(); + + // dispose the array pointer + CleanupStack::PopAndDestroy( orderedSelectedIndices ); + + // refresh listbox's cursor now that items are deleted + AknListBoxUtils::HandleItemRemovalAndPositionHighlightL( + aListBox, currentItem, ETrue ); + } + +/** + * Get the listbox. + */ +CAknDoubleLargeStyleListBox* CNPRStoryListBox::ListBox() + { + return iListBox; + } + +/** + * Create a list box item with the given column values. + */ +void CNPRStoryListBox::CreateListBoxItemL( TDes& aBuffer, + TInt aIconIndex, + const TDesC& aMainText, + const TDesC& aSecondaryText ) + { + + aBuffer.Format( KStringHeader(), aIconIndex, &aMainText, &aSecondaryText); + } + +/** + * Add an item to the list by reading the text items from the array resource + * and setting a single image property (if available) from an index + * in the list box's icon array. + * @param aResourceId id of an ARRAY resource containing the textual + * items in the columns + * @param aIconIndex the index in the icon array, or -1 + */ +void CNPRStoryListBox::AddListBoxResourceArrayItemL( TInt aResourceId, TInt aIconIndex ) + { + CDesCArray* array = iCoeEnv->ReadDesCArrayResourceL( aResourceId ); + CleanupStack::PushL( array ); + // This is intended to be large enough, but if you get + // a USER 11 panic, consider reducing string sizes. + TBuf<512> listString; + CreateListBoxItemL( listString, aIconIndex, (*array) [0], (*array )[1]); + AddListBoxItemL( iListBox, listString ); + CleanupStack::PopAndDestroy( array ); + } + +/** + * Set up the list's icon array. + */ +void CNPRStoryListBox::SetupListBoxIconsL() + { + CArrayPtr< CGulIcon >* icons = new (ELeave) CAknIconArray( 1 ); + CleanupStack::PushL( icons ); + + icons->AppendL(LoadAndScaleIconL(KTestUiFile, + EMbmList_iconsNpr_symbian_generic, + EMbmList_iconsNpr_symbian_generic_mask, + NULL, EAspectRatioPreserved )); + + CleanupStack::Pop( icons ); + + if ( icons != NULL ) + { + iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); + } + } + +/** + * Handle commands relating to markable lists. + */ +TBool CNPRStoryListBox::HandleMarkableListCommandL(TInt /*aCommand*/) + { + return EFalse; + } + +/** + * This routine loads and scales a bitmap or icon. + * + * @param aFileName the MBM or MIF filename + * @param aBitmapId the bitmap id + * @param aMaskId the mask id or -1 for none + * @param aSize the TSize for the icon, or NULL to use real size + * @param aScaleMode one of the EAspectRatio* enums when scaling + * + */ +CGulIcon* CNPRStoryListBox::LoadAndScaleIconL( + const TDesC& aFileName, + TInt aBitmapId, + TInt aMaskId, + TSize* aSize, + TScaleMode aScaleMode ) + { + CFbsBitmap* bitmap; + CFbsBitmap* mask; + TRAPD(err, AknIconUtils::CreateIconL( bitmap, mask, aFileName, aBitmapId, aMaskId )); + + TSize size; + if ( aSize == NULL ) + { + // Use size from the image header. In case of SVG, + // we preserve the image data for a while longer, since ordinarily + // it is disposed at the first GetContentDimensions() or SetSize() call. + AknIconUtils::PreserveIconData( bitmap ); + AknIconUtils::GetContentDimensions( bitmap, size ); + } + else + { + size = *aSize; + } + + AknIconUtils::SetSize( bitmap, size, aScaleMode ); + AknIconUtils::SetSize( mask, size, aScaleMode ); + + if ( aSize == NULL ) + { + AknIconUtils::DestroyIconData( bitmap ); + } + + return CGulIcon::NewL( bitmap, mask ); + } + +TInt CNPRStoryListBox::CurrentItemIndex() + { + return iListBox->CurrentItemIndex(); + } + +void CNPRStoryListBox::ShowSelectedStoryL() + { +// TInt index = CurrentItemIndex(); +// static_cast(CEikonEnv::Static()->EikAppUi())-> +// ActivateLocalViewL(TUid::Uid(ENPRStoryViewerContainerViewId), TUid::Uid(index),KNullDesC8);//TO DO use custum message instead of custum command + + TInt currentItem = iListBox->CurrentItemIndex(); + if (currentItem==-1) + { + return; + } + + CNPRStory* story=(*iStoryArray)[currentItem]; + + //TODO - Move this code into the browser container, so it is seperate from the listbox + iHtmlCreator->CreateHtmlFileL(story); + + static_cast(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRBrowserViewId)); + } diff -r 000000000000 -r 0049171ecffb src/NPRStoryListBoxView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRStoryListBoxView.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,211 @@ +/* + ========================================================================================== + Name : NPRStoryListBoxView.h + Author : Symsource + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symsource + + Contributors: + - Symsource + + Description : AknView for wrapping the container to show the NPR's story list + ========================================================================================== + */ + +#include +#include +#include +#include +#include + +#include "NPR.hrh" +#include "NPRStoryListBoxView.h" +#include "NPRStoryListBox.h" +#include "NPRAppUi.h" +#include "NPRAppEngine.h" + +/** + * First phase of Symbian two-phase construction. Should not contain any + * code that could leave. + */ +CNPRStoryListBoxView::CNPRStoryListBoxView() + { + iNPRStoryListBox = NULL; + } + +/** + * The view's destructor removes the container from the control + * stack and destroys it. + */ +CNPRStoryListBoxView::~CNPRStoryListBoxView() + { + delete iNPRStoryListBox; + iNPRStoryListBox = NULL; + } + +/** + * Symbian two-phase constructor. + * This creates an instance then calls the second-phase constructor + * without leaving the instance on the cleanup stack. + * @return new instance of CNPRStoryListBoxView + */ +CNPRStoryListBoxView* CNPRStoryListBoxView::NewL() + { + CNPRStoryListBoxView* self = CNPRStoryListBoxView::NewLC(); + CleanupStack::Pop( self ); + return self; + } + +/** + * Symbian two-phase constructor. + * This creates an instance, pushes it on the cleanup stack, + * then calls the second-phase constructor. + * @return new instance of CNPRStoryListBoxView + */ +CNPRStoryListBoxView* CNPRStoryListBoxView::NewLC() + { + CNPRStoryListBoxView* self = new ( ELeave ) CNPRStoryListBoxView(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +/** + * Second-phase constructor for view. + * Initialize contents from resource. + */ +void CNPRStoryListBoxView::ConstructL() + { + BaseConstructL( R_NPRSTORY_LIST_BOX_NPRSTORY_LIST_BOX_VIEW ); + } + +/** + * @return The UID for this view + */ +TUid CNPRStoryListBoxView::Id() const + { + return TUid::Uid(ENPRStoryListBoxViewId); + } + +/** + * Handle a command for this view (override) + * @param aCommand command id to be handled + */ +void CNPRStoryListBoxView::HandleCommandL( TInt aCommand ) + { + switch ( aCommand ) + { // code to dispatch to the AknView's menu and CBA commands is generated here + case ESelect: + { + iNPRStoryListBox->ShowSelectedStoryL(); + break; + } + case EAknSoftkeyBack: + { + static_cast(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRListBoxViewId)); + break; + } + default: + break; + } + } + +/** + * Handles user actions during activation of the view, + * such as initializing the content. + */ +void CNPRStoryListBoxView::DoActivateL( + const TVwsViewId& /*aPrevViewId*/, + TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/ ) + { + SetupStatusPaneL(); + if ( iNPRStoryListBox == NULL ) + { + iNPRStoryListBox = CreateContainerL(); + iNPRStoryListBox->SetMopParent( this ); + AppUi()->AddToStackL( *this, iNPRStoryListBox ); + } + } + +/** + */ +void CNPRStoryListBoxView::DoDeactivate() + { + CleanupStatusPane(); + + if ( iNPRStoryListBox != NULL ) + { + AppUi()->RemoveFromViewStack( *this, iNPRStoryListBox ); + delete iNPRStoryListBox; + iNPRStoryListBox = NULL; + } + } + +/** + * Handle status pane size change for this view (override) + */ +void CNPRStoryListBoxView::HandleStatusPaneSizeChange() + { + CAknView::HandleStatusPaneSizeChange(); + + // this may fail, but we're not able to propagate exceptions here + TVwsViewId view; + AppUi()->GetActiveViewId( view ); + if ( view.iViewUid == Id() ) + { + TInt result; + TRAP( result, SetupStatusPaneL() ); + } + } + +void CNPRStoryListBoxView::SetupStatusPaneL() + { + // reset the context pane + TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); + CEikStatusPaneBase::TPaneCapabilities subPaneContext = + StatusPane()->PaneCapabilities( contextPaneUid ); + if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) + { + CAknContextPane* context = static_cast< CAknContextPane* > ( + StatusPane()->ControlL( contextPaneUid ) ); + context->SetPictureToDefaultL(); + } + + // setup the title pane + TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); + CEikStatusPaneBase::TPaneCapabilities subPaneTitle = + StatusPane()->PaneCapabilities( titlePaneUid ); + if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) + { + CAknTitlePane* title = static_cast< CAknTitlePane* >( + StatusPane()->ControlL( titlePaneUid ) ); + TResourceReader reader; + iEikonEnv->CreateResourceReaderLC( reader, R_NPRSTORY_LIST_BOX_TITLE_RESOURCE ); + title->SetFromResourceL( reader ); + CleanupStack::PopAndDestroy(); // reader internal state + } + } + +void CNPRStoryListBoxView::CleanupStatusPane() + { + } + +/** + * Creates the top-level container for the view. You may modify this method's + * contents and the CNPRStoryListBox::NewL() signature as needed to initialize the + * container, but the signature for this method is fixed. + * @return new initialized instance of CNPRStoryListBox + */ +CNPRStoryListBox* CNPRStoryListBoxView::CreateContainerL() + { + return CNPRStoryListBox::NewL( ClientRect(), NULL, this ); + } + diff -r 000000000000 -r 0049171ecffb src/NPRStoryXmlParser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NPRStoryXmlParser.cpp Fri Jul 24 08:46:02 2009 +0100 @@ -0,0 +1,269 @@ +/* + ============================================================================ + Name : NPRStoryXmlParser.cpp + Author : John Kern + + Copyright (c) 2009 Symbian Foundation Ltd + This component and the accompanying materials are made available + under the terms of the License "Eclipse Public License v1.0" + which accompanies this distribution, and is available + at the URL "http://www.eclipse.org/legal/epl-v10.html". + + Initial Contributors: + - Symbian Foundation Ltd - initial contribution + - Symsource + + Contributors: + - John Kern + - Symsource + + Description : Story xml parser + ============================================================================ + */ + +#include "NPRDocument.h" +#include "NPRStoryXmlParser.h" +#include "NPRStory.h" + +CNPRStoryXmlParser* CNPRStoryXmlParser::NewLC(RPointerArray* aStoryArray) + { + CNPRStoryXmlParser* self = new (ELeave) CNPRStoryXmlParser(aStoryArray); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CNPRStoryXmlParser* CNPRStoryXmlParser::NewL(RPointerArray* aStoryArray) + { + CNPRStoryXmlParser* self = CNPRStoryXmlParser::NewLC(aStoryArray); + CleanupStack::Pop(); // self; + return self; + } + +CNPRStoryXmlParser::CNPRStoryXmlParser(RPointerArray* aStoryArray) +:iStoryArray(aStoryArray) + { + // No implementation required + } + +CNPRStoryXmlParser::~CNPRStoryXmlParser() + { + delete iTagName; + } + + +void CNPRStoryXmlParser::ConstructL() + { + iState = ENPRNewsStateIdle; + } + +void CNPRStoryXmlParser::OnStartDocumentL( + const RDocumentParameters& /* aDocParam */, + TInt aErrorCode ) + { + User::LeaveIfError(aErrorCode); + } + +void CNPRStoryXmlParser::OnEndDocumentL(TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +HBufC* CNPRStoryXmlParser::Copy8To16LC(const TDesC8& aDes) + { + HBufC* buf16 = HBufC::NewLC(aDes.Length()); + buf16->Des().Copy(aDes); + return buf16; + } + +void CNPRStoryXmlParser::OnStartElementL( + const RTagInfo& aElement, + const RAttributeArray& aAttributes, + TInt aErrorCode ) + { + User::LeaveIfError(aErrorCode); + const TDesC8& tagName = aElement.LocalName().DesC(); + if (tagName.CompareF(_L8("story"))==0) + { + iStory = ETrue; + if(iTagName) + { + delete iTagName; + } + iState = ENPRNewsStateStory; + iCurrentStory = CNPRStory::NewL(); + // find the story Id attribute + TInt count = aAttributes.Count(); + for (TInt i = 0 ; i < count ; i++) + { + const RAttribute& attribute = aAttributes[i]; + const RTagInfo& nameInfo = attribute.Attribute(); + + const TDesC8& localName8 = nameInfo.LocalName().DesC(); + const TDesC8& value8 = attribute.Value().DesC(); + + HBufC* localName16 = Copy8To16LC(localName8); + HBufC* value16 = Copy8To16LC(value8); + if (localName16->CompareF(_L("id")) == 0 ) + { + TLex lex(value16->Des()); + TInt v = 0; + lex.Val(v); + iCurrentStory->SetStoryId( v ); + } + CleanupStack::PopAndDestroy(2); // value16 and localName16 + } + } + else if(iStory) + { + if(!iTagName && ((iState != ENPRNewsStateText) || (iState != ENPRNewsStateParagraph))) + { + iTagName = tagName.AllocL(); + } + + if (iTagName->CompareF(_L8("title"))==0 && iState == ENPRNewsStateStory) + { + iState = ENPRNewsStateTitle; + } + else if (iTagName->CompareF(_L8("teaser"))==0 && iState == ENPRNewsStateStory) + { + iState = ENPRNewsStateTeaser; + } + else if (iTagName->CompareF(_L8("thumbnail"))==0 && iState == ENPRNewsStateStory) + { + iState = ENPRNewsStateThumbnail; + } + else if (iTagName->CompareF(_L8("text"))== 0 && iState == ENPRNewsStateStory) + { + iState = ENPRNewsStateText; + } + else if (tagName.CompareF(_L8("paragraph"))== 0 && iTagName->CompareF(_L8("text"))==0) + { + iState = ENPRNewsStateParagraph; + } + else + { + iState = ENPRNewsStateIdle; + } + } + } + +void CNPRStoryXmlParser::OnEndElementL(const RTagInfo& aElement, TInt aErrorCode ) + { + User::LeaveIfError(aErrorCode); + const TDesC8& tagName = aElement.LocalName().DesC(); + + TBool result = EFalse; + + if (tagName.CompareF(_L8("story"))== 0 && iState == ENPRNewsStateStory) + { + iStory = EFalse; + iState = ENPRNewsStateIdle; + iStoryArray->AppendL(iCurrentStory); + iCurrentStory = NULL; + } + else if(iTagName) + {//TO DO we can have a switch here + if (iTagName->CompareF(tagName)== 0 && iState == ENPRNewsStateTitle) + { + result = ETrue; + } + else if (iTagName->CompareF(tagName)== 0 && iState == ENPRNewsStateTeaser) + { + result = ETrue; + } + else if (iTagName->CompareF(tagName)== 0 && iState == ENPRNewsStateThumbnail) + { + result = ETrue; + } + else if (iTagName->CompareF(tagName)== 0 && iState == ENPRNewsStateText) + { + result = ETrue; + } + else if (tagName.CompareF(_L8("paragraph"))== 0 && iTagName->CompareF(_L8("text"))==0) + { + iState = ENPRNewsStateText; + } + else if (iTagName->CompareF(tagName)== 0 && iState == ENPRNewsStateIdle) + { + result = ETrue; + } + } + + if(result) + { + if(iTagName) + { + delete iTagName; + iTagName = NULL; + } + iState = ENPRNewsStateStory; + } + } + +void CNPRStoryXmlParser::OnContentL(const TDesC8& aBytes, TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + + switch(iState) + { + case ENPRNewsStateTitle: + { + iCurrentStory->SetTitleL(aBytes); + break; + } + case ENPRNewsStateTeaser: + { + iCurrentStory->SetTeaserL(aBytes); + break; + } + case ENPRNewsStateParagraph: + { + iCurrentStory->SetTextL(aBytes); + break; + } + default: + iState = iState; // for debugging. + break; + } + } + +void CNPRStoryXmlParser::OnStartPrefixMappingL( + const RString& /* aPrefix */, + const RString& /* aUri */, + TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +void CNPRStoryXmlParser::OnEndPrefixMappingL(const RString& /* aPrefix */, TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +void CNPRStoryXmlParser::OnIgnorableWhiteSpaceL(const TDesC8& /* aBytes */, TInt /* aErrorCode*/) + { + } + +void CNPRStoryXmlParser::OnSkippedEntityL(const RString& /* aName */, TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +void CNPRStoryXmlParser::OnProcessingInstructionL( + const TDesC8& /* aTarget */ , + const TDesC8& /* aData */ , + TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +void CNPRStoryXmlParser::OnError(TInt aErrorCode) + { + User::LeaveIfError(aErrorCode); + } + +TAny* CNPRStoryXmlParser::GetExtendedInterface(const TInt32 /* aUid */) + { + return NULL; + } diff -r 000000000000 -r 0049171ecffb testData/pic1.jpg Binary file testData/pic1.jpg has changed diff -r 000000000000 -r 0049171ecffb testData/pic2.jpg Binary file testData/pic2.jpg has changed diff -r 000000000000 -r 0049171ecffb testData/pic3.jpg Binary file testData/pic3.jpg has changed diff -r 000000000000 -r 0049171ecffb testData/pic4.jpg Binary file testData/pic4.jpg has changed diff -r 000000000000 -r 0049171ecffb testData/pic5.jpg Binary file testData/pic5.jpg has changed diff -r 000000000000 -r 0049171ecffb testData/pic6.jpg Binary file testData/pic6.jpg has changed