Ejemplo n.º 1
0
    VALUE rho_sys_get_property(char* szPropName)
    {
        if (!szPropName || !*szPropName)
            return rho_ruby_get_NIL();

        VALUE res;
#ifdef RHODES_EMULATOR
        if (rho_simimpl_get_property(szPropName, &res))
            return res;
#endif

        if (rho_sysimpl_get_property(szPropName, &res))
            return res;

        if (strcasecmp("platform",szPropName) == 0)
            return rho_ruby_create_string(rho_rhodesapp_getplatform());

        if (strcasecmp("has_network",szPropName) == 0)
            return rho_sys_has_network();

        if (strcasecmp("locale",szPropName) == 0)
            return rho_sys_get_locale();

        if (strcasecmp("screen_width",szPropName) == 0)
            return rho_ruby_create_integer(rho_sys_get_screen_width());

        if (strcasecmp("screen_height",szPropName) == 0)
            return rho_ruby_create_integer(rho_sys_get_screen_height());

        if (strcasecmp("device_id",szPropName) == 0)
        {
            rho::String strDeviceID = "";
            if ( rho::sync::CClientRegister::getInstance() )
                strDeviceID = rho::sync::CClientRegister::getInstance()->getDevicePin();

            return rho_ruby_create_string(strDeviceID.c_str());
        }

        if (strcasecmp("phone_id", szPropName) == 0)
            return rho_ruby_create_string("");

        if (strcasecmp("full_browser",szPropName) == 0)
            return rho_ruby_create_boolean(1);

        if (strcasecmp("rhodes_port",szPropName) == 0)
            return rho_ruby_create_integer(atoi(RHODESAPP().getFreeListeningPort()));

        if (strcasecmp("is_emulator",szPropName) == 0)
            return rho_ruby_create_boolean(0);

        if (strcasecmp("has_touchscreen",szPropName) == 0)
            return rho_ruby_create_boolean(1);

        if (strcasecmp("has_sqlite",szPropName) == 0)
            return rho_ruby_create_boolean(1);

        RAWLOG_ERROR1("Unknown Rho::System property : %s", szPropName);

        return rho_ruby_get_NIL();
    }
