예제 #1
0
파일: shocker.cpp 프로젝트: 499940913/moon
bool
ShockerScriptableControlObject::HasProperty (NPIdentifier id)
{
	char *name = Browser::Instance ()->UTF8FromIdentifier (id);
	bool res = false;
	
	res = !strcmp (name, "X") || !strcmp (name, "Y");
	
	free (name);
		
	LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::HasProperty (%s): %i\n", getpid (), name, res);

	return res;
}
예제 #2
0
파일: shocker.cpp 프로젝트: 499940913/moon
void
ShockerScriptableControlObject::LogError (const NPVariant *args, uint32_t arg_count, NPVariant *result)
{
	g_assert (arg_count == 1);
	g_assert (NPVARIANT_IS_STRING (args [0]));

	LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::LogError ('%s')\n", getpid (), STR_FROM_VARIANT (args [0]));

#if DEBUG_ERROR_GECKO == 1
	findRealErrorOnStack (this);
#endif
	GetLogProvider ()->LogError (STR_FROM_VARIANT (args [0]));
	BOOLEAN_TO_NPVARIANT (true, *result);
}
예제 #3
0
파일: shocker.cpp 프로젝트: 499940913/moon
void
ShockerScriptableControlObject::MouseRightClick (const NPVariant *args, uint32_t arg_count, NPVariant *result)
{
	unsigned int delay = 0;
	if (arg_count >= 1) {
		g_assert (NPVARIANT_IS_NUMBER (args [0]));
		delay = NUMBER_TO_INT32 (args [0]);
	}

	LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::MouseRightClick (delay: %i)\n", getpid (), delay);

	GetInputProvider ()->MouseRightClick (delay);
	BOOLEAN_TO_NPVARIANT (true, *result);
}
예제 #4
0
파일: plugincallback.c 프로젝트: Tilka/uhub
static int plugin_command_dispatch(struct command_base* cbase, struct hub_user* user, struct hub_command* cmd)
{
	struct plugin_handle* plugin = (struct plugin_handle*) cmd->ptr;
	struct plugin_callback_data* data = get_callback_data(plugin);
	struct plugin_command_handle* cmdh;
	struct plugin_user* puser = (struct plugin_user*) user; // FIXME: Use a proper conversion function instead.
	struct plugin_command* pcommand = (struct plugin_command*) cmd; // FIXME: Use a proper conversion function instead.

	LOG_PLUGIN("plugin_command_dispatch: cmd=%s", cmd->prefix);

	LIST_FOREACH(struct plugin_command_handle*, cmdh, data->commands,
	{
		if (strcmp(cmdh->prefix, cmd->prefix) == 0)
			return cmdh->handler(plugin, puser, pcommand);
	});
예제 #5
0
static NPError
Plugin_Destroy (NPP instance, NPSavedData** save)
{
	LOG_PLUGIN ("[%i shocker] Plugin_Destroy destroying: %p\n", getpid (), instance->pdata);

	if(instance == NULL)
		return NPERR_INVALID_INSTANCE_ERROR;

	PluginObject* plugin = (PluginObject *) instance->pdata;
	if (plugin) {
		plugin->Shutdown ();
		delete plugin;
	}

	return NPERR_NO_ERROR;
}
예제 #6
0
파일: pluginloader.c 프로젝트: junaidk/uhub
void plugin_close(struct uhub_plugin* plugin)
{
	struct plugin_hub_internals* internals = (struct plugin_hub_internals*) plugin->internals;

	LOG_PLUGIN("plugin_close: \"%s\"", plugin->filename);
	plugin_callback_data_destroy(plugin->handle, internals->callback_data);
	hub_free(internals);
	plugin->internals = NULL;

#ifdef HAVE_DLOPEN
	dlclose(plugin->handle);
#else
	FreeLibrary((HMODULE) plugin->handle);
#endif
	hub_free(plugin->filename);
	hub_free(plugin);
}
예제 #7
0
파일: shocker.cpp 프로젝트: 499940913/moon
void
ShockerScriptableControlObject::SendKeyInput (const NPVariant *args, uint32_t arg_count, NPVariant *result)
{
	g_assert (arg_count >= 4);
	g_assert (NPVARIANT_IS_NUMBER (args [0]));
	g_assert (NPVARIANT_IS_BOOLEAN (args [1]));
	g_assert (NPVARIANT_IS_BOOLEAN (args [2]));
	g_assert (NPVARIANT_IS_BOOLEAN (args [3]));

	LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::SendKeyInput (key_code: %i, key_down: %i extended: %i, unicode: %i)\n", getpid (),
		NUMBER_TO_INT32 (args [0]), NPVARIANT_TO_BOOLEAN (args [1]), NPVARIANT_TO_BOOLEAN (args [2]), NPVARIANT_TO_BOOLEAN (args [3]));

	GetInputProvider ()->SendKeyInput (NUMBER_TO_INT32 (args [0]), NPVARIANT_TO_BOOLEAN (args [1]),
		NPVARIANT_TO_BOOLEAN (args [2]), NPVARIANT_TO_BOOLEAN (args [3]));

	BOOLEAN_TO_NPVARIANT (true, *result);
}
예제 #8
0
static NPError
Plugin_New (NPMIMEType type, NPP instance, guint16 mode, gint16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
	if(instance == NULL)
		return NPERR_INVALID_INSTANCE_ERROR;
	
	PluginObject* plugin = new PluginObject (instance, argc, argn, argv);
	if (!plugin)
		return NPERR_OUT_OF_MEMORY_ERROR;

	instance->pdata = (void *) plugin;

	NPError rv = Browser::Instance ()->GetValue (instance, NPNVnetscapeWindow, (void *) &PluginObject::browser_app_context);

	LOG_PLUGIN ("[%i shocker] Plugin_New created: %p\n", getpid (), plugin);

	return rv;
}
예제 #9
0
파일: shocker.cpp 프로젝트: 499940913/moon
void
ShockerScriptableControlObject::CaptureSingleImage (const NPVariant *args, uint32_t arg_count, NPVariant *result)
{
	g_assert (arg_count == 6);
	g_assert (NPVARIANT_IS_STRING (args [0]));
	g_assert (NPVARIANT_IS_STRING (args [1]));
	g_assert (NPVARIANT_IS_NUMBER (args [2]));
	g_assert (NPVARIANT_IS_NUMBER (args [3]));
	g_assert (NPVARIANT_IS_NUMBER (args [4]));
	g_assert (NPVARIANT_IS_NUMBER (args [5]));

	LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::CaptureSingleImage (image_dir: '%s', file_name: '%s', x: %i, y: %i, width: %i, height: %i)\n", getpid (), 
		STR_FROM_VARIANT (args [0]), STR_FROM_VARIANT (args [1]), NUMBER_TO_INT32 (args [2]), NUMBER_TO_INT32 (args [3]), NUMBER_TO_INT32 (args [4]), NUMBER_TO_INT32 (args [5]));

	GetImageCaptureProvider ()->CaptureSingleImage (STR_FROM_VARIANT (args [0]), STR_FROM_VARIANT (args [1]),
			NUMBER_TO_INT32 (args [2]), NUMBER_TO_INT32 (args [3]), NUMBER_TO_INT32 (args [4]), NUMBER_TO_INT32 (args [5]));

	BOOLEAN_TO_NPVARIANT (true, *result);
}
예제 #10
0
파일: shocker.cpp 프로젝트: 499940913/moon
bool
ShockerScriptableControlObject::GetProperty (NPIdentifier id, NPVariant *result)
{
	char *name = Browser::Instance ()->UTF8FromIdentifier (id);
	bool res = false;
	PluginObject *plugin = GetPluginObject ();

	if (!strcmp (name, "X")) {
		INT32_TO_NPVARIANT (plugin->GetX (), *result);
		res = true;
	} else if (!strcmp (name, "Y")) {
		INT32_TO_NPVARIANT (plugin->GetY (), *result);
		res = true;
	}

	LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::GetProperty (%s) x: %i, y: %i => %i\n", getpid (), name, plugin->GetX (), plugin->GetY (), res);

	return res;
}
예제 #11
0
파일: pluginloader.c 프로젝트: junaidk/uhub
static int plugin_parse_line(char* line, int line_count, void* ptr_data)
{
	struct hub_info* hub = (struct hub_info*) ptr_data;
	struct uhub_plugins* handle = hub->plugins;
	struct cfg_tokens* tokens = cfg_tokenize(line);
	struct plugin_handle* plugin;
	char *directive, *soname, *params;

	if (cfg_token_count(tokens) == 0)
	{
		cfg_tokens_free(tokens);
		return 0;
	}

	if (cfg_token_count(tokens) < 2)
	{
		cfg_tokens_free(tokens);
		return -1;
	}

	directive = cfg_token_get_first(tokens);
	soname    = cfg_token_get_next(tokens);
	params    = cfg_token_get_next(tokens);

	if (strcmp(directive, "plugin") == 0 && soname && *soname)
	{
		if (!params)
			params = "";

		LOG_PLUGIN("Load plugin: \"%s\", params=\"%s\"", soname, params);
		plugin = plugin_load(soname, params, hub);
		if (plugin)
		{
			list_append(handle->loaded, plugin);
			cfg_tokens_free(tokens);
			return 0;
		}
	}

	cfg_tokens_free(tokens);
	return -1;
}
예제 #12
0
파일: shocker.cpp 프로젝트: 499940913/moon
bool
ShockerScriptableObject::HasMethod (NPIdentifier id)
{
	bool res = false;
	char *name = Browser::Instance ()->UTF8FromIdentifier (id);
	ShockerScriptableObjectMethod *method = GetMethods ();

	while (method->name) {
		if (!strcmp (name, method->name)) {
			res = true;
			break;
		}
		method++;
	}

	LOG_PLUGIN ("[%i shocker] %s::HasMethod (%s): %i\n", getpid (), GetTypeName (), name, res);

	free (name);
	return res;
}
예제 #13
0
파일: netscape.cpp 프로젝트: kangaroo/moon
NPError
NP_Initialize (NPNetscapeFuncs* mozilla_funcs, NPPluginFuncs* plugin_funcs)
{
	LOG_PLUGIN ("[%i shocker] NP_Initialize\n", getpid ());

	Dl_info dl_info;
	// Prevent firefox from unloading us
	if (dladdr ((void *) &NP_Initialize, &dl_info) != 0) {
		void *handle = dlopen (dl_info.dli_fname, RTLD_LAZY | RTLD_NOLOAD);
		if (handle == NULL)
			printf ("[%i shocker] tried to open a handle to libshocker.so, but: '%s' (rare crashes might occur).\n", getpid (), dlerror ());
	} else {
		printf ("[%i shocker] could not get path of libshocker.so: '%s' (rare crashes might occur).\n", getpid (), dlerror ());
	}
	
	Browser_Initialize (mozilla_funcs);
	Plugin_Initialize (plugin_funcs);
	Shocker_Initialize ();

	return NPERR_NO_ERROR;
}
예제 #14
0
파일: shocker.cpp 프로젝트: 499940913/moon
void
ShockerScriptableControlObject::CompareImages (const NPVariant *args, uint32_t arg_count, NPVariant *result)
{
	guint8 res = false;

	g_assert (arg_count >= 5);
	g_assert (NPVARIANT_IS_STRING (args [0]));
	g_assert (NPVARIANT_IS_STRING (args [1]));
	g_assert (NPVARIANT_IS_NUMBER (args [2]));
	g_assert (NPVARIANT_IS_STRING (args [3]));
	g_assert (NPVARIANT_IS_BOOLEAN (args [4]));

	LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::CompareImages (imageFile1: '%s', imageFile2: '%s', tolerance: %i, diffFileName: '%s', copySourceFiles: %i)\n", getpid (),
		STR_FROM_VARIANT (args [0]), STR_FROM_VARIANT (args [1]), NUMBER_TO_INT32 (args [2]),
		STR_FROM_VARIANT (args [3]), NPVARIANT_TO_BOOLEAN (args [4]));


	::CompareImages (STR_FROM_VARIANT (args [0]), STR_FROM_VARIANT (args [1]), NUMBER_TO_INT32 (args [2]),
		STR_FROM_VARIANT (args [3]), NPVARIANT_TO_BOOLEAN (args [4]), &res);
	
	BOOLEAN_TO_NPVARIANT ((bool) res, *result);
}
예제 #15
0
파일: shocker.cpp 프로젝트: 499940913/moon
bool
ShockerScriptableObject::Invoke (NPIdentifier id, const NPVariant *args, guint32 arg_count, NPVariant *result)
{
	bool res = false;
	char *name = Browser::Instance ()->UTF8FromIdentifier (id);
	ShockerScriptableObjectMethod *method = GetMethods ();

	while (method->name) {
		if (!strcmp (name, method->name)) {
			scriptable_method m = method->Invoke;
			(this->*m) (args, arg_count, result);
			res = true;
			break;
		}
		method++;
	}

	LOG_PLUGIN ("[%i shocker] %s::Invoke (%s): %i\n", getpid (), GetTypeName (), name, res);

	free (name);
	return res;
}
예제 #16
0
파일: shocker.cpp 프로젝트: 499940913/moon
const char *
ShockerScriptableControlObject::GetTestPath ()
{
	if (test_path == NULL) {
		NPVariant nplocation;
		NPVariant nppath;
		NPObject *window = NULL;
		NPIdentifier identifier = Browser::Instance ()->GetStringIdentifier ("location");
	
	
		Browser::Instance ()->GetValue (instance, NPNVWindowNPObject, &window);
		Browser::Instance ()->GetProperty (instance, window, identifier, &nplocation);
	
		identifier = Browser::Instance ()->GetStringIdentifier ("pathname");
		Browser::Instance ()->GetProperty (instance, NPVARIANT_TO_OBJECT (nplocation), identifier, &nppath);
	
		test_path = g_path_get_basename (STR_FROM_VARIANT (nppath));
	}

	LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::GetTestPath (): %s\n", getpid (), test_path);

	return test_path;
}
예제 #17
0
파일: shocker.cpp 프로젝트: 499940913/moon
bool
RenderDataCapturerObject::GetProperty (NPIdentifier id, NPVariant *result)
{
	LOG_PLUGIN ("[%i shocker] RenderDataCapturerObject::GetProperty (%s): nope\n", getpid (), Browser::Instance ()->UTF8FromIdentifier (id));
	return false;
}