Ejemplo n.º 1
0
PDL_bool CheckPathForImg(PDL_JSParameters *parms)
{
	PDL_Err err;

	char retVal[512];

	const char *strVal = PDL_GetJSParamString(parms, 0);

	if (g_Indexer.CheckForImg(strVal, retVal))
	{
		err = PDL_JSReply(parms, retVal);

		if (err != PDL_NOERROR)
		{
			ReportError1("PDL_Init failed, err = %s", PDL_GetError());
			return PDL_FALSE;
		}
	}
	else
	{
		err = PDL_JSReply(parms, "-1");

		if (err != PDL_NOERROR)
		{
			ReportError1("PDL_Init failed, err = %s", PDL_GetError());
			return PDL_FALSE;
		}
	}


	return PDL_TRUE;
}
Ejemplo n.º 2
0
PDL_bool SetEQ(PDL_JSParameters *params)
{

	const char *cstrPath = PDL_GetJSParamString(params, 0);
	ReportError1("Open Message being created for %s", cstrPath);
	g_MusController.PassMessage(MUS_MESSAGE_ATTRIB_SET, ATTRIB_EQ, cstrPath);

	return PDL_TRUE;
}
Ejemplo n.º 3
0
PDL_bool SetNext(PDL_JSParameters *parms)
{
	const char *cstrPath = PDL_GetJSParamString(parms, 0);
	double dGap = PDL_GetJSParamDouble(parms, 1);
	int32_t iTrack = PDL_GetJSParamInt(parms, 2);
	ReportError1("dGap val: %f", dGap);
	g_MusController.PassMessage(MUS_MESSAGE_SET_NEXT, cstrPath, dGap, iTrack);

	return PDL_TRUE;
}
Ejemplo n.º 4
0
PDL_bool Open(PDL_JSParameters *parms)
{
	const char *cstrPath = PDL_GetJSParamString(parms, 0);
	int32_t iTrack = PDL_GetJSParamInt(parms, 1);

	ReportError2("Open Message being created for %s, for track %i", cstrPath, iTrack);
	g_MusController.PassMessage(MUS_MESSAGE_OPEN_SONG, cstrPath, iTrack);

	return PDL_TRUE;
}
Ejemplo n.º 5
0
    PDL_bool service::do_render(PDL_JSParameters* params)
    {
        boost::format my_formatter(filename_format);

        int from = PDL_GetJSParamInt(params, 1);
        int count = PDL_GetJSParamInt(params, 2);
        int zoom = PDL_GetJSParamInt(params, 3);
        std::string directory = PDL_GetJSParamString(params, 4);
        std::string prefix = PDL_GetJSParamString(params, 5);
        std::string suffix = PDL_GetJSParamString(params, 6);

        my_formatter % directory % prefix % zoom % suffix;

//        if (!ctx_.is_open())
//            throw std::runtime_error("Document has not been opened yet");

        int err = ::mkdir(directory.c_str(), 0755);
        if (err != 0 && errno != EEXIST)
            throw std::runtime_error("could not create directory");

        LECTOR_LOG("Rendering call: from %d, count %d", from, count);
        for (int i = from; i < from + count; ++i)
        {
            std::string filename = (boost::format(my_formatter) % i).str();

            if (::access(filename.c_str(), R_OK) == -1 && errno == ENOENT)
            {
                LECTOR_LOG("Starting rendering of page %d", i);
                queue_.push(std::make_tuple(zoom / 100.f, i, filename));
            }
            else
            {
                LECTOR_LOG("Reusing cached image of page %d", i);
                std::string response_json =
                    (boost::format(render_response) % i % filename).str();

                const char* response = response_json.c_str();
                PDL_CallJS("RenderCallback", &response, 1);
            }
        }

        return PDL_TRUE;
    }
