From 183ce099a36e0019d0cd049774100f91eeca7c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Thu, 3 Jul 2014 11:59:13 +0000 Subject: 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 --- plugins/CmdLine/src/mimcmd_handlers.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'plugins/CmdLine/src/mimcmd_handlers.cpp') 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)) -- cgit v1.2.3