S60平台:使用外部应用程序View

S60平台:使用外部应用程序View

1、        范围
本文描述了如何启动到外部应用程序View。首先介绍当你的程序被别的程序启动时,是如何创建View的。当你创建View或者使用外部程序View时,同样参考文中所述。
描述了View架构之后,在第三章提供了许多有用的UIDs,“这些UIDs是S60里面的重要应用程序”。

2、        S60 View架构的介绍
在S60平台,View架构被广泛的使用在应用程序开发中。一个GUI应用程序可以创建多个View和在每个View中显示不同的数据或者UI控件。每一个View有它自己的控件栈(control stack)。当view被创建的时候,该view的container和controls会被创建出来,同样,当创建别的view时,该view的container和controls也会被销毁。当激活一个view时,可以把一个消息ID和消息内容传递到需要创建的view里去。这种方法为你创建和使用一个已存在的应用程序提供了非常强悍的功能
2.1 View架构概述
        使用一般的Eikon GUI应用程序中的AppUi,创建container类相当于创建所有的controls。在view架构GUI程序中,创建一个view,它继承自AppUi里面的CAknView,AppUi继承自CAknViewAppUi,CAknViewAppUi在CAknAppUi里面添加了view管理的方法。激活和销毁一个view的处理是在view类里面。具体的函数是DoActiveL()和DoDeActiveL()。在这2个方法中,container类被创建和销毁。Container类依次的创建和销毁它包含的controls。
2.2 Views的切换
在应用程序里切换到一个view,可以使用AppUi里的方法ActivateLocalViewL(),该方法的参数是TUid,下面是一个view切换的例子
const TUid KDemo1ViewId = { 1 }; // UID of the first view
ActivateLocalViewL(KDemo1ViewId); // activate view 1
首先新的view被activate,然后前一个view被deactivate。这就允许进行快速的view切换。当deavtivate的时候,所有的controls,包括菜单对话框,都被销毁。
2.3 消息传送
ActivateLocalViewL()已经重载了含参数MessageUid和一个message。MessageUid是TUid类型,经常被特殊的view或者一个确定的功能使用。Messages是TDesC8的描述符,能够在2个views之间传递数据。下面是一个例子:
const TUid KViewUid= {1};
const TUid KCustomMessageUid= {2};
TBuf8<255> customMessage;
customMessage.Copy(_L8("Some data here"));
ActivateLocalViewL(KViewUid, KCustomMessageUid, customMessage);


2.4 DoActivateL和上一个View ID
在view类中,DoActivateL()的作用是创建container和处理传过来的messages。除此之外,还描述了上一个画面,DoActivateL()可以获得上一个画面的TVwsViewId。这个TVwsViewId可以使我们的程序回到原来的view(有或没有带message)这样对应用程序view非常有用。如果你的程序被另一个程序调用,当用户退出你的程序后,以前的view可以自动的还原。

2.5 DoDeActivateL
当另一个view已经activate,并且之前激活的view需要被关闭时,DoDeActivateL会被调用。这种逻辑可是加速view之间的切换。在DoDeActivateL被调用的这个view会被从栈中remove,并且view的container和它的controls也会被destroy。


2.6 使用其它应用程序的views
使用AppUi里的ActivateViewL()可以activate一个外部应用程序的view。ActivateViewL()的作用和ActivateLocalViewL()类似。唯一的区别是ActivateViewL()使用TVwsViewId做参数,而ActivateLocalViewL()使用TUid,TVwsViewId由应用程序UID和应用程序里的view UID组成。下面是一个相关的例子:
const TUid KGalleryUid = { 0x101f8599 };
CCoeAppUi::ActivateViewL(TVwsViewId(KGalleryUid, TUid::Uid(1)));
ActivateViewL() 已经重载了跟 ActivateLocalViewL() 相同的方法来传送 messages. 下面是一个相关的例子:
const TUid KCustomMessageUid= {2};
TBuf8<255> customMessage;
customMessage.Copy(_L8("Some data here"));
const TUid KGalleryUid = { 0x101f8599 };
CCoeAppUi::ActivateViewL(TVwsViewId(KGalleryUid, TUid::Uid(1)), KCustomMessageUid, customMessage);
当用户退出已经启动的应用程序,框架会自动调用ActivateViewL()来返回之前的view。在第三章给出了许多有用的应用程序UIDs,View UIDs,message UIDs和messages。


