Esempio n. 1
0
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get data element as a string
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
std::string dataHandlerString::getString(const imbxUint32 index) const
{
	PUNTOEXE_FUNCTION_START(L"dataHandlerString::getString");

        charsetsList::tCharsetsList localCharsetsList(m_charsetsList);
	return convertFromUnicode(getUnicodeString(index), &localCharsetsList);

	PUNTOEXE_FUNCTION_END();
}
Esempio n. 2
0
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get data element as a double
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
double dataHandlerString::getDouble(const imbxUint32 index) const
{
	PUNTOEXE_FUNCTION_START(L"dataHandlerString::getDouble");

	std::wstring tempString = getUnicodeString(index);
	std::wistringstream convStream(tempString);
	double value;
	convStream >> value;
	return value;

	PUNTOEXE_FUNCTION_END();
}
Esempio n. 3
0
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Get data element as a signed long
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
imbxInt32 dataHandlerString::getSignedLong(const imbxUint32 index) const
{
	PUNTOEXE_FUNCTION_START(L"dataHandlerString::getSignedLong");

	std::wstring tempString = getUnicodeString(index);
	std::wistringstream convStream(tempString);
	imbxInt32 value;
	convStream >> value;
	return value;

	PUNTOEXE_FUNCTION_END();
}
Esempio n. 4
0
/*
 * Load a plugin.
 */
