Fixed replicant issue, it's working as well, but only under a gcc4 Haiku atm. Modified disposition of the main gui widgets, now they are placed better.
This commit is contained in:
parent
9c43174dce
commit
f51f924b89
|
@ -13,12 +13,15 @@
|
||||||
#include "Server.h"
|
#include "Server.h"
|
||||||
#include "TheApp.h"
|
#include "TheApp.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
static AccountManager* fInstance = NULL;
|
static AccountManager* fInstance = NULL;
|
||||||
|
|
||||||
|
|
||||||
AccountManager::AccountManager()
|
AccountManager::AccountManager()
|
||||||
:
|
:
|
||||||
fStatus(CAYA_OFFLINE)
|
fStatus(CAYA_OFFLINE),
|
||||||
|
fReplicantMessenger(NULL)
|
||||||
{
|
{
|
||||||
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
|
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
|
||||||
RegisterObserver(theApp->GetMainWindow());
|
RegisterObserver(theApp->GetMainWindow());
|
||||||
|
@ -29,6 +32,7 @@ AccountManager::~AccountManager()
|
||||||
{
|
{
|
||||||
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
|
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
|
||||||
UnregisterObserver(theApp->GetMainWindow());
|
UnregisterObserver(theApp->GetMainWindow());
|
||||||
|
delete fReplicantMessenger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,6 +60,13 @@ AccountManager::SetNickname(BString nick)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::SetReplicantMessenger(BMessenger* messenger)
|
||||||
|
{
|
||||||
|
fReplicantMessenger = messenger;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CayaStatus
|
CayaStatus
|
||||||
AccountManager::Status() const
|
AccountManager::Status() const
|
||||||
{
|
{
|
||||||
|
@ -82,5 +93,18 @@ AccountManager::SetStatus(CayaStatus status, const char* str)
|
||||||
// Notify status change
|
// Notify status change
|
||||||
fStatus = status;
|
fStatus = status;
|
||||||
NotifyInteger(INT_ACCOUNT_STATUS, (int32)fStatus);
|
NotifyInteger(INT_ACCOUNT_STATUS, (int32)fStatus);
|
||||||
|
_ReplicantStatusNotify((CayaStatus)status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AccountManager::_ReplicantStatusNotify(CayaStatus status)
|
||||||
|
{
|
||||||
|
if(fReplicantMessenger != NULL && fReplicantMessenger->IsValid()) {
|
||||||
|
printf("notification sent\n");
|
||||||
|
BMessage mess(IM_OWN_STATUS_SET);
|
||||||
|
mess.AddInt32("status", status);
|
||||||
|
fReplicantMessenger->SendMessage(&mess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
#ifndef _ACCOUNT_MANAGER_H
|
#ifndef _ACCOUNT_MANAGER_H
|
||||||
#define _ACCOUNT_MANAGER_H
|
#define _ACCOUNT_MANAGER_H
|
||||||
|
|
||||||
|
#include <Messenger.h>
|
||||||
|
|
||||||
#include "CayaConstants.h"
|
#include "CayaConstants.h"
|
||||||
#include "Notifier.h"
|
#include "Notifier.h"
|
||||||
|
|
||||||
|
|
||||||
class AccountManager : public Notifier {
|
class AccountManager : public Notifier {
|
||||||
public:
|
public:
|
||||||
static AccountManager* Get();
|
static AccountManager* Get();
|
||||||
|
@ -18,11 +21,16 @@ public:
|
||||||
void SetStatus(CayaStatus status,
|
void SetStatus(CayaStatus status,
|
||||||
const char* str = NULL);
|
const char* str = NULL);
|
||||||
|
|
||||||
|
void SetReplicantMessenger(BMessenger* messenger);
|
||||||
private:
|
private:
|
||||||
AccountManager();
|
AccountManager();
|
||||||
~AccountManager();
|
~AccountManager();
|
||||||
|
|
||||||
|
void _ReplicantStatusNotify(CayaStatus status);
|
||||||
|
|
||||||
CayaStatus fStatus;
|
CayaStatus fStatus;
|
||||||
|
BMessenger* fReplicantMessenger;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _ACCOUNT_MANAGER_H
|
#endif // _ACCOUNT_MANAGER_H
|
||||||
|
|
|
@ -92,10 +92,10 @@ MainWindow::MainWindow()
|
||||||
|
|
||||||
SetLayout(new BGridLayout(5, 5));
|
SetLayout(new BGridLayout(5, 5));
|
||||||
AddChild(BGridLayoutBuilder(5, 5)
|
AddChild(BGridLayoutBuilder(5, 5)
|
||||||
.Add(fStatusView, 0, 0)
|
.Add(searchBox, 0, 0)
|
||||||
.Add(wrench, 1, 0)
|
.Add(wrench, 1, 0)
|
||||||
.Add(searchBox, 0, 1)
|
.Add(scrollView, 0, 1, 2)
|
||||||
.Add(scrollView, 0, 2, 2)
|
.Add(fStatusView, 0, 2, 2)
|
||||||
.SetInsets(5, 5, 5, 10)
|
.SetInsets(5, 5, 5, 10)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,7 @@
|
||||||
|
|
||||||
Server::Server()
|
Server::Server()
|
||||||
:
|
:
|
||||||
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE)
|
||||||
fReplicantMessenger(NULL)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +41,6 @@ Server::Server()
|
||||||
void
|
void
|
||||||
Server::Quit()
|
Server::Quit()
|
||||||
{
|
{
|
||||||
delete fReplicantMessenger;
|
|
||||||
|
|
||||||
ContactLinker* linker = NULL;
|
ContactLinker* linker = NULL;
|
||||||
|
|
||||||
while ((linker = fRosterMap.ValueAt(0))) {
|
while ((linker = fRosterMap.ValueAt(0))) {
|
||||||
|
@ -157,15 +154,18 @@ Server::Filter(BMessage* message, BHandler **target)
|
||||||
|
|
||||||
case CAYA_REPLICANT_MESSENGER:
|
case CAYA_REPLICANT_MESSENGER:
|
||||||
{
|
{
|
||||||
fReplicantMessenger = new BMessenger();
|
BMessenger* messenger = new BMessenger();
|
||||||
|
|
||||||
status_t ret = message->FindMessenger(
|
status_t ret = message->FindMessenger(
|
||||||
"messenger", fReplicantMessenger);
|
"messenger", messenger);
|
||||||
|
|
||||||
if (ret != B_OK || !fReplicantMessenger->IsValid()) {
|
if (ret != B_OK || !messenger->IsValid()) {
|
||||||
message->PrintToStream();
|
message->PrintToStream();
|
||||||
printf("err %s\n", strerror(ret));
|
printf("err %s\n", strerror(ret));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
AccountManager* accountManager = AccountManager::Get();
|
||||||
|
accountManager->SetReplicantMessenger(messenger);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,6 @@ Server::ImMessage(BMessage* msg)
|
||||||
AccountManager* accountManager = AccountManager::Get();
|
AccountManager* accountManager = AccountManager::Get();
|
||||||
accountManager->SetStatus((CayaStatus)status);
|
accountManager->SetStatus((CayaStatus)status);
|
||||||
|
|
||||||
_ReplicantStatusNotify((CayaStatus)status);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IM_STATUS_SET:
|
case IM_STATUS_SET:
|
||||||
|
@ -242,8 +241,6 @@ Server::ImMessage(BMessage* msg)
|
||||||
if (msg->FindInt32("status", &status) != B_OK)
|
if (msg->FindInt32("status", &status) != B_OK)
|
||||||
return B_SKIP_MESSAGE;
|
return B_SKIP_MESSAGE;
|
||||||
|
|
||||||
_ReplicantStatusNotify((CayaStatus)status);
|
|
||||||
|
|
||||||
ContactLinker* linker = _EnsureContactLinker(msg);
|
ContactLinker* linker = _EnsureContactLinker(msg);
|
||||||
if (!linker)
|
if (!linker)
|
||||||
break;
|
break;
|
||||||
|
@ -438,14 +435,3 @@ Server::_EnsureContactLinker(BMessage* message)
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
Server::_ReplicantStatusNotify(CayaStatus status)
|
|
||||||
{
|
|
||||||
if(fReplicantMessenger != NULL && fReplicantMessenger->IsValid()) {
|
|
||||||
BMessage mess(IM_OWN_STATUS_SET);
|
|
||||||
mess.AddInt32("status", status);
|
|
||||||
//mess.PrintToStream();
|
|
||||||
fReplicantMessenger->SendMessage(&mess);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ private:
|
||||||
RosterMap fRosterMap;
|
RosterMap fRosterMap;
|
||||||
ProtocolLoopers fLoopers;
|
ProtocolLoopers fLoopers;
|
||||||
ContactLinker* fMySelf;
|
ContactLinker* fMySelf;
|
||||||
BMessenger* fReplicantMessenger;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SERVER_H
|
#endif // _SERVER_H
|
||||||
|
|
Ŝarĝante…
Reference in New Issue