Ejemplo n.º 6
0
PDL_bool receiveResultLoop(PDL_JSParameters *params)
{
	pthread_mutex_lock(&callbackMutex);
	int numParams = PDL_GetNumJSParams(params);
	if(numParams == 0)
	{
		Funambol::LOG.info("JSCallback Loop failed.");
		pthread_cond_signal(&callbackReady);
	}
	else if(numParams < 6)
	{
		Funambol::LOG.info("Empty Loop.");
		pthread_cond_signal(&callbackReady);
	}
	else
	{
		Funambol::WString chunk = toWString(PDL_GetJSParamString(params,0));
		int chunkIndex = PDL_GetJSParamInt(params,1);
		int numChunks = PDL_GetJSParamInt(params,2);
		int entryIndex = PDL_GetJSParamInt(params,3);
		int numEntries = PDL_GetJSParamInt(params,4);
		bool lastEventID = PDL_GetJSParamInt(params,5) != 0;

		if(chunkIndex != numChunks)
		{
			partlyResult += chunk;
		}
		else //chunkIndex == numChunks => last chunk!
		{
			if(lastEventID) //last chunk == eventId
			{
				//add parts until now as first result
				//and event id as second result.
				globalResults.push_back(partlyResult);
				globalResults.push_back(chunk);
			}
			else
			{
				partlyResult += chunk;
				globalResults.push_back(partlyResult);
			}
			partlyResult = ""; //clear result string for next entry.

			//was this the last entry in the list?
			if(entryIndex == numEntries)
			{
				//wake up processing thread, loop finished!
				pthread_cond_signal(&callbackReady);
			}
		}
	}

	pthread_mutex_unlock(&callbackMutex);
	return PDL_TRUE;
}
Ejemplo n.º 7
0
PDL_bool SetMetadataPath(PDL_JSParameters *parms)
{
	const char *cstrPath = PDL_GetJSParamString(parms, 0);

	if (ptagFile)
		delete ptagFile;

	ptagFile = new TagLib::FileRef(cstrPath);

	ReportError1("Setting meta path %s", cstrPath);

	return PDL_TRUE;
}
Ejemplo n.º 8
0
PDL_bool flip_page(PDL_JSParameters *params)
{
    char *key;
    if(PDL_GetNumJSParams(params) < 1) {
             PDL_JSException(params, "Params not ok");
        return PDL_TRUE;
    }
    key = PDL_GetJSParamString(params,0); 

    pdfapp_onkey(&app,*key);
    draw_pdf();

    return PDL_TRUE;
}
Ejemplo n.º 9
0
PDL_bool GetMetadata(PDL_JSParameters *parms)
{
	const char *cstrItem = PDL_GetJSParamString(parms, 0);

	ReportError1("Getting meta for tag %s", cstrItem);
	const char *cstrRet = g_Indexer.GetMetadata(cstrItem);

	PDL_Err err = PDL_JSReply(parms, cstrRet);

	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return PDL_FALSE;
	}

	return PDL_TRUE;
}
Ejemplo n.º 10
0
PDL_bool dateToUTCTimestamp(PDL_JSParameters *params)
{
	int numParams = PDL_GetNumJSParams(params);
	if(numParams < 4)
	{
		//problem: not enough params!
		PDL_JSException(params,"Not enough params, need TZName, Year, Month, Day, at least.");
		return PDL_TRUE;
	}

	const char* oldTZ = getenv("TZ");

	struct std::tm t;
	setenv("TZ",PDL_GetJSParamString(params,0),true);
	tzset();
	t.tm_year = PDL_GetJSParamInt(params,1)-1900;
	t.tm_mon  = PDL_GetJSParamInt(params,2); //-1 already in JS.
	t.tm_mday = PDL_GetJSParamInt(params,3);
	if(numParams >= 5)
		t.tm_hour = PDL_GetJSParamInt(params,4);
	else
		t.tm_hour = 0;
	if(numParams >= 6)
		t.tm_min = PDL_GetJSParamInt(params,5);
	else
		t.tm_min = 0;
	if(numParams >= 7)
		t.tm_sec = PDL_GetJSParamInt(params,6);
	else
		t.tm_sec = 0;

	time_t time = std::mktime(&t); //this should produce a timestamp in UTC from the set timezone!
	Funambol::LOG.debug("Converted %02d.%02d.%04d - %02d:%02d:%02d to %d in timezone %s.",t.tm_mday,t.tm_mon+1,t.tm_year+1900,t.tm_hour,t.tm_min,t.tm_sec,time,getenv("TZ"));

	std::stringstream res;
	res << time;
	PDL_JSReply(params,res.str().c_str());

	setenv("TZ",oldTZ,1);

	return PDL_TRUE;
}
Ejemplo n.º 11
0
PDL_bool GetCurrentDirLS(PDL_JSParameters *parms)
{
	PDL_Err err;

	const char *strVal = PDL_GetJSParamString(parms, 0);

	char *cstrRet = g_Indexer.GetDirFileList(strVal);

	err = PDL_JSReply(parms, cstrRet);

	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return PDL_FALSE;
	}

	free(cstrRet);

	return PDL_TRUE;
}
Ejemplo n.º 12
0
PDL_bool receiveResult(PDL_JSParameters *params)
{
	pthread_mutex_lock(&callbackMutex);
	int numParams = PDL_GetNumJSParams(params);
	if(numParams == 0)
	{
		Funambol::LOG.info("JSCallback failed.");
	}
	else
	{
		for(size_t i = 0; i < numParams; i++)
		{
			Funambol::WString result = toWString(PDL_GetJSParamString(params,i));
			globalResults.push_back(result); //for events this will add event and eventId as two different entries into vector.
		}
	}
	pthread_cond_signal(&callbackReady);
	pthread_mutex_unlock(&callbackMutex);
	return PDL_TRUE;
}
Ejemplo n.º 13
0
Archivo: clip.c Proyecto: kai4785/LM
PDL_bool hello_world(PDL_JSParameters *params)
{
    const char *buf;
    if (PDL_GetNumJSParams(params) < 1)
    {
        buf = PDL_GetJSParamString(params, 1);
        if(buf == NULL)
        {
            PDL_JSException(params, "You must send a hellostr param");
            return PDL_TRUE;
        }
    }
    else
    {
        PDL_JSException(params, "No params sent");
        return PDL_TRUE;
    }
    
    char reply[32] = "Hello World!";
    PDL_JSReply(params, reply);

    return PDL_TRUE;
}