Commit Graph

105 Enmetoj

Author SHA1 Message Date
Jaidyn Ann 06b1df8882 (purple) Sending messages to chats 2021-06-28 12:51:50 -05:00
Jaidyn Ann 82cf946bc8 (purple) Joining rooms, receiving chat messages 2021-06-28 12:13:24 -05:00
Jaidyn Ann 30e3d6eefd (purple) Handle own status changes 2021-06-27 20:42:37 -05:00
Jaidyn Ann f755fa298b (purple) Disconnection of accounts, quit server w/o Cardie 2021-06-27 17:33:20 -05:00
Jaidyn Ann 588b32b9c3 (purple) Main loop, server→add-on→app communication
Now the purple add-on's starting to come together with a clear
structure:
	* Add-on sends IM_MESSAGES etc to the server for processing
	* Server sends all (reply/etc) messages to add-on, which sends
	  to app

It's worth noting that on the add-on's side, no looper or handler is
used for receiving messages, it's all through sending serialized
BMessages to the add-on's connect_thread buffer.

PurpleAccounts are now reliably associated with Cardie's account names
and the thread ID of their respective connect_thread.

The GLib main-loop is gone over regularly thanks to a message runner.

Now, the add-on can log into/create accounts, connect to them, and send
the IM_PROTOCOL_READY notification to Cardie as appropriate.
2021-06-27 16:46:38 -05:00
Jaidyn Ann 66df891577 (purple) Support drop-down string/path menu settings 2021-06-26 21:37:47 -05:00
Jaidyn Ann 0aea480ec2 (purple) Loading Cardie-side account settings into PurpleAccount 2021-06-26 20:40:39 -05:00
Jaidyn Ann 6507a4182f Receive protocols' settings templates from libpurple 2021-06-24 12:22:34 -05:00
Jaidyn Ann ddaf39c300 Returning libpurple protocol amount and names
The libpurple add-on has been split into two parts― a background process
that will actually interface with libpurple, and an add-on that acts as
intermediary between Cardie and the process. This helps prevent
redundancy, and is giving me a lot less trouble that directly loading
libpurple.

The protocol amount and names are now returned by the add-on (through
protocol_count() and protocol_at() respectively)― you can see them in
Preferences' protocol list.
2021-06-23 23:57:27 -05:00
Jaidyn Ann b52be74dfb Init libpurple add-on 2021-06-22 14:42:07 -05:00
Jaidyn Ann de28bc8673 Match up nick with own user_id 2021-06-21 03:22:35 -05:00
Jaidyn Ann 31bc304c0b Enable IRC protocol 2021-06-21 03:06:15 -05:00
Jaidyn Ann 0c615b01fd Basic IRC connection/messaging/joining, etc. 2021-06-21 01:54:42 -05:00
Jaidyn Ann 57ecbd1cb3 Init IRC add-on 2021-06-20 22:17:24 -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 a21c8f7601 Editing of roster members
Roster members' can now be edited (through Roster->Edit Roster / CMD+R)

