summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2009-06-24 21:51:59 +0200
committerSamuel Lidén Borell <samuel@slbdata.se>2010-01-02 22:30:10 +0100
commit20f3db961b88a6f4a65b99b48260a616634e398b (patch)
tree54d107b234e8fb0bed9ec0490e8710d9056cecff /plugin
parent0a00154cc95c1c3238bfba745f2e7427b64aa338 (diff)
downloadfribid-20f3db961b88a6f4a65b99b48260a616634e398b.tar.gz
fribid-20f3db961b88a6f4a65b99b48260a616634e398b.tar.bz2
fribid-20f3db961b88a6f4a65b99b48260a616634e398b.zip
Fixed the return values of GetParam and PerformAction
Diffstat (limited to 'plugin')
-rw-r--r--plugin/ipc.c4
-rw-r--r--plugin/npobject.c6
-rw-r--r--plugin/plugin.c8
-rw-r--r--plugin/test.html3
4 files changed, 11 insertions, 10 deletions
diff --git a/plugin/ipc.c b/plugin/ipc.c
index bece516..5f48856 100644
--- a/plugin/ipc.c
+++ b/plugin/ipc.c
@@ -131,7 +131,7 @@ int sign_performAction_Authenticate(Plugin *plugin) {
plugin->lastError = pipe_readInt(pipein);
plugin->info.auth.signature = pipe_readString(pipein);
closePipes();
- return (strlen(plugin->info.auth.signature) != 0 ? 0 : 1);
+ return plugin->lastError;
}
int sign_performAction_Sign(Plugin *plugin) {
@@ -147,7 +147,7 @@ int sign_performAction_Sign(Plugin *plugin) {
plugin->lastError = pipe_readInt(pipein);
plugin->info.auth.signature = pipe_readString(pipein);
closePipes();
- return (strlen(plugin->info.auth.signature) != 0 ? 0 : 1);
+ return plugin->lastError;
}
diff --git a/plugin/npobject.c b/plugin/npobject.c
index 6d6fea3..0dc29c8 100644
--- a/plugin/npobject.c
+++ b/plugin/npobject.c
@@ -207,10 +207,12 @@ static bool objInvoke(NPObject *npobj, NPIdentifier ident,
// Get parameter
char *param = strndup(NPVARIANT_TO_STRING(args[0]).utf8characters, NPVARIANT_TO_STRING(args[0]).utf8length);
- char *s = npstr(sign_getParam(this->plugin, param));
+ char *value = sign_getParam(this->plugin, param);
free(param);
- STRINGZ_TO_NPVARIANT(s, *result);
+ if (value) STRINGZ_TO_NPVARIANT(npstr(value), *result);
+ else NULL_TO_NPVARIANT(*result);
+
return true;
} else if (!strcmp(name, "SetParam") && (argCount == 2) &&
NPVARIANT_IS_STRING(args[0]) && NPVARIANT_IS_STRING(args[1])) {
diff --git a/plugin/plugin.c b/plugin/plugin.c
index ebf75c8..3dc3e7b 100644
--- a/plugin/plugin.c
+++ b/plugin/plugin.c
@@ -85,12 +85,10 @@ static char **getParamPointer(Plugin *plugin, const char *name) {
}
char *sign_getParam(Plugin *plugin, const char *name) {
- char **valuePtr = getParamPointer(plugin, name);
-
- char *value = NULL;
- if (valuePtr && *valuePtr) value = strdup(*valuePtr);
+ const char **valuePtr = getParamPointer(plugin, name);
- return (value != NULL ? value : strdup(""));
+ if (valuePtr && *valuePtr) return strdup(*valuePtr);
+ else return NULL;
}
bool sign_setParam(Plugin *plugin, const char *name, const char *value) {
diff --git a/plugin/test.html b/plugin/test.html
index 2f928e7..cd34256 100644
--- a/plugin/test.html
+++ b/plugin/test.html
@@ -17,8 +17,9 @@ function init() {
output.value += "Calling SetParam(Challenge)\n";
pluginAuth.SetParam("Challenge", "MTI0MzYwMTMyOTk5NTU3MTI4OTg0MjkwMzY3OTYwODM=");
output.value += "Calling SetParam(Policys)\n";
- pluginAuth.SetParam("Policys", "MS4yLjc1Mi43OC4xLjE7MS4yLjc1Mi43OC4xLjI7MS4yLjMuNC41OzEuMi4zLjQuMTA=");
+ var retval = pluginAuth.SetParam("Policys", "MS4yLjc1Mi43OC4xLjE7MS4yLjc1Mi43OC4xLjI7MS4yLjMuNC41OzEuMi4zLjQuMTA=");
+ output.value += "retval of sp = "+retval+"\n";
output.value += "\nGetParam:\n";
output.value += " Challenge: >"+pluginAuth.GetParam("Challenge")+"<\n";
output.value += " Policys: >"+pluginAuth.GetParam("Policys")+"<\n";