javauis/mmapi_akn/baseline/inc/cmmaoutputstream.h
branchRCL_3
changeset 26 2455ef1f5bbc
parent 14 04becd199f91
equal deleted inserted replaced
25:ae942d28ec0e 26:2455ef1f5bbc
       
     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 
       
    26 //  FORWARD DECLARATIONS
       
    27 class CMMAOutputStreamEvent;
       
    28 class MMMAEventPoster;
       
    29 
       
    30 //  CLASS DECLARATION
       
    31 /**
       
    32 *   Class to handle OutputStream operations.
       
    33 *   MMF writes to the stream and Java-class reads the stream.
       
    34 *
       
    35 *
       
    36 */
       
    37 
       
    38 NONSHARABLE_CLASS(CMMAOutputStream): public CBase
       
    39 {
       
    40 private:
       
    41     /**
       
    42      * Status code to be delivered to Java
       
    43      */
       
    44     enum TStatus
       
    45     {
       
    46         EMoreData = 1,
       
    47         ECompleted = 2
       
    48     };
       
    49 
       
    50 public:     // Constructors and destructors
       
    51     /**
       
    52      * Object creation. Static method.
       
    53      *
       
    54      * @param aJNIEnv           handle to used jni environment
       
    55      * @param aEventPoster      handle to event poster
       
    56      * @param aJavaOutputStreamWriter handle to java Outputstream object
       
    57      *
       
    58      * @return CMMAOutputStream object
       
    59      */
       
    60     static CMMAOutputStream* NewL(JNIEnv* aJNIEnv,
       
    61                                   MMMAEventPoster* aEventPoster,
       
    62                                   jobject aJavaOutputStreamWriter);
       
    63 
       
    64     /**
       
    65      * The same as NewL with cleanup stack
       
    66      * @see NewL
       
    67      */
       
    68     static CMMAOutputStream* NewLC(JNIEnv* aJNIEnv,
       
    69                                    MMMAEventPoster* aEventPoster,
       
    70                                    jobject aJavaOutputStreamWriter);
       
    71 
       
    72 
       
    73     /**
       
    74      * Object creation. Static method.
       
    75      *
       
    76      * @param aOutputStream handle to used output stream
       
    77      * @param aJNIEnv       handle to used jni environment
       
    78      * @param aEventPoster  handle to event poster
       
    79      * @param aJavaOutputStreamWriter handle to java Outputstream object
       
    80      */
       
    81     static void CreateL(CMMAOutputStream** aOutputStream,
       
    82                         JNIEnv* aJNIEnv,
       
    83                         MMMAEventPoster* aEventPoster,
       
    84                         jobject aJavaOutputStreamWriter);
       
    85 
       
    86     /**
       
    87      * Deletes owned objects
       
    88      */
       
    89     ~CMMAOutputStream();    // Destructor
       
    90 
       
    91 private:    // Constructors and destructors
       
    92     /**
       
    93      * Default constructor, initializes variables
       
    94      */
       
    95     CMMAOutputStream(MMMAEventPoster* aEventPoster);
       
    96 
       
    97     /**
       
    98      * Finishes construction
       
    99      *
       
   100      * @param aJNIEnv       handle to used jni environment
       
   101      * @param aJavaOutputStreamWriter handle to java Outputstream object
       
   102      */
       
   103     void ConstructL(JNIEnv* aJNIEnv,
       
   104                     jobject aJavaOutputStreamWriter);
       
   105 
       
   106 public: // New methods
       
   107     /**
       
   108      * Read data from c++ to aOutputData (passed from java side)
       
   109      */
       
   110     virtual void ReadDataL(TUint8* aOutputData,
       
   111                            TInt* aBufferSize,
       
   112                            TInt* aReadStatus);
       
   113 
       
   114 public: // New methods
       
   115     /**
       
   116      * Write data to a stream.
       
   117      */
       
   118     void WriteL(const TDesC8& aData);
       
   119 
       
   120     /**
       
   121      * Commit Java stream
       
   122      */
       
   123     void Commit();
       
   124 
       
   125 private: // Data
       
   126     /**
       
   127      * Owned.
       
   128      * Event which notifies Java when data is available or read continues.
       
   129      */
       
   130     CMMAOutputStreamEvent* iWriteEvent;
       
   131 
       
   132     /**
       
   133      * Pointer to event source
       
   134      */
       
   135     MMMAEventPoster* iEventSource;
       
   136 
       
   137     /**
       
   138      * Ptr to iData member. Moved when data is read.
       
   139      */
       
   140     TPtr8 iPtr;
       
   141 
       
   142     /**
       
   143      * Owned.
       
   144      * Pointer to data to be written to Java side.
       
   145      */
       
   146     HBufC8* iData;
       
   147 };
       
   148 
       
   149 
       
   150 #endif // CMMAOUTPUTSTREAM_H