IPlugin *loadPlugin(const STRING path)
{
    const STRING file = resolve(path);

    HMODULE mod = LoadLibrary(file.c_str());

    if (!mod)
    {
        messageBox(_T("The file ") + file + _T(" is not a valid dynamically linkable library."));
        return NULL;
    }

    FARPROC pReg = GetProcAddress(mod, _T("DllRegisterServer"));

    if (!pReg)
    {
        FreeLibrary(mod);
        COldPlugin *p = new COldPlugin();
        if (p->load(file))
        {
            p->initialize();
            return p;
        }
        messageBox(_T("The file ") + file + _T(" is not a valid plugin."));
        delete p;
        return NULL;
    }

    FreeLibrary(mod);

    CComPlugin *p = new CComPlugin();
    STRING manifestFile = file + ".x.manifest";

    // Create an "Active Context" to load the DLL into this processes
    // execution address.
    //
    // Normally you would have to register a COM DLL to access it which
    // would require administrative rights, to get around that issue
    // we are using "Registration Free COM".
    ACTCTX actCtx;
    memset((void*)&actCtx, 0, sizeof(ACTCTX));
    actCtx.cbSize = sizeof(ACTCTX);
    actCtx.lpSource = manifestFile.c_str();

    HANDLE hCtx = ::CreateActCtx(&actCtx);

    if (hCtx == INVALID_HANDLE_VALUE)
    {
        messageBox(_T("Failed to load the type library manifest ") + manifestFile + _T("."));
        return NULL;
    }
    else
    {
        ULONG_PTR cookie;

        if (::ActivateActCtx(hCtx, &cookie))
        {
            ITypeLib *pTypeLib = NULL;

            // Because we can't simply cast to 'LPCOLESTR'.
            std::wstring fileWstring = getUnicodeString(file);
            LPCOLESTR fileLibrary = fileWstring.c_str();

            if (FAILED(LoadTypeLib(fileLibrary, &pTypeLib)))
            {
                messageBox(_T("Failed to load the type library of ") + file + _T("."));
                return NULL;
            }

            const int types = pTypeLib->GetTypeInfoCount();

            // Check all the types in the library.
            bool bLoaded = false;
            for (int i = 0; i < types; ++i)
            {
                ITypeInfo *pTypeInfo = NULL;
                pTypeLib->GetTypeInfo(i, &pTypeInfo);

                if (bLoaded = p->load(pTypeInfo))
                {
                    break;
                }
            }

            // Release the type library.
            pTypeLib->Release();

            if (!bLoaded)
            {
                messageBox(_T("A remotable class was not found in ") + file + _T("."));
                delete p;
                return NULL;
            }

            ::DeactivateActCtx(0, cookie);
        }
    }

    p->initialize();

    return p;
}
jobject getChannelObject(JNIEnv *env, int index, struct DvbChannelNode *node) {
	LOGD("%s,%d",__FUNCTION__,__LINE__);

	/* audio tracks */
	jobjectArray trackArr = (*env)->NewObjectArray(env, node->audio.audio_count, CLS_DvbAudioTrack, NULL);
	if (trackArr == NULL) {
		LOGE("%s,%d,trackArr: failed to new object array",__FUNCTION__,__LINE__);
		return NULL;
	}

	int i,j;

	for (j=0; j<node->audio.audio_count; j++) {
		jobject audiotrack;
		jstring audiolang;
		
		node->audio.audio_track[j].audio_lang[3] = 0;
		for( i = 0; i < 3; i++) {
			if(node->audio.audio_track[j].audio_lang[i] > 127)
				node->audio.audio_track[j].audio_lang[i] = 0;
		}
		audiolang = (*env)->NewStringUTF(env, node->audio.audio_track[j].audio_lang);
		audiotrack = (*env)->NewObject(env, CLS_DvbAudioTrack, MID_DvbAudioTrack_constructor,
				node->audio.audio_track[j].audio_pid, node->audio.audio_track[j].audio_type, audiolang);

		(*env)->SetObjectArrayElement(env, trackArr, j, audiotrack);

		(*env)->DeleteLocalRef(env, audiolang);
		(*env)->DeleteLocalRef(env, audiotrack);
	}


	/* audio */
	jobject audio = (*env)->NewObject(env, CLS_DvbAudio, MID_DvbAudio_constructor,
			node->audio.audio_channel, node->audio.audio_volume, node->audio.audio_current, trackArr);
	if (trackArr != NULL) {
		(*env)->DeleteLocalRef(env, trackArr);
	}

	/* bouquet */
	jshortArray sarr = (*env)->NewShortArray(env, node->bouquet.bouquet_count);
	if (sarr == NULL) {
		LOGE("%s,%d,sarr: failed to new short array",__FUNCTION__,__LINE__);
		return  NULL;
	}

	(*env)->SetShortArrayRegion(env, sarr,
			0, node->bouquet.bouquet_count,node->bouquet.bouquet_id);
       
	jobject bouquet = (*env)->NewObject(env, CLS_DvbBouquet, MID_DvbBouquet_constructor,
		sarr);
	if (sarr != NULL) {
		(*env)->DeleteLocalRef(env, sarr);
	}

	/* frontend */
	jobject frontend = getFrontendObject(env, &node->frontend);

	/* pcr */
	jobject pcr = (*env)->NewObject(env, CLS_DvbPcr, MID_DvbPcr_constructor,
			node->pcr.pcr_pid);

	/* video */
	jobject video = (*env)->NewObject(env, CLS_DvbVideo, MID_DvbVideo_constructor,
			node->video.video_type, node->video.video_pid);
        
	/* name */
	//node->service_name[MAX_SERVICE_NAME_LENGTH] = 0;
       unsigned short uniname[MAX_SERVICE_NAME_LENGTH+1];
       int unilen;
       
       unilen = getUnicodeString(node->service_name, uniname);
	jstring name = (*env)->NewString(env, uniname, unilen);

	/* number */
	char buf[10];
	sprintf(buf, "%d",index+1);
	jstring number = (*env)->NewStringUTF(env, buf);

	jboolean isFav = (node->favorite == 0)? JNI_FALSE : JNI_TRUE;
	jboolean isLock = (node->lock == 0)? JNI_FALSE : JNI_TRUE;
	jboolean isScramble = (node->scramble == 0)? JNI_FALSE : JNI_TRUE;

	/* channel node */
	jobject channel = (*env)->NewObject(env, CLS_DvbChannelNode, MID_DvbChannelNode_constructor,
			node->prog_id, name, number,
			frontend, pcr, video, audio,
			bouquet, node->tp_id, node->service_id, node->service_type,
			isScramble, isLock, isFav);

	(*env)->DeleteLocalRef(env, name);

	(*env)->DeleteLocalRef(env, number);

	(*env)->DeleteLocalRef(env, frontend);

	(*env)->DeleteLocalRef(env, pcr);

	(*env)->DeleteLocalRef(env, video);

	(*env)->DeleteLocalRef(env, audio);

	(*env)->DeleteLocalRef(env, bouquet);

	return channel;
}