* Some style violation fixes.
* Code aligned to recent multiprotocol branch changes. * Fixed crash when Server filters IM_STATUS_SET messages and ContactLinker is NULL.
This commit is contained in:
parent
533117dc61
commit
2ee14f4c14
|
@ -8,13 +8,12 @@
|
|||
* Ryan Leavengood, leavengood@gmail.com
|
||||
*/
|
||||
|
||||
#include <AboutWindow.h>
|
||||
#include <Alert.h>
|
||||
#include <Font.h>
|
||||
#include <String.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include "AboutWindow.h"
|
||||
|
||||
|
||||
AboutWindow::AboutWindow(const char* appName, const char** holders,
|
||||
const char** authors, const char* extraInfo)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
#include "AccountManager.h"
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "MainWindow.h"
|
||||
#include "NotifyMessage.h"
|
||||
#include "Server.h"
|
||||
|
@ -44,7 +45,7 @@ AccountManager::SetNickname(BString nick)
|
|||
{
|
||||
// Create message
|
||||
BMessage* msg = new BMessage(IM_MESSAGE);
|
||||
msg->AddInt32("im_what", IM_SET_NICKNAME);
|
||||
msg->AddInt32("im_what", IM_SET_OWN_NICKNAME);
|
||||
msg->AddString("nick", nick);
|
||||
|
||||
// Send message
|
||||
|
@ -67,7 +68,7 @@ AccountManager::SetStatus(CayaStatus status, const char* str)
|
|||
if (fStatus != status) {
|
||||
// Create status change message
|
||||
BMessage* msg = new BMessage(IM_MESSAGE);
|
||||
msg->AddInt32("im_what", IM_SET_STATUS);
|
||||
msg->AddInt32("im_what", IM_SET_OWN_STATUS);
|
||||
msg->AddInt32("status", (int32)status);
|
||||
if (str != NULL)
|
||||
msg->AddString("message", str);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright 2009, Andrea Anzani. All rights reserved.
|
||||
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
|
||||
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _CAYA_CONSTANTS_H
|
||||
|
@ -7,7 +8,7 @@
|
|||
|
||||
#include <GraphicsDefs.h>
|
||||
|
||||
/*
|
||||
/**
|
||||
* Color constants.
|
||||
*/
|
||||
const rgb_color CAYA_ORANGE_COLOR = {255, 186, 0, 255};
|
||||
|
@ -19,116 +20,13 @@ const rgb_color CAYA_SELSTART_COLOR = {254, 150, 57};
|
|||
const rgb_color CAYA_SELEND_COLOR = {230, 113, 9};
|
||||
|
||||
/**
|
||||
* What-codes for messages.
|
||||
* Miscellaneous.
|
||||
*/
|
||||
enum message_what_codes {
|
||||
// Used for all error messages
|
||||
IM_ERROR = 'IMer',
|
||||
|
||||
// Returned after a request has succeded
|
||||
IM_ACTION_PERFORMED = 'IMok',
|
||||
|
||||
// All client <> protocol communication uses the MESSAGE what-code.
|
||||
IM_MESSAGE = 'IMme',
|
||||
|
||||
IM_SERVER_BASED_CONTACT_LIST = 'IMsl'
|
||||
};
|
||||
#define CAYA_UTF8_MUSICAL_NOTES "\xE2\x99\xAB"
|
||||
|
||||
/**
|
||||
* Valid codes for im_what field.
|
||||
* Status codes.
|
||||
*/
|
||||
enum im_what_code {
|
||||
// Request a server-side contact list from protocol
|
||||
IM_GET_CONTACT_LIST = 1,
|
||||
|
||||
// Send a message to a contact
|
||||
IM_SEND_MESSAGE = 2,
|
||||
|
||||
// Message has been sent to contact
|
||||
IM_MESSAGE_SENT = 3,
|
||||
|
||||
// Message received from contact
|
||||
IM_MESSAGE_RECEIVED = 4,
|
||||
|
||||
// Contact's status has changes
|
||||
IM_STATUS_CHANGED = 5,
|
||||
|
||||
// Server-side contact list received
|
||||
IM_CONTACT_LIST = 6,
|
||||
|
||||
// Change own nickname
|
||||
IM_SET_NICKNAME = 7,
|
||||
|
||||
// Change own status
|
||||
IM_SET_STATUS = 8,
|
||||
|
||||
// Retreive information on contact
|
||||
IM_GET_CONTACT_INFO = 9,
|
||||
|
||||
// Received information on contact
|
||||
IM_CONTACT_INFO = 10,
|
||||
|
||||
// Received extended information on contact
|
||||
IM_EXTENDED_CONTACT_INFO = 30,
|
||||
|
||||
// Start listening to changes in these contact's statuses
|
||||
IM_REGISTER_CONTACTS = 11,
|
||||
|
||||
// Contact started typing
|
||||
IM_CONTACT_STARTED_TYPING = 12,
|
||||
|
||||
// Contact stopped typing
|
||||
IM_CONTACT_STOPPED_TYPING = 13,
|
||||
|
||||
// User started typing
|
||||
IM_USER_STARTED_TYPING = 14,
|
||||
|
||||
// User stopped typing
|
||||
IM_USER_STOPPED_TYPING = 15,
|
||||
|
||||
// Own status was chagned
|
||||
IM_STATUS_SET = 16,
|
||||
|
||||
// Authorization request received
|
||||
IM_AUTH_REQUEST = 17,
|
||||
|
||||
// Send authorization
|
||||
IM_SEND_AUTH_ACK = 18,
|
||||
|
||||
// Contact has been authorized
|
||||
IM_CONTACT_AUTHORIZED = 19,
|
||||
|
||||
// Request authorization from contact
|
||||
IM_REQUEST_AUTH = 20,
|
||||
|
||||
// Stop listening to status changes from these contacts
|
||||
IM_UNREGISTER_CONTACTS = 21,
|
||||
|
||||
// Progress message received, could be login sequence, file transfer etc...
|
||||
IM_PROGRESS = 22,
|
||||
|
||||
// Away message
|
||||
GET_AWAY_MESSAGE = 23,
|
||||
AWAY_MESSAGE = 24,
|
||||
|
||||
// Protocols send this when they get a new avatar icon
|
||||
IM_SET_AVATAR = 25,
|
||||
|
||||
// Client get this when an avatar icon is changed
|
||||
IM_AVATAR_CHANGED = 26,
|
||||
|
||||
// Adding and removing contact from the server side list
|
||||
IM_SERVER_LIST_ADD_CONTACT = 27,
|
||||
IM_SERVER_LIST_REMOVED_CONTACT = 28,
|
||||
|
||||
// Get account contact information
|
||||
IM_OWN_CONTACT_INFO = 29,
|
||||
|
||||
// These are forwarded to or from protocols
|
||||
IM_SPECIAL_TO_PROTOCOL = 1000,
|
||||
IM_SPECIAL_FROM_PROTOCOL = 1001
|
||||
};
|
||||
|
||||
enum CayaStatus {
|
||||
CAYA_ONLINE = 1,
|
||||
CAYA_AWAY = 2,
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
|
||||
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _CAYA_PROTOCOL_MESSAGES_H
|
||||
#define _CAYA_PROTOCOL_MESSAGES_H
|
||||
|
||||
/**
|
||||
* What-codes for messages.
|
||||
*/
|
||||
enum message_what_codes {
|
||||
//! All client <> protocol communication uses this what-code
|
||||
IM_MESSAGE = 'IMme',
|
||||
|
||||
//! Used for all error messages
|
||||
IM_ERROR = 'IMer',
|
||||
|
||||
//! Returned after a request has succeded
|
||||
IM_ACTION_PERFORMED = 'IMok'
|
||||
};
|
||||
|
||||
/**
|
||||
* Valid codes for im_what field.
|
||||
*/
|
||||
enum im_what_code {
|
||||
/*
|
||||
* Messages that involves server-side contact list.
|
||||
*/
|
||||
|
||||
//! Request a server-side contact list from protocol
|
||||
IM_GET_CONTACT_LIST = 1,
|
||||
|
||||
//! Server-side contact list received
|
||||
IM_CONTACT_LIST = 2,
|
||||
|
||||
//! Contact(s) was added to the server-side list
|
||||
IM_CONTACT_LIST_ADD_CONTACT = 3,
|
||||
|
||||
//! Contact(s) removed from the server-side list
|
||||
IM_CONTACT_LIST_REMOVED_CONTACT = 4,
|
||||
|
||||
/*
|
||||
* Messages related to text chat.
|
||||
*/
|
||||
|
||||
//! Send a chat message to a contact
|
||||
IM_SEND_MESSAGE = 20,
|
||||
|
||||
//! Chat message has been sent to contact
|
||||
IM_MESSAGE_SENT = 21,
|
||||
|
||||
//! Chat message received from contact
|
||||
IM_MESSAGE_RECEIVED = 22,
|
||||
|
||||
//! Contact started typing
|
||||
IM_CONTACT_STARTED_TYPING = 23,
|
||||
|
||||
//! Contact stopped typing
|
||||
IM_CONTACT_STOPPED_TYPING = 24,
|
||||
|
||||
//! User started typing
|
||||
IM_USER_STARTED_TYPING = 25,
|
||||
|
||||
//! User stopped typing
|
||||
IM_USER_STOPPED_TYPING = 26,
|
||||
|
||||
/*
|
||||
* Messages related to contact changes.
|
||||
*/
|
||||
|
||||
//! Change contact's status
|
||||
IM_SET_NICKNAME = 40,
|
||||
|
||||
//! Contact's status has changed
|
||||
IM_NICKNAME_SET = 41,
|
||||
|
||||
/*
|
||||
* Messages related to contact's information received from protocols.
|
||||
*/
|
||||
|
||||
//! Received contact new status
|
||||
IM_STATUS_SET = 60,
|
||||
|
||||
//! Contact's avatar icon was changed
|
||||
IM_AVATAR_SET = 61,
|
||||
|
||||
//! Get contact information
|
||||
IM_GET_CONTACT_INFO = 62,
|
||||
|
||||
//! Received contact information
|
||||
IM_CONTACT_INFO = 63,
|
||||
|
||||
//! Get extended contact information
|
||||
IM_GET_EXTENDED_CONTACT_INFO = 64,
|
||||
|
||||
//! Received extended contact information
|
||||
IM_EXTENDED_CONTACT_INFO = 65,
|
||||
|
||||
/*
|
||||
* Messages that involve changing own information.
|
||||
*/
|
||||
|
||||
//! Change own nickname
|
||||
IM_SET_OWN_NICKNAME = 80,
|
||||
|
||||
//! Own nickname was changed
|
||||
IM_OWN_NICKNAME_SET = 81,
|
||||
|
||||
//! Change own status
|
||||
IM_SET_OWN_STATUS = 82,
|
||||
|
||||
// Own status was chagned
|
||||
IM_OWN_STATUS_SET = 83,
|
||||
|
||||
//! Get own contact information
|
||||
IM_OWN_CONTACT_INFO = 84,
|
||||
|
||||
//! Change own avatar icon
|
||||
IM_SET_OWN_AVATAR = 85,
|
||||
|
||||
//! Own avatar icon was changed
|
||||
IM_OWN_AVATAR_SET = 86,
|
||||
|
||||
/*
|
||||
* Contacts registration.
|
||||
*/
|
||||
|
||||
//! Start listening to changes in these contact's statuses
|
||||
IM_REGISTER_CONTACTS = 100,
|
||||
|
||||
//! Stop listening to status changes from these contacts
|
||||
IM_UNREGISTER_CONTACTS = 101,
|
||||
|
||||
/*
|
||||
* Authorization.
|
||||
*/
|
||||
|
||||
//! Ask authorization to contact
|
||||
IM_ASK_AUTHORIZATION = 120,
|
||||
|
||||
//! Authorization response received from contact
|
||||
IM_AUTHORIZATION_RECEIVED = 121,
|
||||
|
||||
//! Authorization request received from contact
|
||||
IM_AUTHORIZATION_REQUEST = 122,
|
||||
|
||||
//! Authorization response given to contact
|
||||
IM_AUTHORIZATION_RESPONSE = 123,
|
||||
|
||||
//! Contact has been authorized
|
||||
IM_CONTACT_AUTHORIZED = 124,
|
||||
|
||||
/*
|
||||
* Miscellaneous.
|
||||
*/
|
||||
|
||||
//! Progress message received, could be login sequence, file transfer etc...
|
||||
IM_PROGRESS = 140,
|
||||
|
||||
/*
|
||||
* Special messages
|
||||
*/
|
||||
|
||||
//! Special message forwarded to protocol
|
||||
IM_SPECIAL_TO_PROTOCOL = 1000,
|
||||
|
||||
//! Special message forwarded from protocol
|
||||
IM_SPECIAL_FROM_PROTOCOL = 1001
|
||||
};
|
||||
|
||||
#endif // _CAYA_PROTOCOL_MESSAGES_H
|
|
@ -23,6 +23,7 @@
|
|||
#include <String.h>
|
||||
|
||||
#include "CayaMessages.h"
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "ChatWindow.h"
|
||||
#include "ContactLinker.h"
|
||||
#include "EditingFilter.h"
|
||||
|
@ -88,7 +89,7 @@ ChatWindow::MessageReceived(BMessage* message)
|
|||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_SEND_MESSAGE);
|
||||
msg.AddString("id", fContactLinker->GetId());
|
||||
msg.AddString("message", message);
|
||||
msg.AddString("body", message);
|
||||
fContactLinker->Messenger().SendMessage(&msg);
|
||||
|
||||
fSendView->SetText("");
|
||||
|
@ -111,66 +112,10 @@ ChatWindow::ImMessage(BMessage* msg)
|
|||
switch (im_what) {
|
||||
case IM_MESSAGE_RECEIVED:
|
||||
{
|
||||
BString message = msg->FindString("message");
|
||||
BString message = msg->FindString("body");
|
||||
fReceiveView->AppendOtherMessage(message.String());
|
||||
break;
|
||||
}
|
||||
case IM_STATUS_CHANGED:
|
||||
{
|
||||
#if 0
|
||||
int32 status;
|
||||
|
||||
if (msg->FindInt32("status", &status) != B_OK)
|
||||
return;
|
||||
|
||||
BString id = msg->FindString("id");
|
||||
|
||||
if (id != "" && status >= CAYA_ONLINE) {
|
||||
bool found = false;
|
||||
BStringItem *item = fRosterMap.ValueFor(id,&found);
|
||||
|
||||
if (!found) {
|
||||
item = new BStringItem(id.String());
|
||||
item->SetHeight(50.0);
|
||||
listView->AddItem(item);
|
||||
fRosterMap.AddItem(id, item);
|
||||
} else {
|
||||
bool itemPresent = listView->HasItem(item);
|
||||
if (status == CAYA_OFFLINE) {
|
||||
//remove from list. (for now)
|
||||
if (itemPresent)
|
||||
listView->RemoveItem(item);
|
||||
} else {
|
||||
if(!itemPresent)
|
||||
listView->AddItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateListItem(item);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case IM_CONTACT_INFO:
|
||||
{
|
||||
#if 0
|
||||
BString id = msg->FindString("id");
|
||||
BString fullName = msg->FindString("nick");
|
||||
if (id != "" && fullName != "") {
|
||||
bool found = false;
|
||||
BStringItem *item = fRosterMap.ValueFor(id,&found);
|
||||
if (!found) {
|
||||
item = new BStringItem(id.String());
|
||||
item->SetHeight(50.0);
|
||||
fRosterMap.AddItem(id, item);
|
||||
}
|
||||
|
||||
item->SetText(fullName);
|
||||
UpdateListItem(item);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -52,16 +52,13 @@ Application Caya :
|
|||
StatusMenuItem.cpp
|
||||
StatusView.cpp
|
||||
CayaRenderView.cpp
|
||||
: be $(TARGET_LIBSTDC++) network translation expat
|
||||
librunview.a libinterface.a libjabber.a
|
||||
ssl crypto
|
||||
: be $(TARGET_LIBSTDC++) translation expat
|
||||
libinterface.a librunview.a libsupport.a
|
||||
: Caya.rdef
|
||||
;
|
||||
|
||||
Depends Caya : libjabber.a ;
|
||||
Depends Caya : librunview.a ;
|
||||
Depends Caya : libinterface.a ;
|
||||
|
||||
LINKFLAGS on Caya += -L$(OPENSSL_LIBRARY_DIR) ;
|
||||
Depends Caya : librunview.a ;
|
||||
Depends Caya : libsupport.a ;
|
||||
|
||||
InstallBin $(CAYA_DIRECTORY) : Caya ;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "CayaConstants.h"
|
||||
#include "CayaMessages.h"
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "CayaResources.h"
|
||||
#include "CayaUtils.h"
|
||||
#include "NotifyMessage.h"
|
||||
|
@ -196,7 +197,7 @@ MainWindow::ImMessage(BMessage* msg)
|
|||
switch (im_what) {
|
||||
case IM_OWN_CONTACT_INFO:
|
||||
{
|
||||
fStatusView->SetName(msg->FindString("nick"));
|
||||
fStatusView->SetName(msg->FindString("name"));
|
||||
|
||||
entry_ref ref;
|
||||
if (msg->FindRef("ref", &ref) == B_OK) {
|
||||
|
@ -205,7 +206,7 @@ MainWindow::ImMessage(BMessage* msg)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case IM_STATUS_CHANGED:
|
||||
case IM_STATUS_SET:
|
||||
{
|
||||
int32 status;
|
||||
|
||||
|
@ -234,10 +235,11 @@ MainWindow::ImMessage(BMessage* msg)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case IM_AVATAR_CHANGED:
|
||||
case IM_AVATAR_SET:
|
||||
case IM_CONTACT_INFO:
|
||||
{
|
||||
RosterItem* rosterItem = fServer->RosterItemForId(msg->FindString("id"));
|
||||
RosterItem* rosterItem
|
||||
= fServer->RosterItemForId(msg->FindString("id"));
|
||||
if (rosterItem)
|
||||
UpdateListItem(rosterItem);
|
||||
break;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "ProtocolLooper.h"
|
||||
#include "CayaMessages.h"
|
||||
#include "CayaProtocol.h"
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "ChatWindow.h"
|
||||
#include "ImageCache.h"
|
||||
#include "ProtocolManager.h"
|
||||
|
@ -66,7 +67,7 @@ Server::LoginAll()
|
|||
ProtocolLooper* looper = fLoopers.ValueAt(i);
|
||||
|
||||
BMessage* msg = new BMessage(IM_MESSAGE);
|
||||
msg->AddInt32("im_what", IM_SET_STATUS);
|
||||
msg->AddInt32("im_what", IM_SET_OWN_STATUS);
|
||||
msg->AddInt32("status", CAYA_ONLINE);
|
||||
looper->PostMessage(msg);
|
||||
}
|
||||
|
@ -123,24 +124,6 @@ Server::Filter(BMessage* message, BHandler **target)
|
|||
filter_result result = B_DISPATCH_MESSAGE;
|
||||
|
||||
switch(message->what) {
|
||||
case IM_SERVER_BASED_CONTACT_LIST:
|
||||
{
|
||||
int i = 0;
|
||||
BString id;
|
||||
while (message->FindString("id", i++, &id) == B_OK) {
|
||||
bool found = false;
|
||||
ContactLinker* item = fRosterMap.ValueFor(id, &found);
|
||||
|
||||
if (found)
|
||||
continue;
|
||||
|
||||
item = new ContactLinker(id.String(), Looper());
|
||||
item->SetProtocolLooper(_LooperFromMessage(message));
|
||||
fRosterMap.AddItem(id, item);
|
||||
}
|
||||
result = B_SKIP_MESSAGE;
|
||||
break;
|
||||
}
|
||||
case IM_MESSAGE_RECEIVED:
|
||||
{
|
||||
BString id = message->FindString("id");
|
||||
|
@ -204,7 +187,25 @@ Server::ImMessage(BMessage* msg)
|
|||
int32 im_what = msg->FindInt32("im_what");
|
||||
|
||||
switch (im_what) {
|
||||
case IM_STATUS_SET:
|
||||
case IM_CONTACT_LIST:
|
||||
{
|
||||
int i = 0;
|
||||
BString id;
|
||||
while (msg->FindString("id", i++, &id) == B_OK) {
|
||||
bool found = false;
|
||||
ContactLinker* item = fRosterMap.ValueFor(id, &found);
|
||||
|
||||
if (found)
|
||||
continue;
|
||||
|
||||
item = new ContactLinker(id.String(), Looper());
|
||||
item->SetProtocolLooper(_LooperFromMessage(msg));
|
||||
fRosterMap.AddItem(id, item);
|
||||
}
|
||||
result = B_SKIP_MESSAGE;
|
||||
break;
|
||||
}
|
||||
case IM_OWN_STATUS_SET:
|
||||
{
|
||||
int32 status;
|
||||
const char* protocol;
|
||||
|
@ -218,7 +219,7 @@ Server::ImMessage(BMessage* msg)
|
|||
accountManager->SetStatus((CayaStatus)status);
|
||||
break;
|
||||
}
|
||||
case IM_STATUS_CHANGED:
|
||||
case IM_STATUS_SET:
|
||||
{
|
||||
int32 status;
|
||||
|
||||
|
@ -226,8 +227,10 @@ Server::ImMessage(BMessage* msg)
|
|||
return B_SKIP_MESSAGE;
|
||||
|
||||
ContactLinker* linker = _EnsureContactLinker(msg);
|
||||
linker->SetNotifyStatus((CayaStatus)status);
|
||||
linker->SetNotifyPersonalStatus(msg->FindString("message"));
|
||||
if (linker) {
|
||||
linker->SetNotifyStatus((CayaStatus)status);
|
||||
linker->SetNotifyPersonalStatus(msg->FindString("message"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IM_CONTACT_INFO:
|
||||
|
@ -240,7 +243,7 @@ Server::ImMessage(BMessage* msg)
|
|||
linker->SetNotifyName(name);
|
||||
break;
|
||||
}
|
||||
case IM_AVATAR_CHANGED:
|
||||
case IM_AVATAR_SET:
|
||||
{
|
||||
ContactLinker* linker = _EnsureContactLinker(msg);
|
||||
entry_ref ref;
|
||||
|
|
|
@ -11,16 +11,12 @@ typedef struct CayaPreferencesData
|
|||
{
|
||||
bool MoveToCurrentWorkspace;
|
||||
bool ActivateWindow;
|
||||
// Add here as much fields as desired
|
||||
|
||||
CayaPreferencesData()
|
||||
:
|
||||
MoveToCurrentWorkspace(true),
|
||||
: MoveToCurrentWorkspace(true),
|
||||
ActivateWindow(true)
|
||||
// Add here its default values
|
||||
{ }
|
||||
|
||||
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
typedef PreferencesContainer<CayaPreferencesData> CayaPreferences;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
const uint32 kToCurrentWorkspace = 'CBcw';
|
||||
const uint32 kActivateChatWindow = 'CBac';
|
||||
|
||||
|
||||
PreferencesBehavior::PreferencesBehavior()
|
||||
: BView("Behavior", B_WILL_DRAW)
|
||||
{
|
||||
|
@ -65,7 +66,6 @@ PreferencesBehavior::PreferencesBehavior()
|
|||
.Add(fHideEmoticons)
|
||||
.SetInsets(spacing, spacing, spacing, spacing)
|
||||
.End()
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,10 @@ PreferencesBehavior::AttachedToWindow()
|
|||
fToCurrentWorkspace->SetTarget(this);
|
||||
fActivateChatWindow->SetTarget(this);
|
||||
|
||||
fToCurrentWorkspace->SetValue(CayaPreferences::Item()->MoveToCurrentWorkspace);
|
||||
fActivateChatWindow->SetValue(CayaPreferences::Item()->ActivateWindow);
|
||||
fToCurrentWorkspace->SetValue(
|
||||
CayaPreferences::Item()->MoveToCurrentWorkspace);
|
||||
fActivateChatWindow->SetValue(
|
||||
CayaPreferences::Item()->ActivateWindow);
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,12 +88,13 @@ PreferencesBehavior::MessageReceived(BMessage* message)
|
|||
{
|
||||
switch (message->what) {
|
||||
case kToCurrentWorkspace:
|
||||
CayaPreferences::Item()->MoveToCurrentWorkspace = fToCurrentWorkspace->Value();
|
||||
CayaPreferences::Item()->MoveToCurrentWorkspace
|
||||
= fToCurrentWorkspace->Value();
|
||||
break;
|
||||
case kActivateChatWindow:
|
||||
CayaPreferences::Item()->ActivateWindow = fActivateChatWindow->Value();
|
||||
CayaPreferences::Item()->ActivateWindow
|
||||
= fActivateChatWindow->Value();
|
||||
break;
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
}
|
||||
|
|
|
@ -10,5 +10,20 @@
|
|||
|
||||
#include "Singleton.h"
|
||||
|
||||
|
||||
template<typename T> T* Singleton<T>::fInstance = 0;
|
||||
|
||||
|
||||
template<typename T>
|
||||
Singleton<T>::Singleton()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T*
|
||||
Singleton<T>::Get()
|
||||
{
|
||||
if (!fInstance)
|
||||
fInstance = new T();
|
||||
return fInstance;
|
||||
}
|
||||
|
|
|
@ -8,17 +8,12 @@
|
|||
template<typename T>
|
||||
class Singleton {
|
||||
public:
|
||||
static T* Get()
|
||||
{
|
||||
if (!fInstance)
|
||||
fInstance = new T();
|
||||
return fInstance;
|
||||
}
|
||||
static T* Get();
|
||||
|
||||
protected:
|
||||
static T* fInstance;
|
||||
static T* fInstance;
|
||||
|
||||
Singleton() {}
|
||||
Singleton();
|
||||
};
|
||||
|
||||
#endif // _SINGLETON_H
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <Entry.h>
|
||||
|
||||
#include "AIM.h"
|
||||
#include "CayaProtocolMessages.h"
|
||||
|
||||
const char* kProtocolSignature = "aim";
|
||||
const char* kProtocolName = "AOL Instant Messenger";
|
||||
|
@ -70,7 +71,7 @@ AIMProtocol::Process(BMessage* msg)
|
|||
msg->FindInt32("im_what", &im_what);
|
||||
|
||||
switch (im_what) {
|
||||
case IM_SET_STATUS: {
|
||||
case IM_OWN_STATUS_SET: {
|
||||
int32 status = msg->FindInt32("status");
|
||||
|
||||
BString status_msg("");
|
||||
|
@ -116,7 +117,7 @@ AIMProtocol::Process(BMessage* msg)
|
|||
break;
|
||||
case IM_SEND_MESSAGE: {
|
||||
const char* buddy = msg->FindString("id");
|
||||
const char* sms = msg->FindString("message");
|
||||
const char* sms = msg->FindString("body");
|
||||
imcomm_im_send_message(fIMCommHandle, buddy, sms, 0);
|
||||
|
||||
// XXX send a message to let caya know we did it
|
||||
|
@ -124,7 +125,7 @@ AIMProtocol::Process(BMessage* msg)
|
|||
msg.AddInt32("im_what", IM_MESSAGE_SENT);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", buddy);
|
||||
msg.AddString("message", sms);
|
||||
msg.AddString("body", sms);
|
||||
|
||||
gServerMsgr->SendMessage(&msg);
|
||||
break;
|
||||
|
@ -156,7 +157,11 @@ AIMProtocol::Process(BMessage* msg)
|
|||
case IM_GET_CONTACT_INFO:
|
||||
UnsupportedOperation();
|
||||
break;
|
||||
case IM_SEND_AUTH_ACK:
|
||||
case IM_ASK_AUTHORIZATION:
|
||||
case IM_AUTHORIZATION_RECEIVED:
|
||||
case IM_AUTHORIZATION_REQUEST:
|
||||
case IM_AUTHORIZATION_RESPONSE:
|
||||
case IM_CONTACT_AUTHORIZED:
|
||||
UnsupportedOperation();
|
||||
break;
|
||||
case IM_SPECIAL_TO_PROTOCOL:
|
||||
|
@ -292,7 +297,7 @@ AIMProtocol::GotMessage(void* imcomm, char* who, int auto, char* recvmsg)
|
|||
msg.AddInt32("im_what", IM_MESSAGE_RECEIVED);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", who);
|
||||
msg.AddString("message", strip_html(recvmsg));
|
||||
msg.AddString("body", strip_html(recvmsg));
|
||||
|
||||
gServerMsgr->SendMessage(&msg);
|
||||
}
|
||||
|
@ -302,7 +307,7 @@ void
|
|||
AIMProtocol::BuddyOnline(void* imcomm, char* who)
|
||||
{
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", who);
|
||||
msg.AddInt32("status", CAYA_ONLINE);
|
||||
|
@ -315,7 +320,7 @@ void
|
|||
AIMProtocol::BuddyOffline(void* imcomm, char* who)
|
||||
{
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", who);
|
||||
msg.AddInt32("status", CAYA_OFFLINE);
|
||||
|
@ -335,7 +340,7 @@ void
|
|||
AIMProtocol::BuddyBack(void* imcomm, char* who)
|
||||
{
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", who);
|
||||
msg.AddInt32("status", CAYA_ONLINE);
|
||||
|
@ -348,7 +353,7 @@ void
|
|||
AIMProtocol::BuddyAwayMsg(void* imcomm, char* who, char* awaymsg)
|
||||
{
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", who);
|
||||
msg.AddInt32("status", CAYA_EXTENDED_AWAY);
|
||||
|
@ -362,7 +367,7 @@ void
|
|||
AIMProtocol::BuddyIdle(void* imcomm, char* who, long idletime)
|
||||
{
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", who);
|
||||
msg.AddInt32("status", CAYA_ONLINE);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <libjabber/JabberSocketPlug.h>
|
||||
#include <libjabber/States.h>
|
||||
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "Facebook.h"
|
||||
|
||||
const char* kProtocolSignature = "facebook";
|
||||
|
@ -81,7 +82,7 @@ Facebook::Process(BMessage* msg)
|
|||
SetOwnNickname(nick);
|
||||
break;
|
||||
}
|
||||
case IM_SET_STATUS:
|
||||
case IM_SET_OWN_STATUS:
|
||||
{
|
||||
int32 status = msg->FindInt32("status");
|
||||
BString status_msg("");
|
||||
|
@ -231,7 +232,7 @@ Facebook::Process(BMessage* msg)
|
|||
case IM_GET_CONTACT_INFO:
|
||||
SendContactInfo(msg->FindString("id"));
|
||||
break;
|
||||
case IM_SEND_AUTH_ACK:
|
||||
case IM_ASK_AUTHORIZATION:
|
||||
{
|
||||
if (!IsAuthorized())
|
||||
return B_ERROR;
|
||||
|
@ -471,7 +472,7 @@ Facebook::BuddyStatusChanged(JabberPresence* jp)
|
|||
return;
|
||||
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", jp->GetJid());
|
||||
msg.AddString("resource", jp->GetResource());
|
||||
|
@ -522,7 +523,7 @@ Facebook::BuddyStatusChanged(const char* who, CayaStatus status)
|
|||
//LOG("Facebook", liDebug, "Facebook::BuddyStatusChanged(%s,%s)",who,status);
|
||||
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", who);
|
||||
msg.AddInt32("status", status);
|
||||
|
@ -620,7 +621,7 @@ Facebook::SendBuddyIcon(const char* id)
|
|||
BString data = vCard->GetPhotoContent();
|
||||
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_SET_AVATAR);
|
||||
msg.AddInt32("im_what", IM_SET_OWN_AVATAR);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", id);
|
||||
msg.AddData("icondata", B_RAW_TYPE, data.String(), data.Length());
|
||||
|
@ -704,7 +705,8 @@ void
|
|||
Facebook::Roster(RosterList* roster)
|
||||
{
|
||||
// Fix me! (Roster message can arrive at different times)
|
||||
BMessage serverBased(IM_SERVER_BASED_CONTACT_LIST);
|
||||
BMessage serverBased(IM_MESSAGE);
|
||||
serverBased.AddInt32("im_what", IM_CONTACT_LIST);
|
||||
serverBased.AddString("protocol", kProtocolSignature);
|
||||
JabberContact* contact;
|
||||
int size = roster->CountItems();
|
||||
|
@ -760,7 +762,7 @@ void
|
|||
Facebook::SubscriptionRequest(JabberPresence* presence)
|
||||
{
|
||||
BMessage im_msg(IM_MESSAGE);
|
||||
im_msg.AddInt32("im_what", IM_AUTH_REQUEST);
|
||||
im_msg.AddInt32("im_what", IM_AUTHORIZATION_REQUEST);
|
||||
im_msg.AddString("protocol", kProtocolSignature);
|
||||
im_msg.AddString("id", presence->GetJid());
|
||||
im_msg.AddString("message", presence->GetStatus());
|
||||
|
@ -777,7 +779,7 @@ Facebook::Unsubscribe(JabberPresence* presence)
|
|||
//LOG("Facebook", liDebug, "Facebook::Unsubscribe()");
|
||||
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", presence->GetJid());
|
||||
msg.AddInt32("status", CAYA_OFFLINE);
|
||||
|
@ -822,7 +824,7 @@ Facebook::GotBuddyPhoto(const BString& jid, const BString& imagePath)
|
|||
{
|
||||
BMessage msg(IM_MESSAGE);
|
||||
|
||||
msg.AddInt32("im_what", IM_AVATAR_CHANGED);
|
||||
msg.AddInt32("im_what", IM_AVATAR_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", jid);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <libjabber/JabberSSLPlug.h>
|
||||
#include <libjabber/States.h>
|
||||
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "GoogleTalk.h"
|
||||
|
||||
const char* kProtocolSignature = "gtalk";
|
||||
|
@ -81,7 +82,7 @@ GoogleTalk::Process(BMessage* msg)
|
|||
SetOwnNickname(nick);
|
||||
break;
|
||||
}
|
||||
case IM_SET_STATUS:
|
||||
case IM_SET_OWN_STATUS:
|
||||
{
|
||||
int32 status = msg->FindInt32("status");
|
||||
BString status_msg("");
|
||||
|
@ -231,7 +232,7 @@ GoogleTalk::Process(BMessage* msg)
|
|||
case IM_GET_CONTACT_INFO:
|
||||
SendContactInfo(msg->FindString("id"));
|
||||
break;
|
||||
case IM_SEND_AUTH_ACK:
|
||||
case IM_ASK_AUTHORIZATION:
|
||||
{
|
||||
if (!IsAuthorized())
|
||||
return B_ERROR;
|
||||
|
@ -471,7 +472,7 @@ GoogleTalk::BuddyStatusChanged(JabberPresence* jp)
|
|||
return;
|
||||
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", jp->GetJid());
|
||||
msg.AddString("resource", jp->GetResource());
|
||||
|
@ -522,7 +523,7 @@ GoogleTalk::BuddyStatusChanged(const char* who, CayaStatus status)
|
|||
//LOG("GoogleTalk", liDebug, "GoogleTalk::BuddyStatusChanged(%s,%s)",who,status);
|
||||
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", who);
|
||||
msg.AddInt32("status", status);
|
||||
|
@ -620,7 +621,7 @@ GoogleTalk::SendBuddyIcon(const char* id)
|
|||
BString data = vCard->GetPhotoContent();
|
||||
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_SET_AVATAR);
|
||||
msg.AddInt32("im_what", IM_SET_OWN_AVATAR);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", id);
|
||||
msg.AddData("icondata", B_RAW_TYPE, data.String(), data.Length());
|
||||
|
@ -704,7 +705,8 @@ void
|
|||
GoogleTalk::Roster(RosterList* roster)
|
||||
{
|
||||
// Fix me! (Roster message can arrive at different times)
|
||||
BMessage serverBased(IM_SERVER_BASED_CONTACT_LIST);
|
||||
BMessage serverBased(IM_MESSAGE);
|
||||
serverBased.AddInt32("im_what", IM_CONTACT_LIST);
|
||||
serverBased.AddString("protocol", kProtocolSignature);
|
||||
JabberContact* contact;
|
||||
int size = roster->CountItems();
|
||||
|
@ -760,7 +762,7 @@ void
|
|||
GoogleTalk::SubscriptionRequest(JabberPresence* presence)
|
||||
{
|
||||
BMessage im_msg(IM_MESSAGE);
|
||||
im_msg.AddInt32("im_what", IM_AUTH_REQUEST);
|
||||
im_msg.AddInt32("im_what", IM_AUTHORIZATION_REQUEST);
|
||||
im_msg.AddString("protocol", kProtocolSignature);
|
||||
im_msg.AddString("id", presence->GetJid());
|
||||
im_msg.AddString("message", presence->GetStatus());
|
||||
|
@ -777,7 +779,7 @@ GoogleTalk::Unsubscribe(JabberPresence* presence)
|
|||
//LOG("GoogleTalk", liDebug, "GoogleTalk::Unsubscribe()");
|
||||
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_STATUS_CHANGED);
|
||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", presence->GetJid());
|
||||
msg.AddInt32("status", CAYA_OFFLINE);
|
||||
|
@ -822,7 +824,7 @@ GoogleTalk::GotBuddyPhoto(const BString& jid, const BString& imagePath)
|
|||
{
|
||||
BMessage msg(IM_MESSAGE);
|
||||
|
||||
msg.AddInt32("im_what", IM_AVATAR_CHANGED);
|
||||
msg.AddInt32("im_what", IM_AVATAR_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", jid);
|
||||
|
||||
|
|
Ŝarĝante…
Reference in New Issue