00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "CSummaryScreenUI.h"
00018 #include "CWeatherReportWatcher.h"
00019 #include "SummaryScreenLog.h"
00020
00021 _LIT(KNewLine, "\n");
00022
00023 CSummaryScreenUI* CSummaryScreenUI::NewLC(CConsoleBase& aConsole)
00024 {
00025 CSummaryScreenUI* self = new (ELeave) CSummaryScreenUI(aConsole);
00026 CleanupStack::PushL(self);
00027 self->ConstructL();
00028 CActiveScheduler::Add(self);
00029 return self;
00030 }
00031
00032 void CSummaryScreenUI::ConstructL()
00033 {
00034 iFs.Connect();
00035
00036
00037
00038
00039
00040 iMessageSummaryEngine = CMessageSummaryEngine::NewL(*this);
00041 }
00042
00043 void CSummaryScreenUI::StartL()
00044 {
00045 LOG(">> CSummaryScreenUI::StartL()");
00046
00047 iStatus = KRequestPending;
00048
00049 iMessageSummaryEngine->StartL();
00050
00051 SetActive();
00052
00053 CActiveScheduler::Start();
00054
00055 LOG("<< CSummaryScreenUI::StartL()");
00056 }
00057
00058
00059 CSummaryScreenUI::~CSummaryScreenUI()
00060 {
00061 delete iMessageSummaryEngine;
00062 delete iWeatherReportWatcher;
00063 iFs.Close();
00064 }
00065
00066 CSummaryScreenUI::CSummaryScreenUI(CConsoleBase& aConsole) : CActive(EPriorityStandard), iConsole(aConsole)
00067 {
00068 }
00069
00070 void CSummaryScreenUI::WriteSummaries(const CMessageSummaryGenerator& aSummaryGenerator)
00071 {
00072
00073 const RArray<TMessageSummary>& messageSummaries = aSummaryGenerator.MessageSummaries();
00074
00075 TInt index;
00076 TInt messageCount = messageSummaries.Count();
00077
00078
00079 for (index = 0; index < messageCount; index++)
00080 {
00081 iConsole.Printf(messageSummaries[index].iFrom);
00082 iConsole.SetPos(KSubjectIndent);
00083 iConsole.Printf(messageSummaries[index].iSummaryText);
00084 iConsole.Printf(KNewLine);
00085 }
00086 }
00087
00088 void CSummaryScreenUI::Refresh()
00089 {
00090 _LIT(KSmsMessageTitle, "SMS Messages:\n\n");
00091 _LIT(KEmailMessageTitle, "Email Messages:\n\n");
00092 _LIT(KWeatherReportTitle, "Weather Report:\n\n");
00093
00094 _LIT(KNoWeatherReport, "None\n");
00095 _LIT(KSunnyWeatherReport, "Sun\n");
00096 _LIT(KCloudyWeatherReport, "Cloud\n");
00097 _LIT(KRainyWeatherReport, "Rain\n");
00098
00099 iConsole.ClearScreen();
00100
00101
00102 if (iWeatherReportWatcher == NULL)
00103 iWeatherReportWatcher = CWeatherReportWatcher::NewL(*this, iFs);
00104
00105
00106 iConsole.Printf(KSmsMessageTitle);
00107 WriteSummaries(iMessageSummaryEngine->SmsSummary());
00108
00109
00110 const CMessageSummaryGenerator* emailSummaries = iMessageSummaryEngine->EmailSummary();
00111 if (emailSummaries != NULL)
00112 {
00113 iConsole.Printf(KNewLine);
00114 iConsole.Printf(KEmailMessageTitle);
00115 WriteSummaries(*emailSummaries);
00116 }
00117
00118 iConsole.Printf(KNewLine);
00119 iConsole.Printf(KWeatherReportTitle);
00120
00121 switch (iWeatherReport)
00122 {
00123 case ENone:
00124 iConsole.Printf(KNoWeatherReport);
00125 break;
00126
00127 case ESunny:
00128 iConsole.Printf(KSunnyWeatherReport);
00129 break;
00130
00131 case ECloudy:
00132 iConsole.Printf(KCloudyWeatherReport);
00133 break;
00134
00135 case ERainy:
00136 iConsole.Printf(KRainyWeatherReport);
00137 break;
00138
00139 default:
00140 break;
00141 }
00142 }
00143
00144 void CSummaryScreenUI::DoCancel()
00145 {
00146 }
00147
00148 void CSummaryScreenUI::RunL()
00149 {
00150
00151 }
00152
00153
00154 void CSummaryScreenUI::NewWeatherReport(MWeatherReportObserver::TWeatherReport aWeatherReport)
00155 {
00156 iWeatherReport = aWeatherReport;
00157 Refresh();
00158 }
00159