1 /*
   2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #import "iPodAccess.h"
  27 
  28 
  29 static IPodAccess* ipa;
  30 
  31 /*
  32  * Class:     com_sun_javafx_ext_device_ios_ipod_MediaQuery
  33  * Method:    nCreateQuery
  34  * Signature: ()V
  35  */
  36 JNIEXPORT void JNICALL Java_com_sun_javafx_ext_device_ios_ipod_MediaQuery_nCreateQuery
  37 (JNIEnv *env, jobject obj) {
  38 
  39     ipa = [[IPodAccess alloc] init];
  40     if (ipa) {
  41         [ipa createQuery];
  42     }
  43 }
  44 
  45 /*
  46  * Class:     com_sun_javafx_ext_device_ios_ipod_MediaQuery
  47  * Method:    nAddNumberPredicate
  48  * Signature: (II)V
  49  */
  50 JNIEXPORT void JNICALL Java_com_sun_javafx_ext_device_ios_ipod_MediaQuery_nAddNumberPredicate
  51 (JNIEnv *env, jobject obj, jint predicateKey, jint predicateValue) {
  52 
  53     if (ipa) {
  54         [ipa addNumberPredicateForKey: (int) predicateKey
  55                                 value: (int) predicateValue];
  56     }
  57 }
  58 
  59 /*
  60  * Class:     com_sun_javafx_ext_device_ios_ipod_MediaQuery
  61  * Method:    nAddStringPredicate
  62  * Signature: (ILjava/lang/String;)V
  63  */
  64 JNIEXPORT void JNICALL Java_com_sun_javafx_ext_device_ios_ipod_MediaQuery_nAddStringPredicate
  65 (JNIEnv *env, jobject obj, jint predicateKey, jstring jsPredicateValue) {
  66 
  67     if (ipa) {
  68 
  69         const char *predicateNativeString = (*env)->GetStringUTFChars(env, jsPredicateValue, 0);
  70         NSString *predicateValue = [NSString stringWithCString: predicateNativeString
  71                                                       encoding: NSUTF8StringEncoding];
  72         (*env)->ReleaseStringUTFChars(env, jsPredicateValue, predicateNativeString);
  73 
  74         [ipa addStringPredicateForKey: (int) predicateKey
  75                                 value: predicateValue];
  76     }
  77 }
  78 
  79 /*
  80  * Class:     com_sun_javafx_ext_device_ios_ipod_MediaQuery
  81  * Method:    nSetGroupingType
  82  * Signature: (I)V
  83  */
  84 JNIEXPORT void JNICALL Java_com_sun_javafx_ext_device_ios_ipod_MediaQuery_nSetGroupingType
  85 (JNIEnv *env, jobject obj, jint groupingType) {
  86 
  87     if (ipa) {
  88         [ipa setGroupingType: (int) groupingType];
  89     }
  90 }
  91 
  92 /*
  93  * Class:     com_sun_javafx_ext_device_ios_ipod_MediaQuery
  94  * Method:    nFillItemList
  95  * Signature: ()V
  96  */
  97 JNIEXPORT void JNICALL Java_com_sun_javafx_ext_device_ios_ipod_MediaQuery_nFillItemList
  98 (JNIEnv *env, jobject obj) {
  99 
 100     if (ipa) {
 101         [ipa fillItemListOfMediaQuery: obj jniEnv: env];
 102     }
 103 }
 104 
 105 /*
 106  * Class:     com_sun_javafx_ext_device_ios_ipod_MediaQuery
 107  * Method:    nFillCollections
 108  * Signature: ()V
 109  */
 110 JNIEXPORT void JNICALL Java_com_sun_javafx_ext_device_ios_ipod_MediaQuery_nFillCollections
 111 (JNIEnv *env, jobject obj) {
 112 
 113     if (ipa) {
 114         [ipa fillCollectionsOfMediaQuery: obj jniEnv: env];
 115     }
 116 }
 117 
 118 /*
 119  * Class:     com_sun_javafx_ext_device_ios_ipod_MediaQuery
 120  * Method:    nDisposeQuery
 121  * Signature: ()V
 122  */
 123 JNIEXPORT void JNICALL Java_com_sun_javafx_ext_device_ios_ipod_MediaQuery_nDisposeQuery
 124 (JNIEnv *env, jobject obj) {
 125 
 126     if (ipa) {
 127         [ipa disposeQuery];
 128         [ipa release];
 129     }
 130 }
 131