2012-03-21 56 views
0

我正在研究這個source base。基本上,這是Symbian 3rd版的Anim服務器客戶端,用於抓取輸入事件而不會以可靠的方式使用它們。瞭解RProperty IPC通信

如果你發現this line of the server,這裏它基本上是設置RProperty的值(顯然是增加計數器)。似乎沒有對輸入進行實際處理。

內部this client line,客戶端應該是接收通知數據,但它只調用附加。

understanding is that Attach只需要被調用一次,而不是在什麼事件被觸發每個服務器設置RProperty

如何(在哪裏)時間客戶明確的是應該訪問RProperty值客戶端?

回答

1

Attach之後,客戶將在某處Subscribe到達其通過TRequestStatus參考的屬性。當異步事件發生時,服務器將通過內核通知內核的請求狀態屬性(在您的情況下屬性發生變化)。如果您的示例源代碼以正確的方式實現,您會發現掛起的活動對象(AO; CActive派生類),此AO的iStatus將傳遞給RProperty API。在這種情況下,AO屬性的RunL函數將在屬性更改時調用。

在Symbian中,瞭解活動對象框架是非常重要的,而且實際上很少有人這樣做。不幸的是,我沒有在網上找到很好的描述(他們在Symbian OS Internals書中解釋得很好),但至少可以給你一個快速的例子。

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(); 
    } 
+0

是啊,在這源項目訂閱沒有被調用到任何地方,所以它看起來不起作用。謝謝你的例子,看看那裏,看看他們是否可以幫助我訪問屬性值。所以你認爲在那個實現(除了訂閱)中缺少什麼能夠通過RProperty接收通信? – lurscher 2012-03-22 16:29:01

+0

我添加了一些草案示例。 – MrTJ 2012-03-22 17:15:33

+0

現在我發現你必須爲你的DLL提供ProtServ功能。如果您計劃一旦發佈軟件,諾基亞可能會有一些問題,您爲什麼需要它... http://www.developer.nokia.com/Community/Wiki/Capabilities_%28Symbian_Signed%29/ProtServ_Capability – MrTJ 2012-03-22 17:20:52