Commit Graph

97 Enmetoj

Author SHA1 Message Date
Jaidyn Ann 6e89dbdab1 Better protocol status notifications
Now a notification is sent as soon as a protocol has been readied
(before connection established), and all status notifications use the
same message ID to avoid spamming the poor user.
2021-08-18 17:22:08 -05:00
Jaidyn Ann b2e17f57dc Fix avatar-loading 2021-08-18 17:00:11 -05:00
Jaidyn Ann 5e0782b553 Ensure implicit room-members are real
If a message/event is sent to a room that's tied to a user that hasn't
been formally declared (through IM_ROOM_PARTICIPANTS or
IM_ROOM_PARTICIPANT_JOINED), that user won't be unconditionally kept
anymore.

Now, after adding an implicit user, the participant list will be
requested again― upon receiving the list, all implicitly-defined users
will be removed. If they really existed to begin with, they should be
re-added quickly through this re-sending of IM_ROOM_PARTICIPANTS.

Ghosts should be treated as ghosts, not users.
2021-08-18 14:18:24 -05:00
Jaidyn Ann c492a46a65 Rename AccountManager to StatusManager 2021-08-16 10:40:18 -05:00
Jaidyn Ann b380b6115c Fix chat creation with non-contact users 2021-08-15 20:34:30 -05:00
Jaidyn Ann e6f9c3e085 Notification and buffer message on disconnect/reconnect 2021-08-14 11:57:42 -05:00
Jaidyn Ann 057e7fba9b Add "system buffer" per protocol
Now, per each account, there is a read-only chat view associated with
it, accessible through its item in the conversations list. This can be
used to place system messages, MOTDs, insignificant errors, etc.

Protocols can send text to this buffer by specifying no "chat_id" in
an IM_MESSAGE_RECEIVED message.
2021-08-12 15:43:52 -05:00
Jaidyn Ann 12215266d0 Display message in chat when user changes nick 2021-08-10 18:03:37 -05:00
Jaidyn Ann 373dcb4a58 Protocol message tweaks, bump API version
Some chat protocol messages' names have been changed to more fitting or
consistent names― e.g., "IM_AVATAR_SET" to "IM_USER_AVATAR_SET", or
"IM_CONTACT_LIST_*" to "IM_ROSTER_*" (to agree with Cardie's usage of
the word).

The API version has been bumped― for the forseeable future (at least
several months, I promise!) no compatibility-breaking changes will be
introduced. Until then, any new feautures or message slots will be
additive and optional.
2021-08-08 21:01:42 -05:00
Jaidyn Ann 3861fa718d Remove unused APP_*_CHAT_WINDOW messages 2021-08-05 21:05:59 -05:00
Jaidyn Ann e8e1ce0b05 Error notification if applying protocol settings fails 2021-08-05 20:43:08 -05:00
Jaidyn Ann a49e957b16 Re-enabling of accounts after disable
Accounts can now be toggled on-and-off freely.
Fixes #42
2021-08-05 19:31:26 -05:00
Jaidyn Ann f0ce3e87c6 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:28:56 -05:00
Jaidyn Ann 7c2362a851 Add 'Room info' dialogue
Fixes #55
2021-08-04 12:44:20 -05:00
Jaidyn Ann 984f066070 Multi-account StatusView; set info per-account
Now the StatusView (bottom-left corner, right below the room list) can
be used to set the nickname and status not only for all accounts at
once, but for managing the status/nick of individual accounts.

AccountManager now can set details of a single account, too.

MainWindow is no longer an Observer (as it just passed the information
along to StatusView― now StatusView manages that itself).

NicknameTextControl was removed, not being in use.
2021-08-03 13:24:36 -05:00
Jaidyn Ann 9f05ce1136 Misc. tweaks, no functional change 2021-08-01 06:37:25 -05:00
Jaidyn Ann 82f920798f Auto-completion for commands 2021-07-31 20:18:36 -05:00
Jaidyn Ann 89ff195c8d Set room topic/name through conversation view
If the user has permission to change a room's subject or name, they can
now edit the text views displaying them (toward the top of the window).
When enter is pressed, the changes will be sent to the protocol.

