Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/mumble/EnumStringConversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@
PROCESS(Log::MsgType, PrivateTextMessage, "PrivateTextMessage") \
PROCESS(Log::MsgType, ChannelListeningAdd, "ChannelListeningAdd") \
PROCESS(Log::MsgType, ChannelListeningRemove, "ChannelListeningRemove") \
PROCESS(Log::MsgType, PluginMessage, "PluginMessage")
PROCESS(Log::MsgType, PluginMessage, "PluginMessage") \
PROCESS(Log::MsgType, ImageMessage, "ImageMessage") \
PROCESS(Log::MsgType, PrivateImageMessage, "PrivateImageMessage")

#define OVERLAY_PRESETS_VALUES \
PROCESS(OverlaySettings::OverlayPresets, AvatarAndName, "AvatarAndName") \
Expand Down
8 changes: 7 additions & 1 deletion src/mumble/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ const Log::MsgType Log::msgOrder[] = { DebugInfo,
PermissionDenied,
TextMessage,
PrivateTextMessage,
ImageMessage,
PrivateImageMessage,
PluginMessage };

Comment thread
28arnab marked this conversation as resolved.
const char *Log::msgNames[] = { QT_TRANSLATE_NOOP("Log", "Debug"),
Expand Down Expand Up @@ -494,7 +496,9 @@ const char *Log::msgNames[] = { QT_TRANSLATE_NOOP("Log", "Debug"),
QT_TRANSLATE_NOOP("Log", "Private text message"),
QT_TRANSLATE_NOOP("Log", "User started listening to channel"),
QT_TRANSLATE_NOOP("Log", "User stopped listening to channel"),
QT_TRANSLATE_NOOP("Log", "Plugin message") };
QT_TRANSLATE_NOOP("Log", "Plugin message"),
QT_TRANSLATE_NOOP("Log", "Image message"),
QT_TRANSLATE_NOOP("Log", "Private image message") };

QString Log::msgName(MsgType t) const {
return tr(msgNames[t]);
Expand Down Expand Up @@ -840,6 +844,8 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
break;
case TextMessage:
case PrivateTextMessage:
case ImageMessage:
case PrivateImageMessage:
msgIcon = QSystemTrayIcon::NoIcon;
break;
case Information:
Expand Down
6 changes: 4 additions & 2 deletions src/mumble/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ class Log : public QObject {
PrivateTextMessage,
ChannelListeningAdd,
ChannelListeningRemove,
PluginMessage
PluginMessage,
ImageMessage,
PrivateImageMessage
};

enum LogColorType { Time, Server, Privilege, Source, Target };
static const MsgType firstMsgType = DebugInfo;
static const MsgType lastMsgType = ChannelListeningRemove;
static const MsgType lastMsgType = PrivateImageMessage;

// Display order in settingsscreen, allows to insert new events without breaking config-compatibility with older
// versions.
Expand Down
29 changes: 26 additions & 3 deletions src/mumble/Messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "crypto/CryptStateOCB2.h"
#include "Global.h"

#include <QRegularExpression>
#include <QTextDocumentFragment>

#define ACTOR_INIT \
Expand Down Expand Up @@ -1038,9 +1039,31 @@ void MainWindow::msgTextMessage(const MumbleProto::TextMessage &msg) {

const QString prefixMessage = target.isEmpty() ? name : tr("(%1) %2").arg(target).arg(name);

Global::get().l->log(privateMessage ? Log::PrivateTextMessage : Log::TextMessage,
tr("%1: %2").arg(prefixMessage).arg(u8(msg.message())), tr("Message from %1").arg(plainName),
false, overrideTTS, pSrc ? pSrc->bLocalIgnoreTTS : false);
// Determine if this message contains an image embed
const QString messageContent = u8(msg.message());
const QRegularExpression imageTagRegex(QLatin1String("<\\s*img\\b"),
QRegularExpression::CaseInsensitiveOption);
const bool hasImage = imageTagRegex.match(messageContent).hasMatch();

// Select the appropriate message type based on whether the message contains images
Log::MsgType msgType;
if (hasImage) {
if (privateMessage) {
msgType = Log::PrivateImageMessage;
} else {
msgType = Log::ImageMessage;
}
} else {
if (privateMessage) {
msgType = Log::PrivateTextMessage;
} else {
msgType = Log::TextMessage;
}
}

Global::get().l->log(msgType, tr("%1: %2").arg(prefixMessage).arg(messageContent),
tr("Message from %1").arg(plainName), false, overrideTTS,
pSrc ? pSrc->bLocalIgnoreTTS : false);
}

/// This message is being received when the server informs the client about the access control list (ACL) for
Expand Down
2 changes: 2 additions & 0 deletions src/mumble/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ Settings::Settings() {
qmMessageSounds[Log::YouMuted] = QLatin1String(":/UserMutedYouOrByYou.ogg");
qmMessageSounds[Log::YouKicked] = QLatin1String(":/UserKickedYouOrByYou.ogg");
qmMessageSounds[Log::Recording] = QLatin1String(":/RecordingStateChanged.ogg");
qmMessageSounds[Log::ImageMessage] = qmMessageSounds[Log::TextMessage];
qmMessageSounds[Log::PrivateImageMessage] = qmMessageSounds[Log::TextMessage];

qmMessages[Log::DebugInfo] = Settings::LogConsole;
qmMessages[Log::Warning] = Settings::LogConsole | Settings::LogBalloon;
Expand Down
Loading