Symbian3/PDK/Source/GUID-DCB8CA27-F64F-4B78-831D-F88B1AD7E38B.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Fri, 22 Jan 2010 18:26:19 +0000
changeset 1 25a17d01db0c
child 3 46218c8b8afa
permissions -rw-r--r--
Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-DCB8CA27-F64F-4B78-831D-F88B1AD7E38B" xml:lang="en"><title>Create
the client class</title><prolog><metadata><keywords/></metadata></prolog><taskbody>
<context>       <p>Create the client-side service support class, derived from <codeph>REikAppServiceBase</codeph>, <codeph>RApaAppServiceBase</codeph>, or a suitable System-GUI specialization of this class. This will have the
following responsibilities:</p> <ul>
<li><p>Implementing the client API </p></li>
<li><p>Organizing calls to and from the server over IPC</p></li>
<li><p>Any necessary security checks on the server. For example, restricting
the data sent to a server having particular capabilities.</p></li>
<li><p>Parameter checking from the server. Parameters returned from the server
application must be checked to ensure that they are valid.</p></li>
<li><p>Time-out support for IPC calls to the server.</p></li>
</ul><p>The reason for these checks is that the client cannot be sure that
the server application is using the appropriate server-side service support
classes and may instead be trying to weaken the system by implementing the
IPC handling itself.</p><p>This example shows the client interface for a chat
service implemented in two parts. The active object class <codeph>CChatter</codeph> is
the main client interface. It uses a class <codeph>RInterAppChat</codeph>,
derived from <codeph>REikAppServiceBase</codeph>, which handles the client-side
IPC for the chat service. </p><codeblock xml:space="preserve">class RInterAppChat : public REikAppServiceBase
    {
    public:
        TInt Send(const TDesC&amp; aMessage);
        void Receive(TRequestStatus&amp; aStatus, TDes&amp; aMessage);
        void CancelReceive();
    private:
        TUid ServiceUid() const;
    };
class MChatterReceiver
    {
    public:
        virtual void Receive(const TDesC&amp;) = 0;
    };
class CChatter : public CActive
    {
    public:
        CChatter(MChatterReceiver&amp; aReceiver);
        ~CChatter();
        void ConstructL(TUid aAppUid);
        void SendL(const TDesC&amp; aMsg);
    private:
        void Queue();
        void RunL();
        void DoCancel();
    public:
        RInterAppChat iSub;
        TBuf&lt;KMaxMyMessage&gt; iBuf;
        MChatterReceiver&amp; iReceiver;
    };</codeblock></context>
</taskbody></task>