To do this, a BTextView subclass was added to libinterface
(splitting somewhat from SendTextView)― EnterTextView sends a message
containing the text to the given target when the user hits enter sans
modifiers.
2021-07-29 22:00:01 -05:00
Jaidyn Ann f038c492f7 Refactor preference saving/loading 2021-07-28 19:10:09 -05:00
Jaidyn Ann 0ffe3e5ce8 Replace CreateAccountMenu() with dedicated class
CreateAccountMenu() is used to populate a BMenu with items corresponding
to the map of accounts provided to it― but when an account is disabled
or enabled, it can't update automatically.

A dedicated class, fAccountsMenu, now replaces it― it'll automatically
repopulate the list whenever the active accounts update.
2021-07-21 12:14:25 -05:00
Jaidyn Ann 82c06bba25 Localization, init catkeys 2021-07-19 09:54:27 -05:00
Jaidyn Ann 4905dbbe6c 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
Jaidyn Ann 6dcb6f4405 Notify on account disabling, more detailed alerts
Like the notification sent when accounts are ready (IM_PROTOCOL_READY),
one's been added for when accounds have disconnected/are disabled:
IM_PROTOCOL_DISABLED.

Also, error BAlerts (created with IM_ERROR messages) are now more
detailed, showing the associated accounts' name in the header.
2021-07-18 15:39:30 -05:00
Jaidyn Ann 5ec79ebbf5 Fix status view's avatar icon
The StatusView (below the roomlist) now shows a default icon if no
accounts have associated avatars, and will use an account's cached avatar
if available.
2021-07-13 14:43:48 -05:00
Jaidyn Ann 52a580e03d Remove own user from contacts; fix roster bitmaps
It doesn't make sense to lump the user themself with their contacts
list― their Contact object is now stored seperately.

BBitmap loading for RosterItems are fixed, as well.

Fixes #33
2021-07-06 14:46:28 -05:00
Jaidyn Ann d9051766d9 Reloading of protocol's commands on request
Sometimes a protocol's commands are dynamic, or change based on certain
events― and it's necessary in these cases that commands be reloaded.

The IM_PROTOCOL_RELOAD_COMMANDS message is now added to the API, which
will force Cardie to reload commands from the protocol.
2021-07-05 23:53:46 -05:00
Jaidyn Ann fb070e841a Store default commands/menu items in resources 2021-06-30 14:27:58 -05:00
Jaidyn Ann 48db626672 Accept IM_ROOM_PARTICIPANTS without user_names 2021-06-29 15:19:43 -05:00
Jaidyn Ann de09ff9ad6 Rename Caya to Cardie 2021-06-22 01:06:00 -05:00
Jaidyn Ann 4ee453d0d6 Update room subject; accept user_name in OWN_CONTACT_INFO 2021-06-21 02:32:49 -05:00
Jaidyn Ann fbe6e66743 Change class names 2021-06-20 12:44:20 -05:00
Jaidyn Ann b1920dad47 Move command/menu-item registration to call
Registration of custom chat commands and menu-items for protocols was
done by the IM_REGISTER_* messages, and is now done through direct calls
to the CayaProtocol object.

The new model for call/message for protocols is this: Temporary
information (chat messages, roster members, etc.) should be accessed
through messages. Relatively static data (protocol name, commands)
should be accessed through direct calls to the protocol object.
2021-06-20 01:24:34 -05:00
Jaidyn Ann d4f82dccc6 Removal of roster members
Now roster members can be deleted through the RosterEditWindow.

IM_CONTACT_LIST_REMOVED_CONTACT was renamed to
IM_CONTACT_LIST_CONTACT_REMOVED to fit style of other API messages.

Fixes #1.
2021-06-20 01:22:59 -05:00
Jaidyn Ann 077a01e8bf Print room 'join' and 'create' messages 2021-06-18 01:39:34 -05:00
Jaidyn Ann 48f84377fc Room-creation for XMPP 2021-06-18 01:30:59 -05:00
Jaidyn Ann 560be5a810 Base for custom menubar items
Fixes #8
2021-06-16 05:03:30 -05:00
Jaidyn Ann d5aebac5c5 Custom chatlist pop-up items 2021-06-16 04:33:06 -05:00
Jaidyn Ann 8a9cb9effd Register commands & pop-up items through messages
Use IM_MESSAGEs, IM_REGISTER_COMMAND and IM_REGISTER_USER_ITEM, for
registering commands and user-list pop-up items.