Ejemplo n.º 2
0
RHO_GLOBAL VALUE get_camera_info(const char* camera_type) {
    
    JNIEnv *env = jnienv();
    jclass cls = getJNIClass(RHODES_JAVA_CLASS_CAMERA);
    if (!cls) return rho_ruby_get_NIL();
    jmethodID mid_w = getJNIClassStaticMethod(env, cls, "getMaxCameraWidth", "(Ljava/lang/String;)I");
    jmethodID mid_h = getJNIClassStaticMethod(env, cls, "getMaxCameraHeight", "(Ljava/lang/String;)I");
    if ((!mid_w) || (!mid_h)) return rho_ruby_get_NIL();
    int w = env->CallStaticIntMethod(cls, mid_w, rho_cast<jhstring>(camera_type).get());
    int h = env->CallStaticIntMethod(cls, mid_h, rho_cast<jhstring>(camera_type).get());
    
    if ((w <= 0) || (h <= 0)) {
        return rho_ruby_get_NIL();
    }

    VALUE hash = rho_ruby_createHash();
    
    VALUE hash_max_resolution = rho_ruby_createHash();
    
    rho_ruby_add_to_hash(hash_max_resolution, rho_ruby_create_string("width"), rho_ruby_create_integer(w));
    rho_ruby_add_to_hash(hash_max_resolution, rho_ruby_create_string("height"), rho_ruby_create_integer(h));

    rho_ruby_add_to_hash(hash, rho_ruby_create_string("max_resolution"), hash_max_resolution);
    
    return hash;
}
Ejemplo n.º 3
0
RHO_GLOBAL VALUE rho_bluetooth_get_device_name() {
    JNIEnv *env = jnienv();
    jclass cls = getJNIClass(RHODES_JAVA_CLASS_RHOBLUETOOTHMANAGER);
    if (!cls) return rho_ruby_get_NIL();
    jmethodID mid = getJNIClassStaticMethod(env, cls, "get_device_name", "()Ljava/lang/String;");
    if (!mid) return rho_ruby_get_NIL();
    jstring jname = static_cast<jstring>(env->CallStaticObjectMethod(cls, mid));
    if (!jname) return rho_ruby_get_NIL();
    std::string name = rho_cast<std::string>(env, jname); 
    RAWLOG_INFO1("rho_bluetooth_get_device_name() : %s", name.c_str());
    return rho_ruby_create_string(name.c_str());
}
extern "C" VALUE locationmanager_native_process_string(const char* str) {

    JNIEnv *env = jnienv();
    jclass cls = rho_find_class(env, "com/locationmanager/Locationmanager");
    if (!cls) return rho_ruby_get_NIL();;
    jmethodID mid = env->GetStaticMethodID( cls, "processString", "(Ljava/lang/String;)Ljava/lang/String;");
    if (!mid) return rho_ruby_get_NIL();;
    jstring objStr = env->NewStringUTF(str);
    jstring jstr = (jstring)env->CallStaticObjectMethod(cls, mid, objStr);
    env->DeleteLocalRef(objStr);
    const char* buf = env->GetStringUTFChars(jstr,0);
    VALUE result = rho_ruby_create_string(buf);
    env->ReleaseStringUTFChars(jstr, buf);
    return result;
}
Ejemplo n.º 5
0
RHO_GLOBAL VALUE rho_bluetooth_session_read_data(const char* connected_device_name) {
    JNIEnv *env = jnienv();
    jclass cls = getJNIClass(RHODES_JAVA_CLASS_RHOBLUETOOTHMANAGER);
    if (!cls) return 0;
    jmethodID mid = getJNIClassStaticMethod(env, cls, "session_read_data", "(Ljava/lang/String;[BI)I");
    if (!mid) return 0;
    jhstring objStr1 = rho_cast<jstring>(env, connected_device_name);

    int buf_size = env->CallStaticIntMethod(cls, mid, objStr1.get(), 0, 0);

    if (buf_size == 0) {
        // nothing for receive
        return rho_ruby_get_NIL();
    }

    jholder<jbyteArray> buf_j = jholder<jbyteArray>(env->NewByteArray(buf_size));
    int real_readed = env->CallStaticIntMethod(cls, mid, objStr1.get(), buf_j.get(), buf_size);

    jbyte* buf_p = env->GetByteArrayElements(buf_j.get(), 0);
 
    VALUE val = rho_ruby_create_byte_array((unsigned char*)buf_p, real_readed);

    env->ReleaseByteArrayElements(buf_j.get(), buf_p, 0); 

    return val;
}
Ejemplo n.º 6
0
unsigned long CAsyncHttp::CHttpCommand::getRetValue()
{
    if ( m_strCallback.length() == 0 )
        return rho_ruby_create_string(m_strResBody.c_str());

    return rho_ruby_get_NIL();
}
Ejemplo n.º 7
0
VALUE getallPhonebookRecords(void* pb) {
#if defined (_WIN32_WCE)//&& !defined( OS_PLATFORM_MOTCE )
	if (RHO_IS_WMDEVICE && pb) {
		CNativeAddressBook* phonebook = (CNativeAddressBook*)pb;
        VALUE valGc = rho_ruby_disable_gc();
        CHoldRubyValue hash(rho_ruby_createHash());
		
		std::vector<CABRecord*> records;
		phonebook->getAllRecords(records);
		while(records.size() > 0) {
			CABRecord* record = records.back();
			const char* rid = record->getValue("id").c_str();
			if (rid) {
				LOGC(TRACE,"Phonebook") + "Adding record " + rid;
				addHashToHash(hash,rid,_getRecord(record));
			}
			delete record;
			records.pop_back();
		}

        rho_ruby_enable_gc(valGc);
		return hash;
	}	
#endif
	return rho_ruby_get_NIL();	
}
Ejemplo n.º 8
0
RHO_GLOBAL VALUE rho_sys_get_locale()
{
    VALUE res;
    if ( rho_sysimpl_get_property((char*)"locale", &res) )
        return res;

    return rho_ruby_get_NIL();
}
Ejemplo n.º 9
0
static VALUE _getRecord(CABRecord* record) {
	if (record) {
		VALUE hash = createHash();
		record->enumValues(_addRecordValue,&hash);
		return hash;
	}
	return rho_ruby_get_NIL();
}
Ejemplo n.º 10
0
static VALUE _getRecord(CABRecord* record) {
	if (RHO_IS_WMDEVICE && record) {
        CHoldRubyValue hash(rho_ruby_createHash());
		record->enumValues(_addRecordValue,&(hash.m_value));
		return hash;
	}
	return rho_ruby_get_NIL();
}
Ejemplo n.º 11
0
VALUE getPhonebookRecord(void* pb, char* id) 
{
	if ( pb && id )
	{
		CPhonebook* phonebook = (CPhonebook*)pb;
		return phonebook->getContact(id);
	}
	return rho_ruby_get_NIL();	
}
Ejemplo n.º 12
0
VALUE getallPhonebookRecords(void* pb) 
{
	if ( pb )
	{
		CPhonebook* phonebook = (CPhonebook*)pb;
		return phonebook->getallPhonebookRecords();
	}

	return rho_ruby_get_NIL();	
}
Ejemplo n.º 13
0
RHO_GLOBAL VALUE navbar_started()
{
    JNIEnv *env = jnienv();
    VALUE nil = rho_ruby_get_NIL();
    jclass cls = getJNIClass(RHODES_JAVA_CLASS_NAVBAR);
    if (!cls) return nil;
    jmethodID mid = getJNIClassStaticMethod(env, cls, "isStarted", "()Z");
    if (!mid) return nil;

    return rho_ruby_create_boolean(env->CallStaticBooleanMethod(cls, mid));
}
Ejemplo n.º 14
0
RHO_GLOBAL VALUE google_mapview_state_started()
{
    VALUE nil = rho_ruby_get_NIL();
    JNIEnv *env = jnienv();
    static jclass cls = rho_find_class(env, GMAP_FACADE_CLASS);
    if (!cls) return nil;
    jmethodID mid = getJNIClassStaticMethod(env, cls, "isStarted", "()Z");
    if (!mid) return nil;

    return rho_ruby_create_boolean(env->CallStaticBooleanMethod(cls, mid));
}
Ejemplo n.º 15
0
VALUE rho_sys_get_property(char* szPropName) 
{
	if (!szPropName || !*szPropName) 
        return rho_ruby_get_NIL();
    
    VALUE res = rho_sysimpl_get_property(szPropName);
    if (res)
        return res;

	if (strcasecmp("platform",szPropName) == 0) 
        return rho_ruby_create_string(getPlatformProp());

	if (strcasecmp("has_network",szPropName) == 0) 
        return rho_sys_has_network();

	if (strcasecmp("locale",szPropName) == 0) 
        return rho_sys_get_locale();

	if (strcasecmp("screen_width",szPropName) == 0) 
        return rho_ruby_create_integer(rho_sys_get_screen_width());

	if (strcasecmp("screen_height",szPropName) == 0) 
        return rho_ruby_create_integer(rho_sys_get_screen_height());

	if (strcasecmp("device_id",szPropName) == 0) 
    {
        rho::String strDeviceID = "";
        if ( rho::sync::CClientRegister::getInstance() )
            strDeviceID = rho::sync::CClientRegister::getInstance()->getDevicePin();

        return rho_ruby_create_string(strDeviceID.c_str());
    }

	if (strcasecmp("full_browser",szPropName) == 0) 
        return rho_ruby_create_boolean(1);

    RAWLOG_ERROR1("Unknown Rho::System property : %s", szPropName);

    return rho_ruby_get_NIL();
}
Ejemplo n.º 16
0
unsigned long CExtManager::parseJsonToRubyHash(const char* szJson)
{
    char* szError = 0;
    unsigned long valBody = rjson_tokener_parse(szJson, &szError);
    if ( valBody != 0 )
        return valBody;

    LOG(ERROR) + "Incorrect json body.Error:" + (szError ? szError : "");
    if ( szError )
        free(szError);

    return rho_ruby_get_NIL();
}
Ejemplo n.º 17
0
VALUE getPhonebookRecord(void* pb, char* id) {
#if defined (_WIN32_WCE)
	if (pb && id) {
		CNativeAddressBook* phonebook = (CNativeAddressBook*)pb;
		CABRecord* record = phonebook->getRecord(id);
		if (record) {
			VALUE hash = _getRecord(record);
			delete record;
			return hash;
		}
	}
#endif
	return rho_ruby_get_NIL();	
}
Ejemplo n.º 18
0
RHO_GLOBAL VALUE google_mapview_state_started()
{
#ifdef RHO_GOOGLE_API_KEY
    VALUE nil = rho_ruby_get_NIL();
    JNIEnv *env = jnienv();
    jclass cls = getJNIClass(RHODES_JAVA_CLASS_GOOGLEMAPVIEW);
    if (!cls) return nil;
    jmethodID mid = getJNIClassStaticMethod(env, cls, "isStarted", "()Z");
    if (!mid) return nil;

    return rho_ruby_create_boolean(env->CallStaticBooleanMethod(cls, mid));
#else
    return rho_ruby_create_boolean(0);
#endif
}
Ejemplo n.º 19
0
VALUE getallPhonebookRecords(void* pb) {
#if defined (_WIN32_WCE)
	if (pb) {
		CNativeAddressBook* phonebook = (CNativeAddressBook*)pb;
		VALUE hash = createHash();
		
		std::vector<CABRecord*> records;
		phonebook->getAllRecords(records);
		while(records.size() > 0) {
			CABRecord* record = records.back();
			const char* rid = record->getValue("id").c_str();
			if (rid) {
				LOGC(TRACE,"Phonebook") + "Adding record " + rid;
				addHashToHash(hash,rid,_getRecord(record));
			}
			delete record;
			records.pop_back();
		}

		return hash;
	}
#endif
	return rho_ruby_get_NIL();	
}
Ejemplo n.º 20
0
VALUE getallPhonebookRecords(void* pb)
{
    //TODO: getallPhonebookRecords
    return rho_ruby_get_NIL();    
}
Ejemplo n.º 21
0
VALUE getfirstPhonebookRecord(void* pb)
{
    //TODO: getfirstPhonebookRecord
    return rho_ruby_get_NIL();
}
Ejemplo n.º 22
0
VALUE getPhonebookRecords(void* pb, int offset, int max_results, rho_param* select_param) {
	return rho_ruby_get_NIL();	
}
Ejemplo n.º 23
0
VALUE event_fetch_by_id(const char *eid)
{
    return rho_ruby_get_NIL();
}
Ejemplo n.º 24
0
VALUE rho_sys_get_property(char* szPropName) 
{
	if (!szPropName || !*szPropName) 
        return rho_ruby_get_NIL();
    
    VALUE res;
#ifdef RHODES_EMULATOR
    if (rho_simimpl_get_property(szPropName, &res))
        return res;
#endif

    if (rho_sysimpl_get_property(szPropName, &res))
        return res;

	if (strcasecmp("platform",szPropName) == 0) 
        return rho_ruby_create_string(rho_rhodesapp_getplatform());

	if (strcasecmp("has_network",szPropName) == 0) 
        return rho_sys_has_network();

	if (strcasecmp("locale",szPropName) == 0) 
        return rho_sys_get_locale();

	if (strcasecmp("screen_width",szPropName) == 0) 
        return rho_ruby_create_integer(rho_sys_get_screen_width());

	if (strcasecmp("screen_height",szPropName) == 0) 
        return rho_ruby_create_integer(rho_sys_get_screen_height());

	if (strcasecmp("real_screen_width",szPropName) == 0) 
        return rho_ruby_create_integer(rho_sys_get_screen_width());
    
	if (strcasecmp("real_screen_height",szPropName) == 0) 
        return rho_ruby_create_integer(rho_sys_get_screen_height());

	if (strcasecmp("device_id",szPropName) == 0) 
    {
        rho::String strDeviceID = "";
        if ( rho::sync::CClientRegister::getInstance() )
            strDeviceID = rho::sync::CClientRegister::getInstance()->getDevicePin();

        return rho_ruby_create_string(strDeviceID.c_str());
    }

    if (strcasecmp("phone_id", szPropName) == 0)
        return rho_ruby_create_string(""); 

	if (strcasecmp("full_browser",szPropName) == 0) 
        return rho_ruby_create_boolean(1);

	if (strcasecmp("rhodes_port",szPropName) == 0) 
        return rho_ruby_create_integer(atoi(RHODESAPP().getFreeListeningPort()));

	if (strcasecmp("free_server_port",szPropName) == 0) 
        return rho_ruby_create_integer(RHODESAPP().determineFreeListeningPort());

	if (strcasecmp("is_emulator",szPropName) == 0) 
        return rho_ruby_create_boolean(0);

	if (strcasecmp("has_touchscreen",szPropName) == 0)
        return rho_ruby_create_boolean(1);

	if (strcasecmp("has_sqlite",szPropName) == 0)
        return rho_ruby_create_boolean(1);
    
    if (strcasecmp("security_token_not_passed",szPropName) == 0) {
        int passed = 0;
        if ((RHODESAPP().isSecurityTokenNotPassed())) {
            passed = 1;
        }
        return rho_ruby_create_boolean(passed);
    }

	if (strcasecmp("is_moto_device",szPropName) == 0)
#ifdef APP_BUILD_CAPABILITY_MOTOROLA
        return rho_ruby_create_boolean(1);
#else
        return rho_ruby_create_boolean(0);
#endif

    RAWLOG_ERROR1("Unknown Rho::System property : %s", szPropName);

    return rho_ruby_get_NIL();
}
Ejemplo n.º 25
0
VALUE getfirstPhonebookRecord(void* pb) {
	pb;
	return rho_ruby_get_NIL();
}
Ejemplo n.º 26
0
VALUE getPhonebookRecords(void* pb, rho_param* params) {
	return rho_ruby_get_NIL();	
}
Ejemplo n.º 27
0
VALUE get_camera_info(const char* camera_type) {
     return rho_ruby_get_NIL();
}
Ejemplo n.º 28
0
VALUE getPhonebookRecord(void* pb, char* id)
{
    //TODO: getPhonebookRecord
    return rho_ruby_get_NIL();    
}
Ejemplo n.º 29
0
VALUE rho_bluetooth_session_read_data(const char* connected_device_name)
{
    return rho_ruby_get_NIL();
}
Ejemplo n.º 30
0
VALUE getnextPhonebookRecord(void* pb) {
	return rho_ruby_get_NIL();}