summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-09-29 00:23:53 +0300
committeraunsane <aunsane@gmail.com>2017-09-29 00:39:19 +0300
commit5709b0dfa9523055ec423e48d411f098ba6882eb (patch)
treef53ed90f801c143e5588543726b61987a8ca9fcb /plugins
parent8d706b4ef942e01814f0a9db519aa32505b9abed (diff)
CmdLine: MirLua support
version bump
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CmdLine/src/mimcmd_data.cpp31
-rw-r--r--plugins/CmdLine/src/mimcmd_data.h2
-rw-r--r--plugins/CmdLine/src/mimcmd_handlers.cpp38
-rw-r--r--plugins/CmdLine/src/stdafx.h2
-rw-r--r--plugins/CmdLine/src/version.h16
5 files changed, 66 insertions, 23 deletions
diff --git a/plugins/CmdLine/src/mimcmd_data.cpp b/plugins/CmdLine/src/mimcmd_data.cpp
index 61c6af89d7..8338c0e48a 100644
--- a/plugins/CmdLine/src/mimcmd_data.cpp
+++ b/plugins/CmdLine/src/mimcmd_data.cpp
@@ -24,23 +24,24 @@ TCommand mimCommands[] =
{
{ MIMCMD_STATUS, "status", MIMCMD_HELP_STATUS },
{ MIMCMD_AWAYMSG, "awaymsg", MIMCMD_HELP_AWAYMSG },
- { MIMCMD_XSTATUS, "xstatus", MIMCMD_HELP_XSTATUS },
- { MIMCMD_POPUPS, "popups", MIMCMD_HELP_POPUPS },
- { MIMCMD_SOUNDS, "sounds", MIMCMD_HELP_SOUNDS },
- { MIMCMD_CLIST, "clist", MIMCMD_HELP_CLIST },
- { MIMCMD_QUIT, "quit", MIMCMD_HELP_QUIT },
- { MIMCMD_HELP, "help", MIMCMD_HELP_HELP },
- { MIMCMD_EXCHANGE, "exchange", MIMCMD_HELP_EXCHANGE },
- { MIMCMD_YAMN, "yamn", MIMCMD_HELP_YAMN },
- { MIMCMD_CALLSERVICE, "callservice", MIMCMD_HELP_CALLSERVICE },
- { MIMCMD_MESSAGE, "message", MIMCMD_HELP_MESSAGE },
- { MIMCMD_DATABASE, "db", MIMCMD_HELP_DATABASE },
- { MIMCMD_PROXY, "proxy", MIMCMD_HELP_PROXY },
- { MIMCMD_CONTACTS, "contacts", MIMCMD_HELP_CONTACTS },
- { MIMCMD_HISTORY, "history", MIMCMD_HELP_HISTORY },
- { MIMCMD_VERSION, "version", MIMCMD_HELP_VERSION },
+ { MIMCMD_XSTATUS, "xstatus", MIMCMD_HELP_XSTATUS },
+ { MIMCMD_POPUPS, "popups", MIMCMD_HELP_POPUPS },
+ { MIMCMD_SOUNDS, "sounds", MIMCMD_HELP_SOUNDS },
+ { MIMCMD_CLIST, "clist", MIMCMD_HELP_CLIST },
+ { MIMCMD_QUIT, "quit", MIMCMD_HELP_QUIT },
+ { MIMCMD_HELP, "help", MIMCMD_HELP_HELP },
+ { MIMCMD_EXCHANGE, "exchange", MIMCMD_HELP_EXCHANGE },
+ { MIMCMD_YAMN, "yamn", MIMCMD_HELP_YAMN },
+ { MIMCMD_CALLSERVICE, "callservice", MIMCMD_HELP_CALLSERVICE },
+ { MIMCMD_MESSAGE, "message", MIMCMD_HELP_MESSAGE },
+ { MIMCMD_DATABASE, "db", MIMCMD_HELP_DATABASE },
+ { MIMCMD_PROXY, "proxy", MIMCMD_HELP_PROXY },
+ { MIMCMD_CONTACTS, "contacts", MIMCMD_HELP_CONTACTS },
+ { MIMCMD_HISTORY, "history", MIMCMD_HELP_HISTORY },
+ { MIMCMD_VERSION, "version", MIMCMD_HELP_VERSION },
{ MIMCMD_SETNICKNAME, "setnickname", MIMCMD_HELP_SETNICKNAME },
{ MIMCMD_IGNORE, "ignore", MIMCMD_HELP_IGNORE },
+ { MIMCMD_LUA, "lua", MIMCMD_HELP_LUA },
};
int cMimCommands = sizeof(mimCommands) / sizeof(mimCommands[0]); \ No newline at end of file
diff --git a/plugins/CmdLine/src/mimcmd_data.h b/plugins/CmdLine/src/mimcmd_data.h
index 0cea4b2ac1..3718bb3ac6 100644
--- a/plugins/CmdLine/src/mimcmd_data.h
+++ b/plugins/CmdLine/src/mimcmd_data.h
@@ -87,6 +87,7 @@ typedef TSharedData *PSharedData;
#define MIMCMD_VERSION 17
#define MIMCMD_SETNICKNAME 18
#define MIMCMD_IGNORE 19
+#define MIMCMD_LUA 20
#define MIMCMD_HELP_STATUS LPGEN("Changes account status either globally or per account.\nUsage: status <status> [<account>].\nPossible values for <status> are: offline, online, away, dnd, na, occupied, freechat, invisible, onthephone, outtolunch.\n<Account> is an optional parameter specifying the account to set the status for. If it's not specified then the command will issue a global status change.")
#define MIMCMD_HELP_AWAYMSG LPGEN("Changes away message either globally or per account.\nUsage: awaymsg <message> [<account>].\n<Message> is the new away message.\n<Account> is an optional parameter specifying the account to set the away message for. If not specified then the away message will be set globally.")
@@ -107,6 +108,7 @@ typedef TSharedData *PSharedData;
#define MIMCMD_HELP_VERSION LPGEN("Shows version information for Miranda and CmdLine plugin. If CrashDumper plugin is installed, it will use its report instead.\nUsage: version.\nThe command will print Miranda's and CmdLine's version numbers or, if CrashDumper plugin is installed, it will show Version Info report.")
#define MIMCMD_HELP_SETNICKNAME LPGEN("Changes the user's nickname on the given protocol to the new name.\nUsage: setnickname <protocol> new_nickname.")
#define MIMCMD_HELP_IGNORE LPGEN("Ignores or removes ignore flags for specific contacts.\nUsage:\n ignore (block | unblock) <contact> [<contact> [<contact> [...]]].\nThe command will set or remove ignore flags for the specified contacts")
+#define MIMCMD_HELP_LUA LPGEN("Execute lua script via MirLua plugin.\nUsage:\n call [<module>] <function>\n exec \"<path>\"\n eval \"<code>\"")
#define MIMMEM_REPLY 1 //data is a PReply structure
diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp
index 05c1bbed22..ca84413487 100644
--- a/plugins/CmdLine/src/mimcmd_handlers.cpp
+++ b/plugins/CmdLine/src/mimcmd_handlers.cpp
@@ -1610,6 +1610,40 @@ void HandleIgnoreCommand(PCommand command, TArgument *argv, int argc, PReply rep
else HandleWrongParametersCount(command, reply);
}
+void HandleLuaCommand(PCommand command, TArgument *argv, int argc, PReply reply)
+{
+ if (argc <= 3) {
+ HandleWrongParametersCount(command, reply);
+ return;
+ }
+
+ if (_stricmp(argv[2], "call") == 0) {
+ wchar_t *result = argc == 4
+ ? lua_call(NULL, _A2T(argv[3]))
+ : lua_call(_A2T(argv[3]), _A2T(argv[4]));
+ mir_strcpy(reply->message, _T2A(result));
+ mir_free(result);
+ reply->code = MIMRES_SUCCESS;
+ return;
+ }
+
+ if (_stricmp(argv[2], "exec") == 0) {
+ ptrW result(lua_exec(_A2T(argv[3])));
+ mir_strcpy(reply->message, _T2A(result));
+ reply->code = MIMRES_SUCCESS;
+ return;
+ }
+
+ if (_stricmp(argv[2], "eval") == 0) {
+ ptrW result(lua_eval(_A2T(argv[3])));
+ mir_strcpy(reply->message, _T2A(result));
+ reply->code = MIMRES_SUCCESS;
+ return;
+ }
+
+ HandleUnknownParameter(command, argv[2], reply);
+}
+
void HandleCommand(PCommand command, TArgument *argv, int argc, PReply reply)
{
switch (command->ID) {
@@ -1681,6 +1715,10 @@ void HandleCommand(PCommand command, TArgument *argv, int argc, PReply reply)
HandleIgnoreCommand(command, argv, argc, reply);
return;
+ case MIMCMD_LUA:
+ HandleLuaCommand(command, argv, argc, reply);
+ return;
+
default:
reply->code = MIMRES_NOTFOUND;
mir_snprintf(reply->message, Translate("Command '%s' is not currently supported."), command->command);
diff --git a/plugins/CmdLine/src/stdafx.h b/plugins/CmdLine/src/stdafx.h
index 527f179566..0cdff59745 100644
--- a/plugins/CmdLine/src/stdafx.h
+++ b/plugins/CmdLine/src/stdafx.h
@@ -42,6 +42,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "m_crashdumper.h"
#include "m_statusplugins.h"
+#include "m_lua.h"
+
#include "version.h"
#include "utils.h"
#include "resource.h"
diff --git a/plugins/CmdLine/src/version.h b/plugins/CmdLine/src/version.h
index 11275081d5..2fcfc361cd 100644
--- a/plugins/CmdLine/src/version.h
+++ b/plugins/CmdLine/src/version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 0
-#define __RELEASE_NUM 4
-#define __BUILD_NUM 6
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 0
+#define __RELEASE_NUM 4
+#define __BUILD_NUM 7
#include <stdver.h>
-#define __PLUGIN_NAME "Command line"
-#define __FILENAME "CmdLine.dll"
+#define __PLUGIN_NAME "Command line"
+#define __FILENAME "CmdLine.dll"
#define __DESCRIPTION "This plugin lets you control Miranda from the command line."
-#define __AUTHOR "Cristian Libotean"
-#define __AUTHOREMAIL "eblis102@yahoo.com"
+#define __AUTHOR "Cristian Libotean"
+#define __AUTHOREMAIL "eblis102@yahoo.com"
#define __AUTHORWEB "https://miranda-ng.org/p/CmdLine/"
#define __COPYRIGHT "© 2007-2011 Cristian Libotean"