summaryrefslogtreecommitdiff
path: root/plugins/CmdLine/src/mimcmd_handlers.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-07-03 11:59:13 +0000
committerRobert Pösel <robyer@seznam.cz>2014-07-03 11:59:13 +0000
commit183ce099a36e0019d0cd049774100f91eeca7c48 (patch)
tree0f257f44600e91fc3bb1645f2769d9f0fbc873e7 /plugins/CmdLine/src/mimcmd_handlers.cpp
parentd9ede0b18399ddc87808b71daa8ba3d8b8dc6a9c (diff)
CmdLine: Support for new lines (\n) in message text (as requested on UserVoice)
git-svn-id: http://svn.miranda-ng.org/main/trunk@9660 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CmdLine/src/mimcmd_handlers.cpp')
-rw-r--r--plugins/CmdLine/src/mimcmd_handlers.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp
index 6552deb408..20c6c63b4a 100644
--- a/plugins/CmdLine/src/mimcmd_handlers.cpp
+++ b/plugins/CmdLine/src/mimcmd_handlers.cpp
@@ -1,7 +1,7 @@
/*
CmdLine plugin for Miranda IM
-Copyright © 2007 Cristian Libotean
+Copyright � 2007 Cristian Libotean
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -1065,6 +1065,18 @@ void HandleCallServiceCommand(PCommand command, TArgument *argv, int argc, PRepl
}
}
+void ParseMessage(char buffer[512], const char *message) {
+ unsigned int j = 0;
+ for (unsigned int i = 0; i < strlen(message); ++i) {
+ char c = message[i];
+ if (c == '\\' && i < (strlen(message) - 1) && message[i+1] == 'n') {
+ c = '\n';
+ i++;
+ }
+ buffer[j++] = c;
+ }
+ buffer[j] = '\0';
+}
MCONTACT ParseContactParam(char *contact)
{
@@ -1095,22 +1107,20 @@ void HandleMessageCommand(PCommand command, TArgument *argv, int argc, PReply re
{
if (argc >= 4)
{
- char *message = argv[argc - 1]; //get the message
- int i;
- char *contact;
+ char message[512];
+ ParseMessage(message, argv[argc - 1]); //get the message
+
char buffer[1024];
- MCONTACT hContact;
- HANDLE hProcess = NULL;
ACKDATA *ack = NULL;
- for (i = 2; i < argc - 1; i++)
+ for (int i = 2; i < argc - 1; i++)
{
- contact = argv[i];
- hContact = ParseContactParam(contact);
+ char *contact = argv[i];
+ MCONTACT hContact = ParseContactParam(contact);
if (hContact)
{
bShouldProcessAcks = TRUE;
- hProcess = (HANDLE) CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM) message);
+ HANDLE hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)message);
const int MAX_COUNT = 60;
int counter = 0;
while (((ack = GetAck(hProcess)) == NULL) && (counter < MAX_COUNT))