javauis/mmapi_qt/baseline/inc/cmmaoutputstream.h
changeset 23 98ccebc37403
child 26 dc7c549001d5
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Class to handle OutputStream operations.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMMAOUTPUTSTREAM_H
       
    20 #define CMMAOUTPUTSTREAM_H
       
    21 
       
    22 //  EXTERNAL INCLUDES
       
    23 //#include <jutils.h>
       
    24 #include <s32mem.h>
       
    25 #include "MMAFunctionServer.h"
       
    26 
       
    27 //  FORWARD DECLARATIONS
       
    28 class CMMAOutputStreamEvent;
       
    29 class MMMAEventPoster;
       
    30 
       
    31 //  CLASS DECLARATION
       
    32 /**
       
    33 *   Class to handle OutputStream operations.
       
    34 *   MMF writes to the stream and Java-class reads the stream.
       
    35 *
       
    36 *
       
    37 */
       
    38 
       
    39 NONSHARABLE_CLASS(CMMAOutputStream): public CBase
       
    40 {
       
    41 private:
       
    42     /**
       
    43      * Status code to be delivered to Java
       
    44      */
       
    45     enum TStatus
       
    46     {
       
    47         EMoreData = 1,
       
    48         ECompleted = 2
       
    49     };
       
    50 
       
    51 public:     // Constructors and destructors
       
    52     /**
       
    53      * Object creation. Static method.
       
    54      *
       
    55      * @param aJNIEnv           handle to used jni environment
       
    56      * @param aEventPoster      handle to event poster
       
    57      * @param aJavaOutputStreamWriter handle to java Outputstream object
       
    58      *
       
    59      * @return CMMAOutputStream object
       
    60      */
       
    61     static CMMAOutputStream* NewL(JNIEnv* aJNIEnv,
       
    62                                   MMMAEventPoster* aEventPoster,
       
    63                                   jobject aJavaOutputStreamWriter);
       
    64 
       
    65     /**
       
    66      * The same as NewL with cleanup stack
       
    67      * @see NewL
       
    68      */
       
    69     static CMMAOutputStream* NewLC(JNIEnv* aJNIEnv,
       
    70                                    MMMAEventPoster* aEventPoster,
       
    71                                    jobject aJavaOutputStreamWriter);
       
    72 
       
    73 
       
    74     /**
       
    75      * Object creation. Static method.
       
    76      *
       
    77      * @param aOutputStream handle to used output stream
       
    78      * @param aJNIEnv       handle to used jni environment
       
    79      * @param aEventPoster  handle to event poster
       
    80      * @param aJavaOutputStreamWriter handle to java Outputstream object
       
    81      */
       
    82     static void CreateL(CMMAOutputStream** aOutputStream,
       
    83     										MMAFunctionServer* aEventSource,
       
    84                         JNIEnv* aJNIEnv,
       
    85                         MMMAEventPoster* aEventPoster,
       
    86                         jobject aJavaOutputStreamWriter);
       
    87 
       
    88     /**
       
    89      * Deletes owned objects
       
    90      */
       
    91     ~CMMAOutputStream();    // Destructor
       
    92 
       
    93 private:    // Constructors and destructors
       
    94     /**
       
    95      * Default constructor, initializes variables
       
    96      */
       
    97     CMMAOutputStream(MMMAEventPoster* aEventPoster);
       
    98 
       
    99     /**
       
   100      * Finishes construction
       
   101      *
       
   102      * @param aJNIEnv       handle to used jni environment
       
   103      * @param aJavaOutputStreamWriter handle to java Outputstream object
       
   104      */
       
   105     void ConstructL(JNIEnv* aJNIEnv,
       
   106                     jobject aJavaOutputStreamWriter);
       
   107 
       
   108 public: // New methods
       
   109     /**
       
   110      * Read data from c++ to aOutputData (passed from java side)
       
   111      */
       
   112     virtual void ReadDataL(TUint8* aOutputData,
       
   113                            TInt* aBufferSize,
       
   114                            TInt* aReadStatus);
       
   115 
       
   116 public: // New methods
       
   117     /**
       
   118      * Write data to a stream.
       
   119      */
       
   120     void WriteL(const TDesC8& aData);
       
   121 
       
   122     /**
       
   123      * Commit Java stream
       
   124      */
       
   125     void Commit();
       
   126 
       
   127 private: // Data
       
   128     /**
       
   129      * Owned.
       
   130      * Event which notifies Java when data is available or read continues.
       
   131      */
       
   132     CMMAOutputStreamEvent* iWriteEvent;
       
   133 
       
   134     /**
       
   135      * Pointer to event source
       
   136      */
       
   137     MMMAEventPoster* iEventSource;
       
   138 
       
   139     /**
       
   140      * Ptr to iData member. Moved when data is read.
       
   141      */
       
   142     TPtr8 iPtr;
       
   143 
       
   144     /**
       
   145      * Owned.
       
   146      * Pointer to data to be written to Java side.
       
   147      */
       
   148     HBufC8* iData;
       
   149 };
       
   150 
       
   151 
       
   152 #endif // CMMAOUTPUTSTREAM_H