configlib/dbmsjdbc/src/native/StreamStore.cpp
author Bob Rosenberg <bob.rosenberg@nokia.com>
Wed, 13 Oct 2010 14:00:36 +0100
changeset 6 5b32dc297d05
parent 1 b538b70cbe51
permissions -rw-r--r--
Prepare old system model generator for 2.0 update
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
     2
// All rights reserved.
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
     3
// This component and the accompanying materials are made available
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
     5
// which accompanies this distribution, and is available
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
     7
//
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
     8
// Initial Contributors:
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    10
//
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    11
// Contributors:
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    12
//
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    13
// Description:
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    14
//
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    15
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    16
#include <jni.h>
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    17
#include "dbmsjni/com_symbian_store_StreamStore.h"
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    18
#include "StreamStore.h"
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    19
#include "Utils.h"
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    20
#include <s32stor.h>
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    21
#include <errortranslator.h>
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    22
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    23
extern CTrapCleanup* gCleanup; // clean-up stack
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    24
extern TPanicHandler gPanicHandler;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    25
extern jclass gExcCls;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    26
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    27
// //
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    28
// StreamStore class implementation
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    29
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    30
// nothing to implement
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    31
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    32
// //
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    33
// JNI implementations
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    34
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    35
JNIEXPORT jint JNICALL Java_com_symbian_store_StreamStore__1initNative
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    36
  (JNIEnv *aEnv, jobject) {
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    37
	if ( gCleanup == NULL ) {
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    38
		// init globals
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    39
		gCleanup=CTrapCleanup::New(); // get clean-up stack
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    40
		gPanicHandler = &SosPanicHandler;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    41
		jclass excCls = aEnv->FindClass("java/lang/RuntimeException");
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    42
		if ( excCls == NULL )
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    43
			{
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    44
			printf("Could not create exception class java/lang/RuntimeException in DbmsConnection::init ...\n");
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    45
			return KErrGeneral;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    46
			}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    47
		else
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    48
			{
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    49
			gExcCls = (jclass)(aEnv->NewGlobalRef(excCls));
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    50
			if ( gExcCls == NULL )
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    51
				{
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    52
				printf("Could not create glref to exception class java/lang/RuntimeException in DbmsConnection::init ...\n");
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    53
				return KErrGeneral;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    54
				}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    55
			}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    56
	}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    57
	return KErrNone;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    58
}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    59
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    60
/*
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    61
 * Class:     com_symbian_store_StreamStore
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    62
 * Method:    _delete
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    63
 * Signature: (II)I
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    64
 */
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    65
JNIEXPORT jint JNICALL Java_com_symbian_store_StreamStore__1delete
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    66
  (JNIEnv *, jobject, jint aPeerHandle, jint aStreamId) {
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    67
	TStreamId strid(aStreamId);
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    68
	StreamStore* store = (StreamStore*) aPeerHandle;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    69
	TRAPD(error, store->iStore->DeleteL(strid));
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    70
	return error;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    71
}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    72
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    73
/*
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    74
 * Class:     com_symbian_store_StreamStore
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    75
 * Method:    _compact
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    76
 * Signature: (I)I
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    77
 */
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    78
JNIEXPORT jint JNICALL Java_com_symbian_store_StreamStore__1compact
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    79
  (JNIEnv *, jobject, jint aPeerHandle) {
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    80
	StreamStore* store = (StreamStore*) aPeerHandle;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    81
	TRAPD(error, store->iStore->CompactL());
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    82
	return error;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    83
}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    84
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    85
/*
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    86
 * Class:     com_symbian_store_StreamStore
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    87
 * Method:    _extend
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    88
 * Signature: (I)I
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    89
 */
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    90
JNIEXPORT jint JNICALL Java_com_symbian_store_StreamStore__1extend
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    91
  (JNIEnv *, jobject, jint aPeerHandle) {
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    92
	StreamStore* store = (StreamStore*) aPeerHandle;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    93
	TInt strid;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    94
	TRAPD(error, strid = (store->iStore->ExtendL()).Value());
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    95
	if ( error < KErrNone ) {
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    96
		return error;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    97
	}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    98
	return strid;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
    99
}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   100
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   101
/*
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   102
 * Class:     com_symbian_store_StreamStore
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   103
 * Method:    _reclaim
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   104
 * Signature: (I)I
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   105
 */
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   106
JNIEXPORT jint JNICALL Java_com_symbian_store_StreamStore__1reclaim
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   107
  (JNIEnv *, jobject, jint aPeerHandle) {
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   108
	StreamStore* store = (StreamStore*) aPeerHandle;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   109
	TRAPD(error, store->iStore->ReclaimL());
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   110
	return error;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   111
}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   112
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   113
/*
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   114
 * Class:     com_symbian_store_StreamStore
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   115
 * Method:    _commit
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   116
 * Signature: (I)I
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   117
 */
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   118
JNIEXPORT jint JNICALL Java_com_symbian_store_StreamStore__1commit
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   119
  (JNIEnv *, jobject, jint aPeerHandle) {
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   120
	StreamStore* store = (StreamStore*) aPeerHandle;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   121
	TRAPD(error, store->iStore->CommitL());
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   122
	return error;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   123
}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   124
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   125
/*
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   126
 * Class:     com_symbian_store_StreamStore
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   127
 * Method:    _revert
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   128
 * Signature: (I)I
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   129
 */
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   130
JNIEXPORT jint JNICALL Java_com_symbian_store_StreamStore__1revert
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   131
  (JNIEnv *, jobject, jint aPeerHandle) {
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   132
	StreamStore* store = (StreamStore*) aPeerHandle;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   133
	TRAPD(error, store->iStore->RevertL());
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   134
	return error;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   135
}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   136
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   137
JNIEXPORT jstring JNICALL Java_com_symbian_store_StreamStore__1translateNativeError
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   138
  (JNIEnv *aEnv, jclass, jint aErrorCode) {
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   139
	TBuf8<256> buf;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   140
	TranslateError(aErrorCode, buf);
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   141
	TBuf<256> buf16;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   142
	buf16.Copy(buf);
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   143
	jstring jstr = CreateJavaString(aEnv, buf16);
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   144
	return jstr;
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   145
}
b538b70cbe51 Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff changeset
   146