Symbian3/PDK/Source/GUID-DCB8CA27-F64F-4B78-831D-F88B1AD7E38B.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE task
       
    11   PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
       
    12 <task id="GUID-DCB8CA27-F64F-4B78-831D-F88B1AD7E38B" xml:lang="en"><title>Create
       
    13 the client class</title><prolog><metadata><keywords/></metadata></prolog><taskbody>
       
    14 <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
       
    15 following responsibilities:</p> <ul>
       
    16 <li><p>Implementing the client API </p></li>
       
    17 <li><p>Organizing calls to and from the server over IPC</p></li>
       
    18 <li><p>Any necessary security checks on the server. For example, restricting
       
    19 the data sent to a server having particular capabilities.</p></li>
       
    20 <li><p>Parameter checking from the server. Parameters returned from the server
       
    21 application must be checked to ensure that they are valid.</p></li>
       
    22 <li><p>Time-out support for IPC calls to the server.</p></li>
       
    23 </ul><p>The reason for these checks is that the client cannot be sure that
       
    24 the server application is using the appropriate server-side service support
       
    25 classes and may instead be trying to weaken the system by implementing the
       
    26 IPC handling itself.</p><p>This example shows the client interface for a chat
       
    27 service implemented in two parts. The active object class <codeph>CChatter</codeph> is
       
    28 the main client interface. It uses a class <codeph>RInterAppChat</codeph>,
       
    29 derived from <codeph>REikAppServiceBase</codeph>, which handles the client-side
       
    30 IPC for the chat service. </p><codeblock xml:space="preserve">class RInterAppChat : public REikAppServiceBase
       
    31     {
       
    32     public:
       
    33         TInt Send(const TDesC&amp; aMessage);
       
    34         void Receive(TRequestStatus&amp; aStatus, TDes&amp; aMessage);
       
    35         void CancelReceive();
       
    36     private:
       
    37         TUid ServiceUid() const;
       
    38     };
       
    39 class MChatterReceiver
       
    40     {
       
    41     public:
       
    42         virtual void Receive(const TDesC&amp;) = 0;
       
    43     };
       
    44 class CChatter : public CActive
       
    45     {
       
    46     public:
       
    47         CChatter(MChatterReceiver&amp; aReceiver);
       
    48         ~CChatter();
       
    49         void ConstructL(TUid aAppUid);
       
    50         void SendL(const TDesC&amp; aMsg);
       
    51     private:
       
    52         void Queue();
       
    53         void RunL();
       
    54         void DoCancel();
       
    55     public:
       
    56         RInterAppChat iSub;
       
    57         TBuf&lt;KMaxMyMessage&gt; iBuf;
       
    58         MChatterReceiver&amp; iReceiver;
       
    59     };</codeblock></context>
       
    60 </taskbody></task>