Skip to content

Commit

Permalink
fixup to dbus notifications: only chat msgs have history synopsis
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jul 14, 2014
1 parent 29d5273 commit feb34af
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
22 changes: 13 additions & 9 deletions src/desktop/dbus_notification.cpp
Expand Up @@ -193,7 +193,7 @@ namespace dbus {

const int MAX_MSG_LINES = 5;

void send_notification(const std::string & owner, const std::string & message)
void send_notification(const std::string & owner, const std::string & message, bool with_history)
{
DBusConnection *connection = get_dbus_connection();
if (!connection) return;
Expand All @@ -203,17 +203,21 @@ void send_notification(const std::string & owner, const std::string & message)
wnotify_owner_it i = noticias.find(owner);

if (i != noticias.end()) {
i->message = message + "\n" + i->message;
if (with_history) {
i->message = message + "\n" + i->message;

size_t endl_pos = i->message.find('\n');
size_t ctr = 1;
size_t endl_pos = i->message.find('\n');
size_t ctr = 1;

while (ctr < MAX_MSG_LINES && endl_pos != std::string::npos) {
endl_pos = i->message.find('\n', endl_pos+1);
ctr++;
}
while (ctr < MAX_MSG_LINES && endl_pos != std::string::npos) {
endl_pos = i->message.find('\n', endl_pos+1);
ctr++;
}

i->message = i->message.substr(0,endl_pos);
i->message = i->message.substr(0,endl_pos);
} else {
i->message = message;
}

send_dbus_notification(connection, i->id, owner, i->message);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/desktop/dbus_notification.hpp
Expand Up @@ -18,7 +18,7 @@
#include <string>

namespace dbus {
void send_notification(const std::string& owner, const std::string& message);
void send_notification(const std::string& owner, const std::string& message, bool with_history);
}

#endif
3 changes: 1 addition & 2 deletions src/desktop/notifications.cpp
Expand Up @@ -70,8 +70,7 @@ void send(const std::string& owner, const std::string& message, type t)
}

#ifdef HAVE_LIBDBUS
(void)t;
dbus::send_notification(owner, message);
dbus::send_notification(owner, message, t == CHAT);
#endif

#ifdef HAVE_GROWL
Expand Down

0 comments on commit feb34af

Please sign in to comment.