TemplateWindows can now be populated through sending any IM_MESSAGE to
it (it will assume the slots of the message correspond to the
template's).

IM_CONTACT_LIST_ADDED_CONTACT was removed (for redundancy), and
IM_CONTACT_LIST_EDIT_CONTACT was added.
2021-06-19 22:03:02 -05:00
Jaidyn Ann f4342d9310 Roster management, adding new contacts
The base for roster management (RosterEditWindow) has been made, and
adding new contacts works. Up next is contact removal and editing.

This leverages a new template (as defined in a protocol's
CayaProtocol::SettingsTemplate()), "roster," which should contain all
slots pertinent to editing/adding a contact member.

Two new API messages were added for this― IM_CONTACT_LIST_CONTACT_ADDED
and IM_CONTACT_LIST_CONTACT_REMOVED. The former will functionally just
be IM_CONTACT_INFO, but with some semantical meaning.

A new CayaMessage (CAYA_EDIT_ROSTER) was also added.

TemplateWindow was also edited to this end: Now, like RosterWindow/View,
it can be given a specific accounts' instance id, and it will prevent
the selection of another account. A new constructor was also added, to
allow a ProtocolTemplate to be explicitly passed to it― probably from
the program itself.
2021-06-19 18:25:58 -05:00
Jaidyn Ann 84eb2d68ba Slight template window tweaks 2021-06-18 14:18:45 -05:00
Jaidyn Ann 4f8aaf7957 Add 'error' slot for templates 2021-06-18 12:49:30 -05:00
Jaidyn Ann 48f84377fc Room-creation for XMPP 2021-06-18 01:30:59 -05:00
Jaidyn Ann 3fbe072d42 Generalize protocol settings' GUI templating
A nice templating system is used for account settings dialogues― the
required slots are specified by the protocol, and are reflected in the
settings dialogue.

To generalize this templating system (and eventually use elsewhere),
ProtocolSettings was split into two classes― ProtocolSettings and
ProtocolTemplate.

The CayaProtocol::SettingsTemplate() call was also edited to require a
string parameter, naming the specific template that should be returned.

"account" is used for the account settings dialogue, and other values
are TBA.
2021-06-17 17:02:29 -05:00
Jaidyn Ann 9eaeac24e6 Split icons into seperate RDEF files 2021-06-17 11:49:42 -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 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 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 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 7767995400 Use account-based rather than protocol-based cache paths 2021-06-09 11:40:27 -05:00
Jaidyn Ann 5723f55433 Support sending invitations
Fixes #5
2021-06-08 21:43:41 -05:00
Jaidyn Ann 3827787d38 Jabber support for receiving invitations 2021-06-08 19:59:22 -05:00
Jaidyn Ann 26e99477fc Document protocol API 2021-06-07 11:45:30 -05:00
Jaidyn Ann 77d914312c Show users' joins/parts in chat view
New API messages were added to distinguish between a user leaving of
their own volition and being kicked/banned.

Messages are now shown in the chat view when a user leaves or or
kicked/banned, etc.
2021-06-07 00:03:15 -05:00
Jaidyn Ann 260b36012e Support moderation (muting, kicking, etc)
Allow kicking/banning/muting/unmuting/deafening and undeafening through
the UserListView right-click menu (if permissions are sufficient).

Support for banning, kicking, and muting were added to the XMPP add-on―
deafening isn't supported, so is left out.
2021-06-06 17:51:22 -05:00
Jaidyn Ann dc3fdd65c8 Store chatlogs in binary and text formats
If chat logs are stored in an endless plain-text file, they're going to be a
pain to parse. If they're stored in a binary file, they're a pain for
the user to `grep` or go through manually, but they're easier to parse.

Why not both?

Logs are now stored with a BMessage (with BStringLists) in the 'logs'
attribute, and the plain-text logs in the file itself.

The attribute will only store 20 messages, but the file itself will be
appended to forever.

The logs directory also changed, from ~/config/settings/Caya/Cache/Logs
to ~/config/settings/Caya/Logs.

Useful functions for reading/writing messages to and from an attribute were
borrowed from BePodder's libfunky. :-)
2021-06-06 12:02:26 -05:00
Jaidyn Ann fe99f3d83a Show moderation items in right-click user menu, by perm 2021-06-06 01:49:11 -05:00
Jaidyn Ann 6e1ca87890 Support for "Roles" (user, moderator, admin, etc.)
Add scaffodling support for arbitrary roles and permission-based (and
varying!) UI.

A new class, Role, represents a user's role in a given room, with three
values:
	* The role's title
	* The role's permission-set
	* The role's priority

The permission set is a bitmask value for various permissions (e.g.,
PERM_WRITE, PERM_BAN, etc), and priority is position in the hierarchy.
A user with higher priority (and PERM_BAN) can ban a user with lower
priority, but not vice-versa. Two users with the same priority can't
ban/kick/mute each other, etc.

These permissions should be used to determine what UI elements are
displayed― if the user doesn't have permission to ban users, then a
"Ban" button shouldn't exist. If the user is muted, they shouldn't be
able to type. So on and so forth.

For now, permissions are sent with a IM_ROLECHANGE message and stored
by the Conversation, but aren't really in use yet.

This system should be flexible groundwork to account for the varying
administrative hierarchies and norms of different protocols.
2021-06-06 00:59:07 -05:00
Jaidyn Ann 2f1aee3220 XMPP support for IM_ROOM_LEAVE/IM_ROOM_LEFT 2021-06-04 16:34:25 -05:00
Jaidyn Ann 89905fe23c Show/receive room subjects, show protocol icon in conversation view
The conversation view now displays the protocol icon and room subject.
Messages for receiving room names (IM_ROOM_NAME) and subjects
(IM_ROOM_SUBJECT) were added, and support for the latter was given to
the XMPP add-on.

New message APIs were added, and several (room-related) im_what values were
moved into the 150s/160s.

UserItem::_TintColor() was moved to CayaUtils, because it can be used in
several different contexts.
2021-06-04 13:57:04 -05:00
Jaidyn Ann 2e1190ae8d Fix handling of chat IDs
Don't show status notifications in group chats, make sure chat IDs are
found and set properly (on the XMPP side of things).
2021-06-03 20:24:34 -05:00
Jaidyn Ann a89bec40a3 Sending messages to MUCs, proper logging 2021-06-03 14:25:51 -05:00
Jaidyn Ann b66ea722b0 Send MUC participants on join, and send participants' status 2021-06-02 16:58:29 -05:00
Jaidyn Ann 061489ba2e Recieve messages from MUC rooms 2021-06-02 12:34:00 -05:00
Jaidyn Ann 770f7eaee3 Support for joining MUCs; Stanza error-handling
Adds basic support for joining MUCs― so basic that Caya won't even tell
the user they've joined, and messages can't be received.

The scaffolding for further MUC development was added, and some
much-needed error-handling for stanzas has been created.
2021-06-01 21:53:50 -05:00
Jaidyn Ann 0326cee687 Move roster into its own generic window
The roster list is now split from MainWindow into RosterWindow, which
can be used arbitrarily for selecting something from contacts. The
im_what, title, and target can be specified.

Right now it's in use under the Chat menu, "New chat…". Chats can only
have two members (DM/PM), so "New chat…" directly leads to the roster
list.

In the future, roster list might be extended to allow specification of
non-contact users based on their identifiers, or filtering based on
protocol/account― this could help it with "invites" to future rooms,
etc.

IM_CREATE_CHAT and IM_CHAT_CREATED were also added to the protocol API,
allowing a new chat to be explicitly created from Caya or the protocol.
2021-05-26 07:48:25 -05:00
Jaidyn Ann 3d020c4628 Populate conversations with logs, if any saved
Also adds a function to protocols to toggle this― if CayaProtocol::SaveLogs()
returns true, then local logs will be used to popualte conversation
windows. Otherwise, it's up to the protocol itself.

A new protocol IM_MESSAGE was also created, IM_LOGS_RECEIVED, which can
be used to populate conversations with old logs.
2021-05-24 19:12:42 -05:00
Jaidyn Ann 48d0b7bc96 Create Conversation class, use it instead of Contact for chats
This is a commit with it's foot in a lot of places, but:

The Conversation class was created as the abstraction of chats: All
ImMessages that are relevant to a conversation get routed through it,
meta-data on chats is stored in it (even if right now that's basically
limited to the user list and ID).

Server was given more methods to help accessing contacts―
ContactById(BString) and AddContact(Contact*). This better allows
Conversations to add and fetch Contacts as necessary. Right now, all
users in chats are treated as Contacts, so in the future creating an
independent userlist for Server (fUserMap?) would be useful.

Server also now stores all Conversations (fChatMap) and has some
convenience methods like for Contacts: Conversations(),
ConversationById(BString), and AddConversation(Conversation*).

CayaRenderView has been changed to not store user nicks, and will use
the appropriate nick of any arbitrarily-numbered user.

Users also have a map of all Conversations they are a part of
(fChatMap).

The Remove* methods of KeyMap now return the removed item.
2021-05-24 01:47:21 -05:00
Jaidyn Ann 61a1f0baf1 Allow multiple protocols per add-on
Now an add-on can contain multiple protocols, and the protocol API has
changed. An add-on must now export protocol_count() and protocol_at(),
with the latter replacing protocol(). protocol_count() returning the
amount of protocols in a given add-on, and protocol_at(i) giving a
new CayaProtocol* "at" the given index.

CayaProtocol has also been changed, adding Signature(),
FriendlySignature(), Icon(), Path(), and SetPath(). The reasoning is
that different protocols (even within a single add-on) will have
different signatures and icons, so this data should be accessible from
the protocol itself.

CayaProtocolAddOn now has CountProtocols() and ProtocolAt(i), allowing
the accessing of multiple protocols. A CayaProtocolAddOn can be given a
default protocol index in the constructor, whose protocol will be
returned with Protocol(). Version() was also moved from CayaProtocol to
CayaProtocolAddOn.
2021-05-21 13:47:14 -05:00