Hi,

what about changing the PROPERTY into WHATIS. I'll modify the patch to use this command name if no-one objects.

- Jeroen

[EMAIL PROTECTED] wrote:

Probably, the command name should be changed.
I hate to produce patches with paths like this, but I'm too lazy to
work on it through CVS. (And my hard disk space is long gone, which
does not allow me to have another copy of gtk-gnutella source).

This patch allows remote shell to print info about a property named.
Write the command:
PROPERTY <property-name>
and it will give you a tooltip about what the property means.

Regards,

Thadeu Cascardo.

------------------------------------------------------------------------

--- src/shell.c 2003-12-05 12:18:05.000000000 -0200
+++ ../shell.c  2003-12-03 13:25:57.000000000 -0200
@@ -74,7 +74,8 @@
        CMD_ADD,
        CMD_HELP,
        CMD_PRINT,
-       CMD_SET
+       CMD_SET,
+       CMD_PROP
};

static struct {
@@ -87,7 +88,8 @@
        {CMD_ADD,    "ADD"},
        {CMD_HELP,   "HELP"},
        {CMD_PRINT,  "PRINT"},
-       {CMD_SET,    "SET"}
+       {CMD_SET,    "SET"},
+       {CMD_PROP,   "PROPERTY"}
};


@@ -494,6 +496,71 @@ return REPLY_ERROR; }

+static guint shell_exec_prop(gnutella_shell_t *sh, const gchar *cmd) +{
+ gchar *tok_prop;
+ gint pos = 0;
+ guint reply_code = REPLY_ERROR;
+ prop_set_stub_t *stub = NULL;
+ property_t prop;
+ prop_set_get_stub_t stub_getter[] = {
+ gui_prop_get_stub,
+ gnet_prop_get_stub,
+ NULL
+ };
+ prop_def_t *prop_buf = NULL;
+ guint n;
+
+ g_assert(sh);
+ g_assert(cmd);
+ g_assert(!IS_PROCESSING(sh));
+
+ tok_prop = shell_get_token(cmd, &pos);
+ if (!tok_prop) {
+ sh->msg = "Property missing";
+ goto error;
+ }
+
+ n = 0; prop = NO_PROP;
+ while((stub_getter[n] != NULL) && (prop == NO_PROP)) {
+ G_FREE_NULL(stub);
+ stub = (stub_getter[n])();
+ prop = stub->get_by_name(tok_prop);
+ n ++;
+ }
+
+ if (prop == NO_PROP) {
+ sh->msg = "Unknown property";
+ goto error;
+ }
+
+ prop_buf = stub->get_def (prop);
+
+ g_assert (prop_buf);
+
+ shell_write(sh, "Help: ");
+ shell_write(sh, prop_buf->desc);
+ shell_write(sh, "\n");
+
+ sh->msg = "";
+ reply_code = REPLY_READY;
+
+ G_FREE_NULL(stub);
+ G_FREE_NULL(tok_prop);
+ prop_free_def (prop_buf);
+
+ return reply_code;
+
+error:
+ G_FREE_NULL(stub);
+ G_FREE_NULL(tok_prop);
+ if (sh->msg == NULL)
+ sh->msg = "Malformed command";
+
+ return REPLY_ERROR;
+}
+
+
/*
* shell_exec:
*
@@ -519,8 +586,9 @@
"100-Help:\n"
"100-SEARCH ADD <query>\n"
"100-NODE ADD <ip> [port]\n"
- "100-PRINT [property]\n"
+ "100-PRINT <property>\n"
"100-SET <property> <value>\n"
+ "100-PROPERTY <property>\n"
"100-QUIT\n"
"100-HELP\n");
reply_code = REPLY_READY;
@@ -542,6 +610,9 @@
case CMD_SET:
reply_code = shell_exec_set(sh, cmd+pos);
break;
+ case CMD_PROP:
+ reply_code = shell_exec_prop(sh, cmd+pos);
+ break;
default:
goto error;
}






-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Gtk-gnutella-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/gtk-gnutella-devel

Reply via email to