/*
============================================================================
Name : QiQiWeatherAppUi.cpp
Author : Richie Chyi
Copyright : Copyright?2008
Description : CQiQiWeatherAppUi implementation
============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <aknmessagequerydialog.h>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <f32file.h>
#include <s32file.h>
#include <hlplch.h>
#include <aknnavide.h> // For CAknNavigationDecorator
#include <BARSREAD.H> // For TResourceReader
#include <eikspane.h> // For CEikStatusPane
#include <aknnavi.h> // For CAknNavigationControlContainer
#include <akntabgrp.h> // For CAknTabGroup
#include <APGTASK.H> // For TApaTaskList
#include <QiQiWeather_0xE6E51F33.rsg>
#include "QiQiWeather_0xE6E51F33.hlp.hrh"
#include "QiQiWeather.hrh"
#include "QiQiWeather.pan"
#include "QiQiWeatherApplication.h"
#include "QiQiWeatherAppUi.h"
#include "QiQiWeatherAppView.h"
#include "WeatherShow.h"
#include "SettingDlg.h"
#include "Setting.h"
_LIT(KFileName, "C:\\private\\E6E51F33\\QiQiWeather.txt");
_LIT(KText, "Hello World!");
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CQiQiWeatherAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CQiQiWeatherAppUi::ConstructL()
{
// Initialise app UI with standard value.
BaseConstructL(CAknAppUi::EAknEnableSkin);
//SetHidden(ETrue);
//CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront);
// Create view object
iAppView = CQiQiWeatherAppView::NewL(this, ClientRect() );
iPeriodic = CPeriodic::NewL(CActive::EPriorityStandard);
iPeriodic->Start(TTimeIntervalMicroSeconds32(KDelay),
TTimeIntervalMicroSeconds32(KInterval),
TCallBack(CQiQiWeatherAppUi::ShowWeatherInfoL, this));
// Create Setting file
CSetting* setting = CSetting::NewLC();
// 设置默认值
if (!setting->IsSaved())
{
// 根据当前时间设定特定值,保证第一次运行程序时,立马预报天气
TTime currentTime;
currentTime.HomeTime();
TDateTime dateTime = currentTime.DateTime();
setting->SetCityIndex(0);
setting->SetHour(dateTime.Hour());
setting->SetMinute(dateTime.Minute() - 10); // 设定当前时间前十秒
setting->SaveToFileL();
}
CleanupStack::PopAndDestroy(setting);
// Create Pane Tabs
TUid naviPaneUid;
naviPaneUid.iUid = EEikStatusPaneUidNavi;
CEikStatusPane* statusPane = StatusPane();
CEikStatusPaneBase::TPaneCapabilities subPane =
statusPane->PaneCapabilities(naviPaneUid);
// if we can access the navigation pane
if (subPane.IsPresent() && subPane.IsAppOwned())
{
CAknNavigationControlContainer* naviPane =
(CAknNavigationControlContainer *) statusPane->ControlL(naviPaneUid);
// read the tab group resource
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, R_NAVIGATIONPANE_TABGROUP);
if (iNaviDecorator)
{
delete iNaviDecorator;
iNaviDecorator = NULL;
}
// set the navigation pane tab group
iNaviDecorator = naviPane->CreateTabGroupL(reader);
CleanupStack::PopAndDestroy(); // pushed by CreateResourceReaderLC
naviPane->PushL(*iNaviDecorator);
}
// Create a file to write the text to
TInt err = CCoeEnv::Static()->FsSession().MkDirAll(KFileName);
if ( (KErrNone != err) && (KErrAlreadyExists != err))
{
return;
}
RFile file;
err = file.Replace(CCoeEnv::Static()->FsSession(), KFileName, EFileWrite);
CleanupClosePushL(file);
if (KErrNone != err)
{
CleanupStack::PopAndDestroy(1); // file
return;
}
RFileWriteStream outputFileStream(file);
CleanupClosePushL(outputFileStream);
outputFileStream << KText;
CleanupStack::PopAndDestroy(2); // outputFileStream, file
}
// -----------------------------------------------------------------------------
// CQiQiWeatherAppUi::CQiQiWeatherAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CQiQiWeatherAppUi::CQiQiWeatherAppUi()
:iNaviDecorator(NULL), iCurrentTabIndex(0)
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CQiQiWeatherAppUi::~CQiQiWeatherAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CQiQiWeatherAppUi::~CQiQiWeatherAppUi()
{
if (iAppView)
{
delete iAppView;
iAppView = NULL;
}
if(iPeriodic->IsActive())
{
iPeriodic->Cancel();
}
delete iPeriodic;
iPeriodic = NULL;
if (iNaviDecorator)
{
delete iNaviDecorator;
iNaviDecorator = NULL;
}
iWeatherDetails.Reset();
}
// -----------------------------------------------------------------------------
// CQiQiWeatherAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CQiQiWeatherAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case ESetting:
{
if (CSettingDlg::RunDlgLD())
{
// TODO:...
}
}
break;
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
SetHidden(ETrue);
//CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront);
break;
case EHelp:
{
CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL();
HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
}
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;
case EHidden:
{
//SetHidden(ETrue);
//CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront);
// 使用上面的隐藏,再点击图标后,会创建一个新进程实例,而不是将已存在进程调至前台
TApaTask task(CEikonEnv::Static()->WsSession());
task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
task.SendToBackground();
}
break;
case ERefresh:
{
CWeatherShow* weatherShow = CWeatherShow::NewLC();
weatherShow->ShowWeatherL();
CleanupStack::PopAndDestroy(weatherShow);
}
break;
default:
Panic(EQiQiWeatherUi);
break;
}
}
// -----------------------------------------------------------------------------
// Called by the framework when the application status pane
// size is changed. Passes the new client rectangle to the
// AppView
// -----------------------------------------------------------------------------
//
void CQiQiWeatherAppUi::HandleStatusPaneSizeChange()
{
iAppView->SetRect(ClientRect() );
}
CArrayFix<TCoeHelpContext>* CQiQiWeatherAppUi::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.
CArrayFixFlat<TCoeHelpContext>* array = new(ELeave)CArrayFixFlat<TCoeHelpContext>(1);
CleanupStack::PushL(arra
symbian下运行的天气播报
需积分: 0 146 浏览量
2008-09-12
14:59:32
上传
评论
收藏 116KB RAR 举报
gaogao1041
- 粉丝: 13
- 资源: 18
最新资源
- 最通俗易懂的 MongoDB 非结构化文档存储数据库教程.zip
- 以mongodb为数据库的订单物流小项目.zip
- 腾讯云-mongodb数据库, 项目部署.zip
- 腾讯 APIJSON 的 MongoDB 数据库插件.zip
- 理解非关系型数据库和关系型数据库的区别.zip
- 操作简单的Mongodb网页web管理工具,基于Spring Boot2.0支持mongodb集群.zip
- tms-mongodb-web,提供访问mongodb数据的REST API和可灵活扩展的mongodb web 客户端.zip
- SpringBoot整合mongodb学习MongoTemplate和MongoRepository两种方式CRUD使用.zip
- SpringBoot整合MongoDB实现对数据库的CRUD小demo.zip
- Python操作MongoDB数据库的基本一些操作 .zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0