/*
* Copyright (c) 2007,苏州丰达
* All rights reserved.
* 版权所有(C)2007-2008 苏州丰达
* 公司地址:中国,江苏省苏州市
* 网址:http://www.
*
* 文件名称:CM3UIQ2AppUi.cpp
* 摘 要:
*
* 产品版本:彩视 1.0
*
* 作 者:xxxx
* 创建日期:xxxxx
* 负责人:xxxxx
*
* 修改者:司治国
* 修改日期:2008.1.17
*
* 编译器或环境等描述:uiqsdk2.1
* 适用于VC2003+symbian 7.x的环境开发。
*
**/
#include <qikon.hrh>
#include <M3UIQ2.rsg>
#include <qikSendAs.h>
#include <QMappExtInterface.h>
#include <cntuifinddlg.h>
////
#include <commdb.h>
#include <AgentClient.h>
#include <cdbstore.h>
#include <cdbcols.h>
////
#include <txtetext.h>
#include <eikchlst.h>
#include <QikMediaFileFolderUtils.h>
#include "M3UIQ2App.h"
#include "M3UIQ2Appui.h"
#include "M3UIQ2AppView.h"
#include "M3UIQ2.hrh"
#include "RLog.h"
const TInt KMaxReqestLength = 1024;
/**
* 两段构造
**/
void CM3UIQ2AppUi::ConstructL()
{
BaseConstructL();
//ReadIniFile();
//用户信息结构
iCurUser = new(ELeave) TUserStruct;
iCurUser->isLogon = EFalse;
// iCurUser->iNick.SetLength(0);
iCurUser->iName.Copy(_L("keper"));
iCurUser->iPassword.SetLength(0);
//主视图
iAppView = new (ELeave) CM3UIQ2AppView(iCurUser, this);
iAppView->ConstructL(ClientRect());
AddToStackL(*iAppView, iAppView);
RegisterViewL(*iAppView);
//手机空间view
iStorageView = CMobileStorageView::NewL(ClientRect());
AddToStackL(*iStorageView, iStorageView);
RegisterViewL(*iStorageView);
RLog::Log(_L("appui 75"));
//发送视图
iSendView = CM3UIQSendView::NewL(ClientRect(), NULL);
AddToStackL(*iSendView, iSendView);
RegisterViewL(*iSendView);
//设置默认视图
SetDefaultViewL(*iAppView);
//call exist iap
CCommsDatabase* CommDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(CommDb);
CCommsDbTableView* tableIAP = CommDb->OpenTableLC(TPtrC(IAP));
if (tableIAP->GotoFirstRecord()==KErrNone)
{
do
{
TUint32 uid(0);
tableIAP->ReadUintL(TPtrC(COMMDB_ID),uid);
TBuf<256> name;
tableIAP->ReadTextL(TPtrC(COMMDB_NAME),name);
descflat = new (ELeave) CDesCArrayFlat(4);
descflat->AppendL(name);
TBuf<32> cmwap;
cmwap.Append(_L("cmwap"));
name.Trim();
if (name.Compare(cmwap) == 0)
{
CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
//pref.iRanking = 1;
pref.iDirection = ECommDbConnectionDirectionOutgoing;
pref.iDialogPref = ECommDbDialogPrefDoNotPrompt;
pref.iBearer.iBearerSet = ECommDbBearerGPRS;
pref.iBearer.iIapId = uid;
break;
}
//CStoreableOverrideSettings* cs = CStoreableOverrideSettings::NewL(CStoreableOverrideSettings::EParamListFull);
//cs->SetConnectionPreferenceOverride(pref);
//RGenericAgent m_connMgr;
//m_connMgr.Open();
//TRequestStatus istatus;
//m_connMgr.StartOutgoing(*cs,istatus);
}
while(tableIAP->GotoNextRecord() == KErrNone);
}
CleanupStack::PopAndDestroy(tableIAP);
CleanupStack::PopAndDestroy(CommDb);
//上传文件核心类
iUserUID = ReadUserUID();
TInt UID = (iUserUID < 0) ? 0: iUserUID;
iHttpEngine = CHTTPClientEngine::NewL(*this);
iHttpEngine->LunachRegister(UID);
iCurrentAction = CHTTPClientEngine::ERegister;
//消息发送引擎
iMessageEngline = CMessageEngine::NewL(iAppView);
CM3UIQ2SetingDlg* iSetdialog = CM3UIQ2SetingDlg::NewL();
iSetdialog->ReadProperty();
RArray<TInt> *array = iSetdialog->GetProperty();
if (array && array->Count() >= 3)
{
iIsShow = (*array)[0];
iCatche = (*array)[2];
}
delete iSetdialog;
iSetdialog = NULL;
}
/**
* 析构函数,释放内存
**/
CM3UIQ2AppUi::~CM3UIQ2AppUi()
{
delete iCurUser;
if (iHttpEngine)
{
delete iHttpEngine;
iHttpEngine = NULL;
}
if (iMessageEngline)
{
delete iMessageEngline;
iMessageEngline = NULL;
}
if (iAppView)
{
RemoveFromStack(iAppView);
delete iAppView;
}
if (iStorageView)
{
RemoveFromStack(iStorageView);
delete iStorageView;
}
if (iSendView)
{
RemoveFromStack(iSendView);
delete iSendView;
}
if (iSPID)
{
delete iSPID;
iSPID = NULL;
}
if (iSMSContent)
{
delete iSMSContent;
iSMSContent = NULL;
}
if (iServerURL)
{
delete iServerURL;
iServerURL = NULL;
}
if (dialog)
{
delete dialog;
dialog = NULL;
}
}
TKeyResponse CM3UIQ2AppUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
/**
* 菜单事件
* @param aCommand 菜单命令
**/
void CM3UIQ2AppUi::HandleCommandL(TInt aCommand)
{
// if (!iIsLogined)
// {
// TBuf<32> infoTitle;
// CEikonEnv::Static()->ReadResource(infoTitle, R_STR_JUSTHANDLE_LABEL);
// iEikonEnv->InfoMsg(infoTitle);
// }
switch (aCommand)
{
case EEikCmdExit:
{
Exit();
break;
}
case ECmdM3UIQ2ContineUpload://处理续传事件
{
_LIT(KAUPLOAD,"upload?%d@%d@%d@%d");//pos,fid,aid,uid
TBuf<64> continueUrl;
continueUrl.Format(KAUPLOAD, iPos, iFid, iAID, iUserUID);//upload?1024@10842@2@2444
iCurrentAction = CHTTPClientEngine::EGeneral;
iHttpEngine->ContinueUpload(continueUrl.Alloc());
break;
}
case ECmdM3UIQ2SystemSeting://处理系统设置
{
//call exist iap
CCommsDatabase* CommDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
CleanupStack::PushL(CommDb);
CCommsDbTableView* tableIAP = CommDb->OpenTableLC(TPtrC(IAP));
if (tableIAP->GotoFirstRecord()==KErrNone)
{
descflat = new (ELeave) CDesCArrayFlat(4);
do
{
TUint32 uid(0);
tableIAP->ReadUintL(TPtrC(COMMDB_ID),uid);
TBuf<256> name;
tableIAP->ReadTextL(TPtrC(COMMDB_NAME),name);
descflat->AppendL(name);
RLog::Log(name);
// CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
// pref.iRanking = 1;
// pref.iDirection = ECommDbConnectionDirectionOutgoing;
// pref.iDialogPref = ECommDbDialogPrefDoNotPrompt;
// pref.iBearer.iBearerSet = ECommDbBearerGPRS;
// pref.iBearer.iIapId = uid;
}
while(tableIAP->GotoNextRecord() == KErrNone);
}
CleanupStack::PopAndDestroy(tableIAP);
CleanupStack::PopAndDestroy(CommDb);
//显示设置对话框
CM3UIQ2SetingDlg* iSetdialog = CM3UIQ2SetingDlg::NewL();
iSetdialog->ExecuteLD(R_CONTROLS3_DIALOG);
// RGenericAgent netAgent;
// if (netAgent.Open() == KErrNone)
// {
// CleanupClosePushL(netAgent);
// CCommsDatabase* db = CCommsDatabase::NewL();
// CleanupStack::PushL(db);
// CCommsDbConnectionPrefTableView* view;
// view = db->OpenConnectionPrefTableViewOnRankLC(ECommDbConnectionDirectionOutgoing,1);
// view->GotoFirstRecord();
// view->UpdateDialogPrefL(ECommDbDialogPrefDoNotPrompt);
// TRequestStatus status;
// netAgent.StartOutgoing(status);
// User::WaitForRequest(status);
// CleanupStack::PopAndDestroy(3); // view, db, netAgent
// }
break;
}
case ECmdM3UIQ2CheckUpdate://处理检查更新
{
iHttpEngine->CheckUpdate();
iCurrentAction = CHTTPClientEngine::ECheckUpdate;
break;
}
case ECmdM3UIQ2FileInfo://手机空间
{
TDesC* fileName = iStorageView->FileName();
TInt fsize = iStorageView->GetM3Directory()->GetFileSizeL(*fileName);
TInt pos = fileName->LocateReverse('\\');
TPtrC fname = fileName->Mid(pos + 1);//文件的文件名
TBuf<256> info;
TBuf<32> temp;
info.Append(fname);
info.Append(_L("\r\n"));
CEikonEnv::Static()->ReadResource(temp, R_STR_SIZE);
info.Append(temp);
info.AppendNum((fsize/1024 == 0) ? 1 : fsize / 1024);
info.Append(_L(