75de08a18b
Protocol messages was added to the API to allow joining abstract rooms by their chat_id― IM_JOIN_ROOM and IM_ROOM_JOINED. To make room in anticipation of future room-related calls, some messages' values have been shifted. A JoinWindow was created (found through [Chat→Join Room] or [Alt-J] in the main window), to allow joining a room with this protocol message. The user can select which account the room should be joined from through a drop-down menu in the lower left-hand corner― a design I think could be replicated in other parts of Caya well. Path() and SetPath() in CayaProtocol were renamed to AddOnPath() and SetAddOnPath() respectively. GetName() and SetName() were also added, where "name" is the account name (aka the leaf of the protocols settings path). To Server, a new KeyMap was added for convenience (AccountInstances), to associate these account names with their instance IDs.
75 lines
1.3 KiB
C++
75 lines
1.3 KiB
C++
/*
|
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
|
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Authors:
|
|
* Andrea Anzani, andrea.anzani@gmail.com
|
|
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <File.h>
|
|
#include <Message.h>
|
|
#include <Path.h>
|
|
|
|
#include "Account.h"
|
|
#include "CayaUtils.h"
|
|
|
|
|
|
Account::Account(bigtime_t instanceId, CayaProtocol* cayap,
|
|
const char* name, const char* addOnSignature, BHandler* target)
|
|
:
|
|
fIdentifier(instanceId),
|
|
fName(name),
|
|
fProtocol(cayap),
|
|
fMessenger(target),
|
|
fSettings(new BMessage())
|
|
{
|
|
fProtocol->Init(this);
|
|
|
|
// Find user's settings path
|
|
BPath path(CayaAccountPath(addOnSignature, fProtocol->Signature()));
|
|
if (path.InitCheck() == B_OK) {
|
|
path.Append(name);
|
|
|
|
fProtocol->SetName(name);
|
|
|
|
// Load settings file
|
|
BFile file(path.Path(), B_READ_ONLY);
|
|
if (fSettings->Unflatten(&file) == B_OK)
|
|
fProtocol->UpdateSettings(fSettings);
|
|
}
|
|
}
|
|
|
|
|
|
Account::~Account()
|
|
{
|
|
delete fSettings;
|
|
}
|
|
|
|
|
|
bigtime_t
|
|
Account::Identifier() const
|
|
{
|
|
return fIdentifier;
|
|
}
|
|
|
|
|
|
const char*
|
|
Account::Name() const
|
|
{
|
|
return fName.String();
|
|
}
|
|
|
|
|
|
status_t
|
|
Account::SendMessage(BMessage* message)
|
|
{
|
|
message->AddInt64("instance", fIdentifier);
|
|
return fMessenger.SendMessage(message);
|
|
}
|
|
|
|
|