Added Yahoo Protocol login/logout notifications, patch from Jeremiah Holt, Thanks\!

This commit is contained in:
barrett 2012-03-19 00:29:05 +00:00
parent d237f75f61
commit 0e3579b9c3
2 changed files with 53 additions and 0 deletions

View File

@ -86,6 +86,42 @@ Yahoo::Init( CayaProtocolMessengerInterface* msgr )
return B_OK; return B_OK;
} }
void
Yahoo::_NotifyProgress(const char* title, const char* message, float progress)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_PROGRESS);
msg.AddString("title", title);
msg.AddString("message", message);
msg.AddFloat("progress", progress);
_SendMessage(&msg);
}
void
Yahoo::_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
Yahoo::_SendMessage(BMessage* msg)
{
// Skip invalid messages
if (!msg)
return;
msg->AddString("protocol", kProtocolSignature);
fServerMsgr->SendMessage(msg);
}
status_t status_t
Yahoo::Shutdown() Yahoo::Shutdown()
@ -347,6 +383,11 @@ Yahoo::LoggedIn()
msg.AddInt32("im_what", IM_OWN_STATUS_SET); msg.AddInt32("im_what", IM_OWN_STATUS_SET);
msg.AddString("protocol", kProtocolSignature); msg.AddString("protocol", kProtocolSignature);
msg.AddInt32("status", CAYA_ONLINE); msg.AddInt32("status", CAYA_ONLINE);
BString content(fYahooID);
content << " has logged in!";
_Notify(B_INFORMATION_NOTIFICATION, "Connected",
content.String());
fServerMsgr->SendMessage( &msg ); fServerMsgr->SendMessage( &msg );
} }
@ -386,6 +427,11 @@ Yahoo::LoggedOut()
fYahoo = NULL; fYahoo = NULL;
delete oldYahoo; delete oldYahoo;
} }
BString content(fYahooID);
content << " has logged out!";
_Notify(B_INFORMATION_NOTIFICATION, "Disconnected",
content.String());
} }

View File

@ -3,6 +3,7 @@
#include <String.h> #include <String.h>
#include <Messenger.h> #include <Messenger.h>
#include <Notification.h>
#include <CayaProtocol.h> #include <CayaProtocol.h>
#include <CayaConstants.h> #include <CayaConstants.h>
@ -67,6 +68,12 @@ class Yahoo : public CayaProtocol, public YahooManager
BString fPassword; BString fPassword;
YahooConnection * fYahoo; YahooConnection * fYahoo;
void _NotifyProgress(const char* title,
const char* message, float progress);
void _Notify(notification_type type,
const char* title, const char* message);
void _SendMessage(BMessage* msg);
}; };
#endif #endif