2010-05-16 16:02:50 -05:00
|
|
|
/*
|
2011-12-03 16:38:03 -06:00
|
|
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
|
|
|
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
|
2021-06-15 00:59:00 -05:00
|
|
|
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
2010-05-16 16:02:50 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Andrea Anzani, andrea.anzani@gmail.com
|
|
|
|
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
2021-06-15 00:59:00 -05:00
|
|
|
* Jaidyn Levesque, jadedctrl@teknik.io
|
2010-05-16 16:02:50 -05:00
|
|
|
*/
|
|
|
|
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
#include "ProtocolLooper.h"
|
|
|
|
|
Redesign add-on disconnection
Currently, add-ons are disconnected when ChatProtocol::Shutdown() is
called, which the add-on can do by itself― but there is no standard way
for add-ons to notify the app about their Shutdown. Because of this,
they tend to not call Shutdown()― instead (as in the case of the Jabber
add-on), they display a BAlert (IM_ERROR) notifying the user of the
connection error, but the account is considered active by Cardie (and
its threads are still existant, including its ProtocolLooper).
Zombies are bad, so this is redesigned somewhat with this commit:
Protocols should no longer call ChatProtocol::Shutdown() themselves,
they must send an IM_MESSAGE of IM_PROTOCOL_DISABLE to the app.
This will delete its ProtocolLooper, which in turn will send a
notification to the user and delete the ChatProtocol, and so
calling ChatProtocol::Shutdown().
In the included protocols, an IM_ERROR is sent right before
IM_PROTOCOL_DISABLE is sent if due to a connection error. This is not
required, but it is courteous to inform your user about the "why." :)
2021-07-18 17:52:36 -05:00
|
|
|
#include <Bitmap.h>
|
2022-02-23 15:42:46 -06:00
|
|
|
#include <Catalog.h>
|
2010-05-16 16:02:50 -05:00
|
|
|
#include <String.h>
|
|
|
|
|
|
|
|
#include "Account.h"
|
Redesign add-on disconnection
Currently, add-ons are disconnected when ChatProtocol::Shutdown() is
called, which the add-on can do by itself― but there is no standard way
for add-ons to notify the app about their Shutdown. Because of this,
they tend to not call Shutdown()― instead (as in the case of the Jabber
add-on), they display a BAlert (IM_ERROR) notifying the user of the
connection error, but the account is considered active by Cardie (and
its threads are still existant, including its ProtocolLooper).
Zombies are bad, so this is redesigned somewhat with this commit:
Protocols should no longer call ChatProtocol::Shutdown() themselves,
they must send an IM_MESSAGE of IM_PROTOCOL_DISABLE to the app.
This will delete its ProtocolLooper, which in turn will send a
notification to the user and delete the ChatProtocol, and so
calling ChatProtocol::Shutdown().
In the included protocols, an IM_ERROR is sent right before
IM_PROTOCOL_DISABLE is sent if due to a connection error. This is not
required, but it is courteous to inform your user about the "why." :)
2021-07-18 17:52:36 -05:00
|
|
|
#include "AppMessages.h"
|
2021-08-12 15:43:52 -05:00
|
|
|
#include "ChatProtocolMessages.h"
|
2022-02-23 15:42:46 -06:00
|
|
|
#include "Contact.h"
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
#include "Conversation.h"
|
2021-06-11 17:24:04 -05:00
|
|
|
#include "ConversationAccountItem.h"
|
2021-08-12 15:43:52 -05:00
|
|
|
#include "ConversationView.h"
|
|
|
|
#include "MainWindow.h"
|
|
|
|
#include "NotifyMessage.h"
|
|
|
|
#include "TheApp.h"
|
2010-05-16 16:02:50 -05:00
|
|
|
|
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
ProtocolLooper::ProtocolLooper(ChatProtocol* protocol, int64 instance)
|
2010-05-19 17:28:26 -05:00
|
|
|
:
|
|
|
|
BLooper(),
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
fProtocol(protocol),
|
2021-06-11 17:24:04 -05:00
|
|
|
fInstance(instance),
|
2021-07-07 10:59:56 -05:00
|
|
|
fListItem(NULL),
|
|
|
|
fMySelf(NULL)
|
2010-05-16 16:02:50 -05:00
|
|
|
{
|
|
|
|
Account* account = reinterpret_cast<Account*>(
|
|
|
|
protocol->MessengerInterface());
|
|
|
|
|
2021-07-05 23:53:46 -05:00
|
|
|
LoadCommands();
|
2021-06-20 01:24:34 -05:00
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
BString name(protocol->FriendlySignature());
|
|
|
|
name << " - " << account->Name();
|
|
|
|
SetName(name.String());
|
2021-08-12 15:43:52 -05:00
|
|
|
|
|
|
|
_InitChatView();
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
Run();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 20:33:28 -05:00
|
|
|
ProtocolLooper::~ProtocolLooper()
|
|
|
|
{
|
Redesign add-on disconnection
Currently, add-ons are disconnected when ChatProtocol::Shutdown() is
called, which the add-on can do by itself― but there is no standard way
for add-ons to notify the app about their Shutdown. Because of this,
they tend to not call Shutdown()― instead (as in the case of the Jabber
add-on), they display a BAlert (IM_ERROR) notifying the user of the
connection error, but the account is considered active by Cardie (and
its threads are still existant, including its ProtocolLooper).
Zombies are bad, so this is redesigned somewhat with this commit:
Protocols should no longer call ChatProtocol::Shutdown() themselves,
they must send an IM_MESSAGE of IM_PROTOCOL_DISABLE to the app.
This will delete its ProtocolLooper, which in turn will send a
notification to the user and delete the ChatProtocol, and so
calling ChatProtocol::Shutdown().
In the included protocols, an IM_ERROR is sent right before
IM_PROTOCOL_DISABLE is sent if due to a connection error. This is not
required, but it is courteous to inform your user about the "why." :)
2021-07-18 17:52:36 -05:00
|
|
|
BMessage* msg = new BMessage(APP_ACCOUNT_DISABLED);
|
|
|
|
BBitmap* icon = fProtocol->Icon();
|
|
|
|
|
2021-08-09 22:10:01 -05:00
|
|
|
if (icon != NULL)
|
|
|
|
icon->Archive(msg);
|
Redesign add-on disconnection
Currently, add-ons are disconnected when ChatProtocol::Shutdown() is
called, which the add-on can do by itself― but there is no standard way
for add-ons to notify the app about their Shutdown. Because of this,
they tend to not call Shutdown()― instead (as in the case of the Jabber
add-on), they display a BAlert (IM_ERROR) notifying the user of the
connection error, but the account is considered active by Cardie (and
its threads are still existant, including its ProtocolLooper).
Zombies are bad, so this is redesigned somewhat with this commit:
Protocols should no longer call ChatProtocol::Shutdown() themselves,
they must send an IM_MESSAGE of IM_PROTOCOL_DISABLE to the app.
This will delete its ProtocolLooper, which in turn will send a
notification to the user and delete the ChatProtocol, and so
calling ChatProtocol::Shutdown().
In the included protocols, an IM_ERROR is sent right before
IM_PROTOCOL_DISABLE is sent if due to a connection error. This is not
required, but it is courteous to inform your user about the "why." :)
2021-07-18 17:52:36 -05:00
|
|
|
msg->AddString("name", fProtocol->GetName());
|
|
|
|
fProtocol->MessengerInterface()->SendMessage(msg);
|
|
|
|
|
2021-06-11 20:33:28 -05:00
|
|
|
fProtocol->Shutdown();
|
|
|
|
delete fProtocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
void
|
|
|
|
ProtocolLooper::MessageReceived(BMessage* msg)
|
|
|
|
{
|
|
|
|
if (Protocol()->Process(msg) != B_OK)
|
|
|
|
BLooper::MessageReceived(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-12 15:43:52 -05:00
|
|
|
ConversationView*
|
|
|
|
ProtocolLooper::GetView()
|
|
|
|
{
|
|
|
|
return fSystemChatView;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ProtocolLooper::ShowView()
|
|
|
|
{
|
|
|
|
MainWindow* win = ((TheApp*)be_app)->GetMainWindow();
|
|
|
|
win->SetConversation(NULL);
|
|
|
|
win->SetConversationView(fSystemChatView);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
ChatProtocol*
|
2010-05-16 16:02:50 -05:00
|
|
|
ProtocolLooper::Protocol()
|
|
|
|
{
|
|
|
|
return fProtocol;
|
|
|
|
}
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
|
|
|
|
|
|
|
|
ChatMap
|
|
|
|
ProtocolLooper::Conversations() const
|
|
|
|
{
|
|
|
|
return fChatMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Conversation*
|
|
|
|
ProtocolLooper::ConversationById(BString id)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
return fChatMap.ValueFor(id, &found);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ProtocolLooper::AddConversation(Conversation* chat)
|
|
|
|
{
|
2021-08-01 06:37:25 -05:00
|
|
|
if (chat != NULL)
|
|
|
|
fChatMap.AddItem(chat->GetId(), chat);
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ProtocolLooper::RemoveConversation(Conversation* chat)
|
|
|
|
{
|
2021-08-01 06:37:25 -05:00
|
|
|
if (chat != NULL)
|
|
|
|
fChatMap.RemoveItemFor(chat->GetId());
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RosterMap
|
|
|
|
ProtocolLooper::Contacts() const
|
|
|
|
{
|
|
|
|
return fRosterMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Contact*
|
|
|
|
ProtocolLooper::ContactById(BString id)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
return fRosterMap.ValueFor(id, &found);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ProtocolLooper::AddContact(Contact* contact)
|
|
|
|
{
|
2021-08-01 06:37:25 -05:00
|
|
|
if (contact != NULL)
|
|
|
|
fRosterMap.AddItem(contact->GetId(), contact);
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 22:37:20 -05:00
|
|
|
void
|
|
|
|
ProtocolLooper::RemoveContact(Contact* contact)
|
|
|
|
{
|
2021-08-01 06:37:25 -05:00
|
|
|
if (contact == NULL)
|
|
|
|
return;
|
2021-06-19 22:37:20 -05:00
|
|
|
fRosterMap.RemoveItemFor(contact->GetId());
|
|
|
|
fUserMap.AddItem(contact->GetId(), (User*)contact);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
UserMap
|
|
|
|
ProtocolLooper::Users() const
|
|
|
|
{
|
|
|
|
UserMap users = fUserMap;
|
|
|
|
|
|
|
|
for (int i = 0; i < fRosterMap.CountItems(); i++) {
|
|
|
|
User* user = (User*)fRosterMap.ValueAt(i);
|
|
|
|
users.AddItem(user->GetId(), user);
|
|
|
|
}
|
|
|
|
|
|
|
|
return users;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
User*
|
|
|
|
ProtocolLooper::UserById(BString id)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
User* user = ContactById(id);
|
|
|
|
if (user == NULL)
|
|
|
|
user = fUserMap.ValueFor(id, &found);
|
|
|
|
|
|
|
|
return user;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ProtocolLooper::AddUser(User* user)
|
|
|
|
{
|
2021-08-01 06:37:25 -05:00
|
|
|
if (user != NULL)
|
|
|
|
fUserMap.AddItem(user->GetId(), user);
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-15 00:59:00 -05:00
|
|
|
CommandMap
|
|
|
|
ProtocolLooper::Commands() const
|
|
|
|
{
|
|
|
|
return fCommands;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ChatCommand*
|
|
|
|
ProtocolLooper::CommandById(BString id)
|
|
|
|
{
|
|
|
|
return fCommands.ValueFor(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-06 14:46:28 -05:00
|
|
|
Contact*
|
|
|
|
ProtocolLooper::GetOwnContact()
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
{
|
|
|
|
return fMySelf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2021-07-06 14:46:28 -05:00
|
|
|
ProtocolLooper::SetOwnContact(Contact* contact)
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
{
|
Support generally setting own nick, own UserItems
Seperate UserItems are now created for each list, too, rather than a
single one being created per-user. This functionally works a lot nicer.
But onto more important things… now setting the user's own nick should
work quite well. Finally. =w=
This has given me a good bit of trouble over the past couple of days―
setting the user's nick *worked*, but it wouldn't propagate to its
corresponding UserItem nor its UserInfoDialog. It would, however, work
with the StatusView.
These are all registered Observers of the User itself, so if one works,
they *all* should, them all being registered to the same User.
Now, if a given User isn't found in the ProtocolLooper's user-list,
the Conversation class will take it upon itself to create a new
one and add it to both of their respective lists.
So the user's own contact would be set in the ProtocolLooper― but it
*wouldn't* be added to the user-list.
Hilarity ensues as two seperate objects for the user's own contact would
be created.
Since the StatusView is registered to the ProtocolLooper's "real" own contact
slot, it would receive all updates… but since Conversations' user-lists and
items would be registered to the Conversation-created "fake" user, they
would be borked.
Simple oversight, but wow it hecked with me. :P
2021-08-05 14:10:21 -05:00
|
|
|
if (contact != NULL) {
|
2021-08-01 06:37:25 -05:00
|
|
|
fMySelf = contact;
|
Support generally setting own nick, own UserItems
Seperate UserItems are now created for each list, too, rather than a
single one being created per-user. This functionally works a lot nicer.
But onto more important things… now setting the user's own nick should
work quite well. Finally. =w=
This has given me a good bit of trouble over the past couple of days―
setting the user's nick *worked*, but it wouldn't propagate to its
corresponding UserItem nor its UserInfoDialog. It would, however, work
with the StatusView.
These are all registered Observers of the User itself, so if one works,
they *all* should, them all being registered to the same User.
Now, if a given User isn't found in the ProtocolLooper's user-list,
the Conversation class will take it upon itself to create a new
one and add it to both of their respective lists.
So the user's own contact would be set in the ProtocolLooper― but it
*wouldn't* be added to the user-list.
Hilarity ensues as two seperate objects for the user's own contact would
be created.
Since the StatusView is registered to the ProtocolLooper's "real" own contact
slot, it would receive all updates… but since Conversations' user-lists and
items would be registered to the Conversation-created "fake" user, they
would be borked.
Simple oversight, but wow it hecked with me. :P
2021-08-05 14:10:21 -05:00
|
|
|
AddUser(contact);
|
|
|
|
}
|
Explicitly tie Conversations, Contacts, and Users to their ProtocolLoopers
Previously, all Conversations/Contacts/Users were stored in the Server,
each in their respective KeyMaps, identified solely by their
identifiers. This leads to the glaring problem of overlap― if the user
has multiple accounts, some users/rooms might be used or present in multiple
accounts at the same time.
Now, each accounts' Contacts, Conversations, and Users are stored in
its ProtocolLooper, making this overlap impossible. An oversight of only
allowing one user identifier to be stored (fMySelf) in Server was also fixed
this way.
This is the bulk of the work required for multi-account support― now,
the user can join the same XMPP room on two seperate accounts, and it
works perfectly.
2021-06-10 15:16:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int64
|
|
|
|
ProtocolLooper::GetInstance()
|
|
|
|
{
|
|
|
|
return fInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 17:24:04 -05:00
|
|
|
ConversationAccountItem*
|
|
|
|
ProtocolLooper::GetListItem()
|
|
|
|
{
|
|
|
|
if (fListItem == NULL)
|
|
|
|
fListItem = new ConversationAccountItem(fProtocol->GetName(),
|
2021-08-12 15:43:52 -05:00
|
|
|
fInstance, this);
|
2021-06-11 17:24:04 -05:00
|
|
|
return fListItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-20 01:24:34 -05:00
|
|
|
void
|
2021-07-05 23:53:46 -05:00
|
|
|
ProtocolLooper::LoadCommands()
|
2021-06-20 01:24:34 -05:00
|
|
|
{
|
2021-07-05 23:53:46 -05:00
|
|
|
fCommands = CommandMap();
|
2021-06-20 01:24:34 -05:00
|
|
|
BObjectList<BMessage> commands = fProtocol->Commands();
|
|
|
|
for (int i = 0; i < commands.CountItems(); i++) {
|
|
|
|
ChatCommand* cmd = new ChatCommand(commands.ItemAt(i));
|
|
|
|
fCommands.AddItem(cmd->GetName(), cmd);
|
|
|
|
}
|
|
|
|
}
|
2021-08-12 15:43:52 -05:00
|
|
|
|
|
|
|
|
2022-02-23 15:42:46 -06:00
|
|
|
#undef B_TRANSLATION_CONTEXT
|
|
|
|
#define B_TRANSLATION_CONTEXT "Protocol system buffer"
|
|
|
|
|
|
|
|
|
2021-08-12 15:43:52 -05:00
|
|
|
void
|
|
|
|
ProtocolLooper::_InitChatView()
|
|
|
|
{
|
|
|
|
fSystemChatView = new ConversationView();
|
|
|
|
|
|
|
|
BMessage clear(kClearText);
|
|
|
|
fSystemChatView->MessageReceived(&clear);
|
|
|
|
|
|
|
|
BMessage init(IM_MESSAGE);
|
|
|
|
init.AddInt32("im_what", IM_MESSAGE_RECEIVED);
|
2021-08-19 02:28:06 -05:00
|
|
|
init.AddString("user_name", APP_NAME);
|
2021-08-12 15:43:52 -05:00
|
|
|
init.AddString("body", B_TRANSLATE("I'm rearing to go!"));
|
|
|
|
fSystemChatView->MessageReceived(&init);
|
|
|
|
|
|
|
|
fSystemChatView->ObserveString(STR_ROOM_NAME, fProtocol->GetName());
|
|
|
|
fSystemChatView->ObserveString(STR_ROOM_SUBJECT, "System buffer");
|
|
|
|
|
|
|
|
BBitmap* icon = fProtocol->Icon();
|
|
|
|
if (icon != NULL)
|
|
|
|
fSystemChatView->ObservePointer(PTR_ROOM_BITMAP, (void*)icon);
|
|
|
|
}
|