Patch from Maciej Janiszewski which adds support for hiding offline contacts, message notifications and caya can now set the window title to unread state, all functions can be disabled from settings as well. Thanks\!
This commit is contained in:
parent
53c5c02d66
commit
007af3d89a
|
@ -22,10 +22,12 @@
|
|||
#include <SpaceLayoutItem.h>
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
#include <Notification.h>
|
||||
|
||||
#include "BitmapView.h"
|
||||
#include "CayaMessages.h"
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "CayaPreferences.h"
|
||||
#include "ChatWindow.h"
|
||||
#include "ContactLinker.h"
|
||||
#include "EditingFilter.h"
|
||||
|
@ -188,6 +190,32 @@ ChatWindow::ImMessage(BMessage* msg)
|
|||
|
||||
// Message received, clear status anyway
|
||||
fStatus->SetText("");
|
||||
|
||||
if (IsActive()) break;
|
||||
|
||||
// Mark unread window
|
||||
if (CayaPreferences::Item()->MarkUnreadWindow) {
|
||||
BString title = "[*] ";
|
||||
title<<fContactLinker->GetName();
|
||||
SetTitle(title);
|
||||
}
|
||||
|
||||
// Check if the user want the notification
|
||||
if (!CayaPreferences::Item()->NotifyNewMessage)
|
||||
break;
|
||||
|
||||
BString notify_message;
|
||||
notify_message << "You've got new message from ";
|
||||
notify_message << fContactLinker->GetName().String();
|
||||
|
||||
|
||||
BNotification notification(B_INFORMATION_NOTIFICATION);
|
||||
notification.SetGroup(BString("Caya"));
|
||||
notification.SetTitle(BString("New message"));
|
||||
notification.SetIcon(fAvatar->Bitmap());
|
||||
notification.SetContent(notify_message);
|
||||
notification.Send();
|
||||
|
||||
break;
|
||||
}
|
||||
case IM_CONTACT_STARTED_TYPING:
|
||||
|
@ -206,6 +234,11 @@ ChatWindow::ImMessage(BMessage* msg)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ChatWindow::WindowActivated(bool active)
|
||||
{
|
||||
SetTitle(fContactLinker->GetName());
|
||||
}
|
||||
|
||||
void
|
||||
ChatWindow::ObserveString(int32 what, BString str)
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
virtual void ShowWindow();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
void WindowActivated(bool active);
|
||||
virtual bool QuitRequested();
|
||||
|
||||
void UpdateAvatar();
|
||||
|
|
|
@ -278,11 +278,13 @@ MainWindow::ImMessage(BMessage* msg)
|
|||
|
||||
// Add or remove item
|
||||
switch (status) {
|
||||
case CAYA_OFFLINE:
|
||||
/*case CAYA_OFFLINE:
|
||||
// By default offline contacts are hidden
|
||||
if (!CayaPreferences::Item()->HideOffline)
|
||||
break;
|
||||
if (HasItem(rosterItem))
|
||||
RemoveItem(rosterItem);
|
||||
return;
|
||||
return;*/
|
||||
default:
|
||||
// Add item because it has a non-offline status
|
||||
if (!HasItem(rosterItem))
|
||||
|
@ -377,7 +379,11 @@ void
|
|||
MainWindow::AddItem(RosterItem* item)
|
||||
{
|
||||
// Don't add offline items and avoid duplicates
|
||||
if ((item->Status() == CAYA_OFFLINE) || HasItem(item))
|
||||
if ((item->Status() == CAYA_OFFLINE)
|
||||
&& CayaPreferences::Item()->HideOffline)
|
||||
return;
|
||||
|
||||
if (HasItem(item))
|
||||
return;
|
||||
|
||||
// Add item and sort
|
||||
|
|
|
@ -16,11 +16,14 @@ CayaPreferencesData::CayaPreferencesData()
|
|||
MoveToCurrentWorkspace(true),
|
||||
RaiseOnMessageReceived(false),
|
||||
RaiseUserIsTyping(false),
|
||||
MarkUnreadWindow(true),
|
||||
HideCayaDeskbar(false),
|
||||
DisableReplicant(true),
|
||||
IgnoreEmoticons(false),
|
||||
NotifyProtocolStatus(true),
|
||||
NotifyContactStatus(false)
|
||||
NotifyContactStatus(false),
|
||||
NotifyNewMessage(true),
|
||||
HideOffline(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -60,7 +63,7 @@ CayaPreferencesData::FlattenedSize() const
|
|||
// NOTE add the size of every settings
|
||||
// you added.
|
||||
|
||||
ssize_t size = sizeof(bool) * 8;
|
||||
ssize_t size = sizeof(bool) * 11;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
@ -80,9 +83,11 @@ CayaPreferencesData::Flatten(BPositionIO* flatData) const
|
|||
_AddBool(flatData, MoveToCurrentWorkspace);
|
||||
_AddBool(flatData, RaiseOnMessageReceived);
|
||||
_AddBool(flatData, RaiseUserIsTyping);
|
||||
_AddBool(flatData, MarkUnreadWindow);
|
||||
|
||||
_AddBool(flatData, NotifyProtocolStatus);
|
||||
_AddBool(flatData, NotifyContactStatus);
|
||||
_AddBool(flatData, NotifyNewMessage);
|
||||
|
||||
// Replicant
|
||||
_AddBool(flatData, HideCayaDeskbar);
|
||||
|
@ -90,6 +95,9 @@ CayaPreferencesData::Flatten(BPositionIO* flatData) const
|
|||
|
||||
// Chat window
|
||||
_AddBool(flatData, IgnoreEmoticons);
|
||||
|
||||
// Contact list
|
||||
_AddBool(flatData, HideOffline);
|
||||
|
||||
// Usage example for strings :
|
||||
// _AddString(flatData, yourBString.String());
|
||||
|
@ -97,8 +105,6 @@ CayaPreferencesData::Flatten(BPositionIO* flatData) const
|
|||
// NOTE : The order is very important, Unflatten and Flatten
|
||||
// classes should read/write the values in the same order.
|
||||
|
||||
_AddString(flatData, "str");
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
@ -144,9 +150,11 @@ CayaPreferencesData::Unflatten(type_code code, BPositionIO* flatData)
|
|||
MoveToCurrentWorkspace = _ReadBool(flatData);
|
||||
RaiseOnMessageReceived = _ReadBool(flatData);
|
||||
RaiseUserIsTyping = _ReadBool(flatData);
|
||||
MarkUnreadWindow = _ReadBool(flatData);
|
||||
|
||||
NotifyProtocolStatus = _ReadBool(flatData);
|
||||
NotifyContactStatus = _ReadBool(flatData);
|
||||
NotifyNewMessage = _ReadBool(flatData);
|
||||
|
||||
// Replicant
|
||||
HideCayaDeskbar = _ReadBool(flatData);
|
||||
|
@ -154,6 +162,9 @@ CayaPreferencesData::Unflatten(type_code code, BPositionIO* flatData)
|
|||
|
||||
// Chat window
|
||||
IgnoreEmoticons = _ReadBool(flatData);
|
||||
|
||||
// Contact list
|
||||
HideOffline = _ReadBool(flatData);
|
||||
|
||||
// Usage example for strings :
|
||||
// const char* str = _ReadString(flatData);
|
||||
|
@ -195,9 +206,8 @@ const char*
|
|||
CayaPreferencesData::_ReadString(BPositionIO* data)
|
||||
{
|
||||
size_t len;
|
||||
char* ret;
|
||||
data->Read(&len, sizeof(size_t));
|
||||
ret = new char[len];
|
||||
char* ret = new char[len];
|
||||
data->Read(ret, len);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -28,13 +28,17 @@ public:
|
|||
bool MoveToCurrentWorkspace;
|
||||
bool RaiseOnMessageReceived;
|
||||
bool RaiseUserIsTyping;
|
||||
bool MarkUnreadWindow;
|
||||
bool NotifyProtocolStatus;
|
||||
bool NotifyContactStatus;
|
||||
bool NotifyNewMessage;
|
||||
|
||||
bool HideCayaDeskbar;
|
||||
bool DisableReplicant;
|
||||
|
||||
bool IgnoreEmoticons;
|
||||
|
||||
bool HideOffline;
|
||||
private:
|
||||
void _AddBool(BPositionIO* data, bool value) const;
|
||||
void _AddString(BPositionIO* data,
|
||||
|
|
|
@ -28,6 +28,9 @@ const uint32 kRaiseOnMessageReceived = 'FCmr';
|
|||
const uint32 kRaiseUserIsTyping = 'FCit';
|
||||
const uint32 kNotifyProtocolsLogin = 'NTpl';
|
||||
const uint32 kNotifyContactStatus = 'NTcl';
|
||||
const uint32 kNotifyNewMessage = 'NTms';
|
||||
const uint32 kMarkUnreadWindow = 'MKuw';
|
||||
const uint32 kHideOffline = 'HiOf';
|
||||
|
||||
|
||||
PreferencesBehavior::PreferencesBehavior()
|
||||
|
@ -37,6 +40,10 @@ PreferencesBehavior::PreferencesBehavior()
|
|||
fOnIncoming = new BStringView("onIncoming", "On incoming message...");
|
||||
fOnIncoming->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
||||
fOnIncoming->SetFont(be_bold_font);
|
||||
|
||||
fHideOffline = new BCheckBox("HideOfflineContacts",
|
||||
"Hide offline contacts",
|
||||
new BMessage(kHideOffline));
|
||||
|
||||
fToCurrentWorkspace = new BCheckBox("ToCurrentWorkspace",
|
||||
"Move window to current workspace",
|
||||
|
@ -55,8 +62,8 @@ PreferencesBehavior::PreferencesBehavior()
|
|||
fPlaySoundOnMessageReceived->SetEnabled(false); // not implemented
|
||||
|
||||
fMarkUnreadWindow = new BCheckBox("MarkUnreadWindow",
|
||||
"Mark unread window chat", NULL);
|
||||
fMarkUnreadWindow->SetEnabled(false);
|
||||
"Mark unread window chat", new BMessage(kMarkUnreadWindow));
|
||||
/*fMarkUnreadWindow->SetEnabled(false); implementing it right now*/
|
||||
|
||||
fMarkUnreadReplicant = new BCheckBox("MarkUnreadReplicant",
|
||||
"Mark unread the Deskbar Replicant", NULL);
|
||||
|
@ -74,6 +81,9 @@ PreferencesBehavior::PreferencesBehavior()
|
|||
|
||||
fNotifyContactStatus = new BCheckBox("EnableContactNotify",
|
||||
"Enable contact status notifications",new BMessage(kNotifyContactStatus));
|
||||
|
||||
fNotifyNewMessage = new BCheckBox("EnableMessageNotify",
|
||||
"Enable message notifications", new BMessage(kNotifyNewMessage));
|
||||
|
||||
const float spacing = be_control_look->DefaultItemSpacing();
|
||||
|
||||
|
@ -81,6 +91,7 @@ PreferencesBehavior::PreferencesBehavior()
|
|||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
||||
.Add(fOnIncoming)
|
||||
.AddGroup(B_VERTICAL, spacing)
|
||||
.Add(fHideOffline)
|
||||
.Add(fToCurrentWorkspace)
|
||||
.Add(fRaiseOnMessageReceived)
|
||||
.Add(fRaiseUserIsTyping)
|
||||
|
@ -93,6 +104,7 @@ PreferencesBehavior::PreferencesBehavior()
|
|||
.AddGroup(B_VERTICAL, spacing)
|
||||
.Add(fNotifyProtocols)
|
||||
.Add(fNotifyContactStatus)
|
||||
.Add(fNotifyNewMessage)
|
||||
. SetInsets(spacing * 2, spacing, spacing, spacing)
|
||||
.End()
|
||||
.AddGlue()
|
||||
|
@ -105,22 +117,30 @@ PreferencesBehavior::PreferencesBehavior()
|
|||
void
|
||||
PreferencesBehavior::AttachedToWindow()
|
||||
{
|
||||
fHideOffline->SetTarget(this);
|
||||
fToCurrentWorkspace->SetTarget(this);
|
||||
fRaiseUserIsTyping->SetTarget(this);
|
||||
fRaiseOnMessageReceived->SetTarget(this);
|
||||
fNotifyProtocols->SetTarget(this);
|
||||
fNotifyContactStatus->SetTarget(this);
|
||||
|
||||
fNotifyNewMessage->SetTarget(this);
|
||||
|
||||
fHideOffline->SetValue(
|
||||
CayaPreferences::Item()->HideOffline);
|
||||
fToCurrentWorkspace->SetValue(
|
||||
CayaPreferences::Item()->MoveToCurrentWorkspace);
|
||||
fRaiseUserIsTyping->SetValue(
|
||||
CayaPreferences::Item()->RaiseUserIsTyping);
|
||||
fRaiseOnMessageReceived->SetValue(
|
||||
CayaPreferences::Item()->RaiseOnMessageReceived);
|
||||
fMarkUnreadWindow->SetValue(
|
||||
CayaPreferences::Item()->MarkUnreadWindow);
|
||||
fNotifyProtocols->SetValue(
|
||||
CayaPreferences::Item()->NotifyProtocolStatus);
|
||||
fNotifyContactStatus->SetValue(
|
||||
CayaPreferences::Item()->NotifyContactStatus);
|
||||
fNotifyNewMessage->SetValue(
|
||||
CayaPreferences::Item()->NotifyNewMessage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,6 +148,10 @@ void
|
|||
PreferencesBehavior::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kHideOffline:
|
||||
CayaPreferences::Item()->HideOffline
|
||||
= fHideOffline->Value();
|
||||
break;
|
||||
case kToCurrentWorkspace:
|
||||
CayaPreferences::Item()->MoveToCurrentWorkspace
|
||||
= fToCurrentWorkspace->Value();
|
||||
|
@ -148,6 +172,14 @@ PreferencesBehavior::MessageReceived(BMessage* message)
|
|||
CayaPreferences::Item()->NotifyContactStatus
|
||||
= fNotifyContactStatus->Value();
|
||||
break;
|
||||
case kNotifyNewMessage:
|
||||
CayaPreferences::Item()->NotifyNewMessage
|
||||
= fNotifyNewMessage->Value();
|
||||
break;
|
||||
case kMarkUnreadWindow:
|
||||
CayaPreferences::Item()->MarkUnreadWindow
|
||||
= fMarkUnreadWindow->Value();
|
||||
break;
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
private:
|
||||
|
||||
BStringView* fOnIncoming;
|
||||
BCheckBox* fHideOffline;
|
||||
BCheckBox* fToCurrentWorkspace;
|
||||
BCheckBox* fRaiseOnMessageReceived;
|
||||
BCheckBox* fRaiseUserIsTyping;
|
||||
|
@ -31,6 +32,7 @@ private:
|
|||
BStringView* fNotifications;
|
||||
BCheckBox* fNotifyProtocols;
|
||||
BCheckBox* fNotifyContactStatus;
|
||||
BCheckBox* fNotifyNewMessage;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ const uint32 kApply = 'SAVE';
|
|||
|
||||
|
||||
PreferencesDialog::PreferencesDialog()
|
||||
: BWindow(BRect(0, 0, 500, 500), "Preferences", B_TITLED_WINDOW,
|
||||
: BWindow(BRect(0, 0, 500, 550), "Preferences", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE)
|
||||
{
|
||||
BTabView* tabView = new BTabView("tabView", B_WIDTH_AS_USUAL);
|
||||
|
|
Ŝarĝante…
Reference in New Issue