configlib/dbmsjdbc/src/native/EmbeddedStoreOutputStream.cpp
changeset 1 b538b70cbe51
equal deleted inserted replaced
0:2e8eeb919028 1:b538b70cbe51
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // EmbeddedStoreInputStream.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <jni.h>
       
    19 #include "dbmsjni/com_symbian_store_EmbeddedStoreOutputStream.h"
       
    20 #include "StoreOutputStream.h"
       
    21 #include "StreamStore.h"
       
    22 #include "Utils.h"
       
    23 
       
    24 
       
    25 // //
       
    26 // StoreOutputStream class implementation
       
    27 
       
    28 
       
    29 // //
       
    30 // JNI implementations
       
    31 
       
    32 
       
    33 /*
       
    34  * Class:     com_symbian_store_StoreOutputStream
       
    35  * Method:    _create
       
    36  * Signature: (I)I
       
    37  */
       
    38 JNIEXPORT jint JNICALL Java_com_symbian_store_EmbeddedStoreOutputStream__1create__II
       
    39   (JNIEnv *, jobject, jint aStorePeerHandle, jint aStreamId) {
       
    40 	StreamStore* streamStore = (StreamStore*)aStorePeerHandle;
       
    41 	StoreOutputStream* outStream = new StoreOutputStream();
       
    42 	RStoreWriteStream* strptr = new RStoreWriteStream();
       
    43 	outStream->iOutput = strptr;
       
    44 	TStreamId id ( aStreamId);
       
    45 	TRAPD(error, strptr->OpenL(*(streamStore->iStore), id));
       
    46 	if ( error == KErrNotFound ) {
       
    47 		TRAP(error, strptr->OpenL(*(streamStore->iStore), id));
       
    48 	}
       
    49 	if ( error < 0 ) {
       
    50 		return error;
       
    51 	}
       
    52 	return (jint)outStream;
       
    53 }
       
    54 
       
    55 /*
       
    56  * Class:     com_symbian_store_StoreOutputStream
       
    57  * Method:    _create
       
    58  * Signature: (I)I
       
    59  */
       
    60 JNIEXPORT jint JNICALL Java_com_symbian_store_EmbeddedStoreOutputStream__1create__I
       
    61   (JNIEnv *, jobject, jint aStorePeerHandle) {
       
    62 	StreamStore* streamStore = (StreamStore*)aStorePeerHandle;
       
    63 	StoreOutputStream* outStream = new StoreOutputStream();
       
    64 	RStoreWriteStream* strptr = new RStoreWriteStream();
       
    65 	outStream->iOutput = strptr;
       
    66 	CEmbeddedStore* embstore = (CEmbeddedStore*)streamStore->iStore;
       
    67 	TStreamId id;
       
    68 	TRAPD(error, id = strptr->CreateL(*embstore));
       
    69 	if ( error < 0 ) {
       
    70 		return error;
       
    71 	}
       
    72 	outStream->iId = id.Value();
       
    73 	return (jint)outStream;
       
    74 }
       
    75 
       
    76 /*
       
    77  * Class:     com_symbian_store_StoreOutputStream
       
    78  * Method:    _getStreamId
       
    79  * Signature: (I)I
       
    80  */
       
    81 JNIEXPORT jint JNICALL Java_com_symbian_store_EmbeddedStoreOutputStream__1getStreamId
       
    82   (JNIEnv *, jobject, jint aPeerHandle) {
       
    83 	StoreOutputStream* outStream = (StoreOutputStream*)aPeerHandle;
       
    84 	return outStream->iId;
       
    85 }
       
    86 
       
    87