【问题标题】:understanding RProperty IPC communication了解 Property IPC 通信
【发布时间】:2012-03-23 01:14:31
【问题描述】:

我正在研究这个source base。基本上,这是 Symbian 第 3 版的 Anim 服务器客户端,用于抓取输入事件而不以可靠的方式使用它们。

如果您发现this line of the server,这里基本上是在设置 RProperty 值(显然是增加计数器);似乎没有对输入进行实际处理。

this client line内部,客户端本应接收通知数据,但它只调用了Attach。

我的understanding is that Attach只需要调用一次,但在客户端并不清楚每次服务器设置RProperty时触发什么事件

客户端应该如何(以及在​​哪里)访问 RProperty 值?

【问题讨论】:

    标签: c++ ipc symbian


    【解决方案1】:

    Attach 之后,客户端将在某个地方将Subscribe 传递给它传递TRequestStatus 引用的属性。当异步事件发生时(在您的情况下,属性已更改),服务器将通过内核向请求状态属性发出信号。如果您的示例源代码以正确的方式实现,您会发现一个活动对象(AO;CActive 派生类)悬而未决,并且此 AO 的iStatus 将被传递给 RProperty API。在这种情况下,AO 的RunL 函数将在属性更改时被调用。

    在 Symbian 中了解活动对象框架非常重要,但实际上很少有人这样做。不幸的是,我没有在网上找到很好的描述(在 Symbian OS Internals 书中对它们进行了很好的解释),但this page 至少给了你一个简单的例子。

    示例

    CActive 的 CMyActive 子类的 ConstructL 中:

    CKeyEventsClient* iClient;
    RProperty         iProperty;
    // ...
    
    void CMyActive::ConstructL() 
        {
        RProcess myProcess;
        TSecureId propertyCategory = myProcess.SecureId();
            // avoid interference with other properties by defining the category
            // as a secure ID of your process (perhaps it's the only allowed value)
        TUint propertyKey = 1; // whatever you want
    
        iClient = CKeyEventsClient::NewL(propertyCategory, propertyKey, ...);
        iClient->OpenNotificationPropertyL(&iProperty);
    
        // ...
    
        CActiveScheduler::Add(this);
        iProperty.Subscribe(iStatus);
        SetActive();
        }
    

    您的 RunL 将在属性更改时被调用:

    void CMyActive::RunL()
        {
        if (iStatus.Int() != KErrCancel) User::LeaveIfError(iStatus.Int());
             // forward the error to RunError
    
        // "To ensure that the subscriber does not miss updates, it should
        // re-issue a subscription request before retrieving the current value 
        // and acting on it." (from docs)
        iProperty.Subscribe(iStatus);
    
        TInt value; // this type is passed to RProperty::Define() in the client
        TInt err = iProperty.Get(value);
        if (err != KErrNotFound) User::LeaveIfError(err);
    
        SetActive();
        }
    

    【讨论】:

    • 是的,在那个源项目中,Subscribe 没有在任何地方调用,所以它似乎还没有按原样运行。感谢您提供的示例,将在那里查看它们是否帮助我访问属性值。因此,您认为该实现中缺少什么(除了订阅)能够通过 RProperty 接收通信?
    • 现在我看到您的 DLL 必须具有 ProtServ 功能。如果您打算发布一次您的软件,诺基亚可能会有一些疑问,您为什么需要它...developer.nokia.com/Community/Wiki/…
    • 是的,事实上我需要CAPABILITY PowerMgmt ProtServ ReadDeviceData WriteDeviceData,因为这是第三版动画 dll 的新要求。感谢您的示例
    猜你喜欢
    • 1970-01-01
    • 2012-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-05
    • 2011-08-25
    • 1970-01-01
    • 2015-12-25
    相关资源
    最近更新 更多