The former replaces CayaProtocol::Commands(), which was a real bad idea
in the first place. Just awful. No idea why I did that instead of this,
which is nicer and significantly easier anyway.
2021-06-15 23:29:38 -05:00
Jaidyn Ann 66b8150eeb Basis for custom userlist pop-up menu items 2021-06-15 21:05:21 -05:00
Jaidyn Ann 83e98bd5a8 Remove obselete CayaProtocol::SaveLogs(), add ::Commands()
With the new use of RoomFlags for signifying whether or not a room's
chat should be populated with local logs (ROOM_POPULATE_LOGS),
SaveLogs() is redundant.

A Commands() method was added to the CayaProtocol class returning a
CommandMap, which will be used by Caya when searching for commands.

KeyList::AddList() and List::AddList() were also added to libsupport,
for convenience.
2021-06-15 14:40:28 -05:00
Jaidyn Ann dd77f246f8 Per-protocol commands, precedence over default commands
Fixes #10
2021-06-15 00:59:00 -05:00
Jaidyn Ann 7d72b5152c Add '/help' command 2021-06-15 00:48:00 -05:00
Jaidyn Ann 46d6d0a0b0 Basic command storage and parsing
A new class was added (ChatCommand) to represent commands, which are
all stored in the Server iself.

A command can be assigned any arbitrary BMessage, and can be given
arguments with some semantic meaning (so far just "string" or "room
participant," etc).

"invite" and moderation commands were added (ban/kick/mute etc).
2021-06-15 00:22:35 -05:00
Jaidyn Ann b2489a5551 Cache roomflags, autojoin/autocreate based on them
Fixes #3
2021-06-13 02:35:16 -05:00
Jaidyn Ann 7c9d1d9eaa Rework communication of room metadata, add room flags
In the API, a firm distinction between initially fetching a room's
metadata and receiving further changes has been made:
IM_ROOM_METADATA will be sent to Caya on request (IM_GET_ROOM_METADATA)
with the room's name, subject, etc. The other metadata-related messages
should only be sent to Caya after the room is initialized, not as a
means of initially setting its metadata.

Basic room flags were added, though they aren't yet used― they should
allow the protocol/add-on/user to configure some room features. Logging,
auto-joining, etc.
2021-06-13 01:16:30 -05:00
Jaidyn Ann 07350b3a0a Auto-join cached rooms on log-in
Rooms are now cached in ~/config/settings/Caya/Cache/$account/Rooms/,
with each file representing a seperate room. The filename is used as the
identifier, and these files now also serve as log files. The log
attribute name has also changed from "logs" to "Caya:logs".

When a protocol has succesfuly connected, all cached rooms are
automatically joined.
2021-06-12 21:42:10 -05:00
Jaidyn Ann 9cd4ce18e1 Disable some menu items when no account is active
When no accounts are active, all items in the Menubar->Chat menu are
disabled, and some other menu items related to starting/managing chats
are disabled in other views.

One new message was added to the API― IM_PROTOCOL_READY, which tells
Caya that a given protocol has logged in and is ready to receive
messages (rather than just sending).

This is currently done in XMPP after the roster is loaded, which be a
process that stalls the protocol for a few seconds. IM_PROTOCOL_READY
should only be sent after those initial, potentially time-heavy
operations.
2021-06-12 16:13:52 -05:00
Jaidyn Ann dcc5e443d3 Support temporary disabling of accounts
Accounts can now be temporarily disabled (in a Pidgin-like style)
through Preferences->Accounts. Work is still required to allow
enabling/re-enabling of accounts on-the-fly, and for keeping an
account's disabled state persistent.
2021-06-11 20:33:28 -05:00
Jaidyn Ann 5b5840a79e 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
Jaidyn Ann 3827787d38 Jabber support for receiving invitations 2021-06-08 19:59:22 -05:00