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 "TheApp.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static AccountManager* fInstance = NULL;
|
||||
|
||||
|
||||
AccountManager::AccountManager()
|
||||
:
|
||||
fStatus(CAYA_OFFLINE)
|
||||
fStatus(CAYA_OFFLINE),
|
||||
fReplicantMessenger(NULL)
|
||||
{
|
||||
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
|
||||
RegisterObserver(theApp->GetMainWindow());
|
||||
|
@ -29,6 +32,7 @@ AccountManager::~AccountManager()
|
|||
{
|
||||
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
|
||||
UnregisterObserver(theApp->GetMainWindow());
|
||||
delete fReplicantMessenger;
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,6 +60,13 @@ AccountManager::SetNickname(BString nick)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
AccountManager::SetReplicantMessenger(BMessenger* messenger)
|
||||
{
|
||||
fReplicantMessenger = messenger;
|
||||
}
|
||||
|
||||
|
||||
CayaStatus
|
||||
AccountManager::Status() const
|
||||
{
|
||||
|
@ -82,5 +93,18 @@ AccountManager::SetStatus(CayaStatus status, const char* str)
|
|||
// Notify status change
|
||||
fStatus = status;
|
||||
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
|
||||
#define _ACCOUNT_MANAGER_H
|
||||
|
||||
#include <Messenger.h>
|
||||
|
||||
#include "CayaConstants.h"
|
||||
#include "Notifier.h"
|
||||
|
||||
|
||||
class AccountManager : public Notifier {
|
||||
public:
|
||||
static AccountManager* Get();
|
||||
|
@ -18,11 +21,16 @@ public:
|
|||
void SetStatus(CayaStatus status,
|
||||
const char* str = NULL);
|
||||
|
||||
void SetReplicantMessenger(BMessenger* messenger);
|
||||
private:
|
||||
AccountManager();
|
||||
~AccountManager();
|
||||
|
||||
void _ReplicantStatusNotify(CayaStatus status);
|
||||
|
||||
CayaStatus fStatus;
|
||||
BMessenger* fReplicantMessenger;
|
||||
|
||||
};
|
||||
|
||||
#endif // _ACCOUNT_MANAGER_H
|
||||
|
|
|
@ -92,10 +92,10 @@ MainWindow::MainWindow()
|
|||
|
||||
SetLayout(new BGridLayout(5, 5));
|
||||
AddChild(BGridLayoutBuilder(5, 5)
|
||||
.Add(fStatusView, 0, 0)
|
||||
.Add(searchBox, 0, 0)
|
||||
.Add(wrench, 1, 0)
|
||||
.Add(searchBox, 0, 1)
|
||||
.Add(scrollView, 0, 2, 2)
|
||||
.Add(scrollView, 0, 1, 2)
|
||||
.Add(fStatusView, 0, 2, 2)
|
||||
.SetInsets(5, 5, 5, 10)
|
||||
);
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
|
||||
Server::Server()
|
||||
:
|
||||
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
||||
fReplicantMessenger(NULL)
|
||||
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -42,8 +41,6 @@ Server::Server()
|
|||
void
|
||||
Server::Quit()
|
||||
{
|
||||
delete fReplicantMessenger;
|
||||
|
||||
ContactLinker* linker = NULL;
|
||||
|
||||
while ((linker = fRosterMap.ValueAt(0))) {
|
||||
|
@ -157,15 +154,18 @@ Server::Filter(BMessage* message, BHandler **target)
|
|||
|
||||
case CAYA_REPLICANT_MESSENGER:
|
||||
{
|
||||
fReplicantMessenger = new BMessenger();
|
||||
BMessenger* messenger = new BMessenger();
|
||||
|
||||
status_t ret = message->FindMessenger(
|
||||
"messenger", fReplicantMessenger);
|
||||
"messenger", messenger);
|
||||
|
||||
if (ret != B_OK || !fReplicantMessenger->IsValid()) {
|
||||
if (ret != B_OK || !messenger->IsValid()) {
|
||||
message->PrintToStream();
|
||||
printf("err %s\n", strerror(ret));
|
||||
break;
|
||||
}
|
||||
AccountManager* accountManager = AccountManager::Get();
|
||||
accountManager->SetReplicantMessenger(messenger);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,6 @@ Server::ImMessage(BMessage* msg)
|
|||
AccountManager* accountManager = AccountManager::Get();
|
||||
accountManager->SetStatus((CayaStatus)status);
|
||||
|
||||
_ReplicantStatusNotify((CayaStatus)status);
|
||||
break;
|
||||
}
|
||||
case IM_STATUS_SET:
|
||||
|
@ -242,8 +241,6 @@ Server::ImMessage(BMessage* msg)
|
|||
if (msg->FindInt32("status", &status) != B_OK)
|
||||
return B_SKIP_MESSAGE;
|
||||
|
||||
_ReplicantStatusNotify((CayaStatus)status);
|
||||
|
||||
ContactLinker* linker = _EnsureContactLinker(msg);
|
||||
if (!linker)
|
||||
break;
|
||||
|
@ -438,14 +435,3 @@ Server::_EnsureContactLinker(BMessage* message)
|
|||
|
||||
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;
|
||||
ProtocolLoopers fLoopers;
|
||||
ContactLinker* fMySelf;
|
||||
BMessenger* fReplicantMessenger;
|
||||
};
|
||||
|
||||
#endif // _SERVER_H
|
||||
|
|
Ŝarĝante…
Reference in New Issue