platform/android/Rhodes/jni/src/callbacks.cpp in rhodes-3.0.2 vs platform/android/Rhodes/jni/src/callbacks.cpp in rhodes-3.1.0.beta.1
- old
+ new
@@ -1,22 +1,43 @@
+/*------------------------------------------------------------------------
+* (The MIT License)
+*
+* Copyright (c) 2008-2011 Rhomobile, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*
+* http://rhomobile.com
+*------------------------------------------------------------------------*/
+
#include "rhodes/JNIRhodes.h"
+#include "rhodes/JNIRhoRuby.h"
#include "rhodes/RhoClassFactory.h"
#include <ruby/ext/rho/rhoruby.h>
#undef DEFAULT_LOGCATEGORY
#define DEFAULT_LOGCATEGORY "Callbacks"
extern "C" void rho_webview_navigate(const char* url, int index);
-static rho::common::CRhoClassFactory g_oRhoClassFactory;
-rho::common::IRhoClassFactory* rho_get_RhoClassFactory()
-{
- return &g_oRhoClassFactory;
-}
-
RHO_GLOBAL void rho_map_location(char* query)
{
rho::String url = "http://maps.google.com/?";
url += query;
rho_webview_navigate(url.c_str(), 0);
@@ -68,20 +89,24 @@
jmethodID mid = getJNIClassStaticMethod(env, cls, "pingHost", "(Ljava/lang/String;)Z");
if (!mid) return 0;
return (int)env->CallStaticBooleanMethod(cls, mid, rho_cast<jhstring>(szHost).get());
}
-RHO_GLOBAL void *rho_nativethread_start()
+rho::String rho_sysimpl_get_phone_id()
{
- JNIEnv *env;
- jvm()->AttachCurrentThread(&env, NULL);
- store_thr_jnienv(env);
- return NULL;
-}
+ JNIEnv *env = jnienv();
-RHO_GLOBAL void rho_nativethread_end(void *)
-{
- jvm()->DetachCurrentThread();
+ jclass cls = getJNIClass(RHODES_JAVA_CLASS_RHODES_SERVICE);
+ if (!cls) return 0;
+ jmethodID mid = getJNIClassStaticMethod(env, cls, "getProperty", "(Ljava/lang/String;)Ljava/lang/Object;");
+ if (!mid) return 0;
+
+ jhstring propNameObj = rho_cast<jhstring>("phone_id");
+ jhobject result = jhobject(env->CallStaticObjectMethod(cls, mid, propNameObj.get()));
+ if (!result) return 0;
+
+ jstring resStrObj = (jstring)result.get();
+ return rho_cast<std::string>(resStrObj);
}
RHO_GLOBAL int rho_sysimpl_get_property(char* szPropName, VALUE* resValue)
{
JNIEnv *env = jnienv();