Send information notifications instead of progress notifications when we are connected or disconnected to the server.

This commit is contained in:
plfiorini 2010-05-30 18:57:19 +00:00
parent 068cd849ae
commit 6478101579
2 changed files with 23 additions and 5 deletions

View File

@ -219,7 +219,19 @@ JabberHandler::_SendMessage(BMessage* msg)
void void
JabberHandler::_Progress(const char* title, const char* message, float progress) JabberHandler::_Notify(notification_type type, const char* title, const char* message)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_NOTIFICATION);
msg.AddInt32("type", (int32)type);
msg.AddString("title", title);
msg.AddString("message", message);
_SendMessage(&msg);
}
void
JabberHandler::_NotifyProgress(const char* title, const char* message, float progress)
{ {
BMessage msg(IM_MESSAGE); BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_PROGRESS); msg.AddInt32("im_what", IM_PROGRESS);
@ -416,7 +428,8 @@ JabberHandler::onConnect()
BString content(fUsername); BString content(fUsername);
content << " has logged in!"; content << " has logged in!";
_Progress("Connected", content.String(), 1.0f); _Notify(B_INFORMATION_NOTIFICATION, "Connected",
content.String());
fVCardManager->fetchVCard(fJid, this); fVCardManager->fetchVCard(fJid, this);
} }
@ -432,7 +445,8 @@ JabberHandler::onDisconnect(gloox::ConnectionError e)
BString content(fUsername); BString content(fUsername);
content << " has logged out!"; content << " has logged out!";
_Progress("Disconnected", content.String(), 1.0f); _Notify(B_INFORMATION_NOTIFICATION, "Disconnected",
content.String());
} }
@ -556,7 +570,7 @@ JabberHandler::handleItemUpdated(const gloox::JID&)
void void
JabberHandler::handleRosterPresence(const gloox::RosterItem& item, JabberHandler::handleRosterPresence(const gloox::RosterItem& item,
const std::string&, const std::string& resource,
gloox::Presence::PresenceType type, gloox::Presence::PresenceType type,
const std::string& presenceMsg) const std::string& presenceMsg)
{ {
@ -564,6 +578,7 @@ JabberHandler::handleRosterPresence(const gloox::RosterItem& item,
msg.AddInt32("im_what", IM_STATUS_SET); msg.AddInt32("im_what", IM_STATUS_SET);
msg.AddString("id", item.jid().c_str()); msg.AddString("id", item.jid().c_str());
msg.AddInt32("status", _GlooxStatusToCaya(type)); msg.AddInt32("status", _GlooxStatusToCaya(type));
msg.AddString("resource", resource.c_str());
msg.AddString("message", presenceMsg.c_str()); msg.AddString("message", presenceMsg.c_str());
_SendMessage(&msg); _SendMessage(&msg);
} }

View File

@ -5,6 +5,7 @@
#ifndef _JABBER_HANDLER_H #ifndef _JABBER_HANDLER_H
#define _JABBER_HANDLER_H #define _JABBER_HANDLER_H
#include <Notification.h>
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
@ -80,7 +81,9 @@ private:
void _MessageSent(const char* id, const char* subject, void _MessageSent(const char* id, const char* subject,
const char* body); const char* body);
void _Progress(const char* title, const char* message, float progress);
void _Notify(notification_type type, const char* title, const char* message);
void _NotifyProgress(const char* title, const char* message, float progress);
status_t _SetupAvatarCache(); status_t _SetupAvatarCache();
status_t _SaveAvatarCache(); status_t _SaveAvatarCache();