Attach
の後に、クライアントはの参照を渡すプロパティのどこかでSubscribe
になります。非同期イベントが発生したとき(カーネルのプロパティが変更された場合)、サーバはカーネル経由でリクエストステータスプロパティを通知します。サンプルソースコードが正しい方法で実装されている場合は、アクティブオブジェクト(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を介して通信を受信できるようにその実装(サブスクリプション以外)に何が欠けている? – lurscher
私はいくつかのドラフトの例を追加しました。 – MrTJ
これでDLL用のProtServ機能が必要になることがわかりました。ソフトウェアを一度リリースする予定の場合、Nokiaにはなぜそれが必要なのかという質問があるかもしれません... http://www.developer.nokia.com/Community/Wiki/Capabilities_%28Symbian_Signed%29/ProtServ_Capability – MrTJ