3、        S60核心应用程序的UIDs
这章列出了在应用程序中非常有用的应用程序UIDs,View UIDs,message UIDs和messages。
AppUidViewer例子可以被用来查找安装在设备上的应用程序和相关程序的UIDs。

3.1 S60  Web Browser
应用程序UID:0x10008D39 (S60 3rd Edition, Feature Pack 1 and later) 0x1020724D (S60 3rd Edition).
在S60 3rd Edition里面已经引入了S60的Web Browser,但是在S60 3rd Edition里面Services browser(见3.2节)仍然是默认的浏览器。在S60 3rd Edition, Feature Pack 1 the Web Browser 已经是默认的浏览器了。在S60 3rd Edition, Feature Pack 1里,The Services browser已经被卸载了,并且the Web Browser替代了它的UID。
3.1.1 根据指定的页面启动Web BrowSer
为了在S60 3rd Edition and later editions中启动the Web Browser并且自动打开指定的URL,应用程序必须具备SWEvent(准许生成或者捕获键盘以及笔输入事件)能力。注意S60 3rd Edition 和 later editions版本之间应用程序UIDs的不同。

RApaLsSession apaLsSession; const TUid KOSSBrowserUidValue = {0x10008D39}; // 0x1020724D on 3rd Edition!
HBufC* param = HBufC::NewLC(64); param->Des().Copy(_L("4 http://www.yahoo.com/"));
TUid id(KOSSBrowserUidValue); TApaTaskList taskList(CEikonEnv::Static()->WsSession()); TApaTask task = taskList.FindApp(id);
if(task.Exists()) { task.BringToForeground(); HBufC8* param8 = HBufC8::NewLC(param->Length()); param8->Des().Append(*param); task.SendMessage(TUid::Uid(0), *param8); // UID not used CleanupStack::PopAndDestroy(param8); }
else { if(!apaLsSession.Handle())
{ User::LeaveIfError(apaLsSession.Connect()); }
TThreadId thread; User::LeaveIfError(apaLsSession.StartDocument(*param, KOSSBrowserUidValue, thread));
apaLsSession.Close(); } CleanupStack::PopAndDestroy(param);
注意:如果browser正在加载URL,那么外部程序想要打开另外一个URl,将会提示err "Unable to retrieve"并且制定URL不会被load。
3.2  S60  Services Browser
应用程序UID:0x10008D39
在S60 3rd Edition 和更早的 releases 版本中 The Services XHTML browser是默认的浏览器。注意在一些早期的S60设备上the Services browser也被叫做Web。不要把它与Web Browser(见3.1节)混淆。
在S60 3rd Edition设备上有2个浏览器,Web Browser for S60被引入,但是the Services browser仍然是默认浏览器。
3.2.1 根据指定的页面启动Services BrowSer
由于使用ActivateViewL()不一定可以打开指定的页面,所以下面的例子使用别的方法根据指定的页面启动browser。
HBufC* param = HBufC::NewLC( 20 );
//param->Des().Copy( _L( "4 http://wap.yahoo.com/" ) );
param->Des().Copy( _L( "4 wap.yahoo.com/" ) );
// Wap browser's constants UID
const TInt KWmlBrowserUid = 0x10008D39;
TUid id( TUid::Uid( KWmlBrowserUid ) );
TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
TApaTask task = taskList.FindApp( id );
if ( task.Exists() )
{
HBufC8* param8 = HBufC8::NewLC( param->Length() );
param8->Des().Append( *param );
task.SendMessage( TUid::Uid( 0 ), *param8 ); // UID is
// not used
CleanupStack::PopAndDestroy();
}
else
{
RApaLsSession appArcSession;
User::LeaveIfError(appArcSession.Connect()); // connect to
// AppArc server
TThreadId id;
appArcSession.StartDocument( *param, TUid::Uid( KWmlBrowserUid ), id );
appArcSession.Close();
}
CleanupStack::PopAndDestroy(); // param
3.3 Messaging
应用程序UID:0x100058C5
View UIDs:
       



3.3 Messaging
Application UID: 0x100058C5
View UIDs:
&#1048707;0x01 // messaging应用程序的主画面
&#1048707;0x02 // 显示不同的文件
&#1048707;0x03 // 发送报告
3.3.1 messageing 文件夹的Message UIDs
建议在messaging应用程序view0x02中使用下面的值来标识不同的message folders。它们被定义在MSVSTD.HRH中。
KMsvGlobalInBoxIndexEntryIdValue // Inbox
KMsvGlobalOutBoxIndexEntryIdValue // Outbox
KMsvDraftEntryIdValue // Drafts
KMsvSentEntryIdValue // Sent

3.3.2 打开新的message窗口
使用ActivateViewL有可能不能打开一个窗口来写message。但是使用CSendAppUi可能会完成这个任务。这是一个很频繁的问题,所以在这里描述一下。
CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
CleanupStack::PushL(paraFormatLayer);
CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
CleanupStack::PushL(charFormatLayer);
CRichText* messageBodyContent = CRichText::NewL(paraFormatLayer, charFormatLayer);
CleanupStack::PushL(messageBodyContent);
messageBodyContent->InsertL(0, KSAEXTag);
// See CSendAppUi Class Reference in the SDK Help for other
// parameters.
iSendUi->CreateAndSendMessageL(KUidMsgTypeSMS, messageBodyContent);
CleanupStack::PopAndDestroy(3); // messageBodyContent,
// charFormatLayer,
// paraFormatLayer

3.4 联系人
应用程序UID:0x101f4cce
2个主要views的 View UIDs
&#1048707;0x01 // 联系人 view
&#1048707;0x02 // 群组 view

3.5 Log
应用程序UID:0x101f4cd5
下面的view UIDs可以使用:
&#1048707;1 // log's event list view in logs state (Call register/Call Timers/Call Costs/GPRS counter)
&#1048707;6 // event list view in missed calls state
&#1048707;7 // event list view in received calls state (from S60 3rd Edition onwards)
&#1048707;8 // event list view in dialed calls state
3.6 Profiles(个人信息)
应用程序UID:0x100058F8
View UIDs:
&#1048707;0x01 // main view
&#1048707;0x02 // settings view

3.6 Calendar(日历)

应用程序UID: 0x10005901
View UIDs:
&#1048707;0x01 // Month View
&#1048707;0x02 // Week View
&#1048707;0x03 // Day View
&#1048707;0x04 // To-Do View (from S60 3rd Edition onwards)

这个程序不使用 messages。
If the calendar application is not running, it will open to its default view, no matter which view UID is supplied. The desired view will briefly glimpse before the calendar switches to its default view. If the calendar application is running, the desired view is displayed.
In S60 1st and 2nd Edition To-Do was a separate application (see Section 3.8) so there is no To-Do view in the Calendar application.
3.8 To-Do

应用程序 UID: 0x10005900 (S60 1st and 2nd Edition)
这个程序不使用 view UIDs,message UIDs, or messages。
From S60 3rd Edition onwards, To-Do is moved as a view in Calendar application (see Section 3.7).
3.9 时钟

应用程序 UID: 0x10005903
View UIDs:
&#1048707;0x03 // Local time view
&#1048707;0x04 // World time view

3.10 录音

应用程序 UID: 0x100058CA
View UIDs:
&#1048707;0x01 // recorder

Message UIDs for recorder view 0x01:
&#1048707;0x01 // default view
&#1048707;0x02 // recording immediately
&#1048707;0x03 // recording on one button press

If your message length is larger than 0, the application converts the 8-bit descriptor to a 16-bit one without altering data.
S60 1st Edition included also a filelist view.
View UIDs:
&#1048707;0x01 // filelist
&#1048707;0x02 // recorder

Message UIDs for recorder view 0x02 (some difference compared to newer releases):
&#1048707;0x00 // play and record available on demand
&#1048707;0x01 // recording immediately
&#1048707;0x02 // recording on one button press
&#1048707;0x03 // player option only

3.11 转换

应用程序 UID: 0x101F4668
这个程序不使用 view UIDs,message UIDs, or messages。
3.12 计算器

应用程序 UID: 0x10005902
这个程序不使用 view UIDs,message UIDs, or messages。
3.13 Notes

应用程序 UID: 0x1000599d
这个程序不使用 view UIDs,message UIDs, or messages。
3.14 文件管理

应用程序 UID: 0x101f84eb
View UIDs:
&#1048707;0x01 // Default view phone memory
&#1048707;0x02 // Default view memory card

3.15 Gallery

应用程序 UID:
&#1048707;0x101f8599 (from S60 2nd Edition, Feature Pack 2 onwards)
&#1048707;0x101f4d8F (S60 2nd Edition and S60 2nd Edition, Feature Pack 1) View UIDs:
&#1048707;0x01 // the default view

S60 1st Edition版本已经有Photos application取代了Gallery:
应用程序 UID: 0x101F4CD1
View UIDs:
&#1048707;0x01 // Imagelist view – the default view
&#1048707;0x03 // Messaging Picture Grid view
&#1048707;0x04 // Messaging Picture view

3.16 相机
根据cameras数量,这里有2个不同的UIDs
应用程序 UID:
• 101f857a (devices with only one camera)
• 101ffa86 (devices with two cameras)
View UIDs:
&#1048707;0x01 // image mode
&#1048707;0x03 // video mode

在 S60 1st Edition and S60 2nd Edition, 照相 和 视频录制是不同的应用程序, 照相的UID 是 0x1000593F.
View UIDs:
&#1048707;0x01 // standby mode
&#1048707;0x02 // viewfinder mode
&#1048707;0x04 // Name base and Quality settings

所有view不使用message UIDs, or messages。
视频录制应用程序UID: 0x101fa14a (S60 1st Edition and S60 2nd Edition)
3.17 Music Player

应用程序 UID:
&#1048707;0x102072c3 (from S60 3rd Edition onwards)
&#1048707;0x6c5b9d2 (S60 2nd Edition)

这个程序不使用 view UIDs,message UIDs, or messages。
3.18 RealPlayer

应用程序 UID: 0x10005a3e
View UIDs:
&#1048707;0x01 // Default view
&#1048707;0x02 // Media currently playing

3.19 蓝牙

应用程序 UID: 0x10005951
View UIDs:
&#1048707;0x01 // Main view
&#1048707;0x02 // Paired devices view

这个程序不使用messages。
3.20 红外

应用程序UID: 0x1000594d
这个程序不使用 view UIDs,message UIDs, or messages。

3.21 设置

应用程序 UID: 0x100058ec
View UIDs:
&#1048707;0x01 // Default view
&#1048707;0x02 // Phone settings main view
&#1048707;0x03 // Phone settings general view
&#1048707;0x04 // Phone settings standby mode view
&#1048707;0x05 // Phone settings display view
&#1048707;0x09 // Headset settings
&#1048707;0x0A // Date and time settings
&#1048707;0x0B // Enhancement settings loopset view
&#1048707;0x10 // Security settings

3.22 帮助

应用程序UID: 0x10005234
View UIDs:
&#1048707;0x01 // Help category list view
&#1048707;0x04 // Search by keyword view

3.23 主题
应用程序 UID: 0x10005a32
这个程序不使用 view UIDs,message UIDs, or messages。
原文地址:https://www.cnblogs.com/zziss/p/1865236.html