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.
This commit is contained in:
Jaidyn Ann 2021-08-08 21:01:42 -05:00
parent 4bd821eee5
commit 373dcb4a58
12 changed files with 82 additions and 79 deletions

View File

@ -18,7 +18,7 @@ class BBitmap;
#define APP_VERSION_1_PRE_ALPHA_1 0x00000001
#define APP_VERSION_1_ALPHA_1 0x00000100
#define APP_VERSION APP_VERSION_1_PRE_ALPHA_1
#define APP_VERSION APP_VERSION_1_ALPHA_1
class ChatProtocolMessengerInterface {

View File

@ -30,29 +30,29 @@ enum im_what_code {
*/
//! Request a server-side contact list from protocol →Protocol
IM_GET_CONTACT_LIST = 1,
IM_GET_ROSTER = 1,
/*! Server-side contact list received →App
Requires: Stringlist "user_id" */
IM_CONTACT_LIST = 2,
IM_ROSTER = 2,
/*! Add a contact to the roster →Protocol
The slots for this message are determined by the protocol's
"roster" template (ChatProtocol::SettingsTemplate("roster")) */
IM_CONTACT_LIST_ADD_CONTACT = 3,
IM_ROSTER_ADD_CONTACT = 3,
/*! Remove a contact →Protocol
Requires: String "user_id" */
IM_CONTACT_LIST_REMOVE_CONTACT = 4,
IM_ROSTER_REMOVE_CONTACT = 4,
/*! Contact(s) removed from the server-side list →App
Requires: String "user_id" */
IM_CONTACT_LIST_CONTACT_REMOVED = 5,
IM_ROSTER_CONTACT_REMOVED = 5,
/*! Edit some data on contact →Protocol
The slots for this message are determined by the protocol's
"roster" template (ChatProtocol::SettingsTemplate("roster")) */
IM_CONTACT_LIST_EDIT_CONTACT = 6,
IM_ROSTER_EDIT_CONTACT = 6,
/*
@ -79,39 +79,29 @@ enum im_what_code {
Accepts: in64s "when" */
IM_LOGS_RECEIVED = 23,
/*! User started typing →App
Requires: String "chat_id", String "user_id" */
IM_USER_STARTED_TYPING = 24,
/*! User stopped typing →App
Requires: String "chat_id", String "user_id" */
IM_USER_STOPPED_TYPING = 25,
/*
* Messages related to contact changes.
* Messages related changes in general users.
*/
//! Change contact's status →Protocol
IM_SET_NICKNAME = 40,
/*! User's nick has changed →App */
IM_USER_NICKNAME_SET = 40,
//! Contact's status has changed →App
IM_NICKNAME_SET = 41,
/*! Received new status for user →App
Requires: String "user_id", int32/UserStatus "status" */
IM_USER_STATUS_SET = 41,
/*! User's avatar icon was changed →App
Requires: String "user_id", Ref "ref" */
IM_USER_AVATAR_SET = 42,
/*
* Messages related to contact's information received from protocols.
*/
/*! Received contact new status →App
Requires: String "user_id", int32/UserStatus "status" */
IM_STATUS_SET = 60,
/*! User's avatar icon was changed →App
Requires: String "user_id", Ref "ref" */
IM_AVATAR_SET = 61,
//! Get contact information →Protocol
/*! Get contact information →Protocol
Requires: String "user_id" */
IM_GET_CONTACT_INFO = 62,
/*! Received contact information →App
@ -120,13 +110,14 @@ enum im_what_code {
int32/UserStatus "status" */
IM_CONTACT_INFO = 63,
//! Request contact information →Protocol
/*! Request contact information →Protocol
Requires: String "user_id" */
IM_GET_EXTENDED_CONTACT_INFO = 64,
/*! Received contact information →App
Requires: String "user_id",
non-standard slots used by "roster" template
Accepts: String "user_name", String "full_name" */
Accepts: String "user_name" */
IM_EXTENDED_CONTACT_INFO = 65,
@ -169,10 +160,10 @@ enum im_what_code {
* Contacts registration.
*/
//! Start listening to changes in these contact's statuses
//! Start listening to changes in these contact's statuses [unused]
IM_REGISTER_CONTACTS = 100,
//! Stop listening to status changes from these contacts
//! Stop listening to status changes from these contacts [unused]
IM_UNREGISTER_CONTACTS = 101,
@ -180,19 +171,19 @@ enum im_what_code {
* Authorization.
*/
//! Ask authorization to contact
//! Ask authorization to contact [unused]
IM_ASK_AUTHORIZATION = 120,
//! Authorization response received from contact
//! Authorization response received from contact [unused]
IM_AUTHORIZATION_RECEIVED = 121,
//! Authorization request received from contact
//! Authorization request received from contact [unused]
IM_AUTHORIZATION_REQUEST = 122,
//! Authorization response given to contact
//! Authorization response given to contact [unused]
IM_AUTHORIZATION_RESPONSE = 123,
//! Contact has been authorized
//! Contact has been authorized [unused]
IM_CONTACT_AUTHORIZED = 124,
@ -388,6 +379,19 @@ enum im_what_code {
IM_ROOM_UNDEAFEN_PARTICIPANT = 199,
/*
* Misc. room-related messages
*/
/*! User started typing →App [unused]
Requires: String "chat_id", String "user_id" */
IM_ROOM_PARTICIPANT_STARTED_TYPING = 210,
/*! User stopped typing →App [unused]
Requires: String "chat_id", String "user_id" */
IM_ROOM_PARTICIPANT_STOPPED_TYPING = 211,
/*
* Misc. UI messages
*/
@ -403,10 +407,10 @@ enum im_what_code {
* Special messages
*/
//! Special message forwarded to protocol; Unused
//! Special message forwarded to protocol [unused]
IM_SPECIAL_TO_PROTOCOL = 1000,
//! Special message forwarded from protocol; Unused
//! Special message forwarded from protocol [unused]
IM_SPECIAL_FROM_PROTOCOL = 1001,
/*! Protocol is ready →App
@ -417,8 +421,8 @@ enum im_what_code {
This requests that the app delete the ChatProtocol and its
ProtocolLooper so invoking ChatProtocol::Shutdown().
This should be sent by the protocol after connection errors or a
disconnect, when the addon doesn't have anything left to do (other
than yearn for the sweet hand of death). */
disconnect, when the addon doesn't have anything left to do other
than yearn for the sweet hand of death. */
IM_PROTOCOL_DISABLE = 1003
};

View File

@ -248,7 +248,7 @@ Server::ImMessage(BMessage* msg)
int32 im_what = msg->FindInt32("im_what");
switch (im_what) {
case IM_CONTACT_LIST:
case IM_ROSTER:
{
int i = 0;
BString id;
@ -257,7 +257,7 @@ Server::ImMessage(BMessage* msg)
result = B_SKIP_MESSAGE;
break;
}
case IM_CONTACT_LIST_CONTACT_REMOVED:
case IM_ROSTER_CONTACT_REMOVED:
{
Contact* contact = _EnsureContact(msg);
ProtocolLooper* looper = _LooperFromMessage(msg);
@ -297,7 +297,7 @@ Server::ImMessage(BMessage* msg)
contact->SetNotifyName(nick.String());
break;
}
case IM_STATUS_SET:
case IM_USER_STATUS_SET:
{
int32 status;
@ -382,7 +382,7 @@ Server::ImMessage(BMessage* msg)
}
break;
}
case IM_AVATAR_SET:
case IM_USER_AVATAR_SET:
{
User* user = _EnsureUser(msg);
if (!user)
@ -531,8 +531,8 @@ Server::ImMessage(BMessage* msg)
invite->Go();
break;
}
case IM_USER_STARTED_TYPING:
case IM_USER_STOPPED_TYPING:
case IM_ROOM_PARTICIPANT_STARTED_TYPING:
case IM_ROOM_PARTICIPANT_STOPPED_TYPING:
{
// User* user = _EnsureUser();
// Conversation* chat = _EnsureConversation();

View File

@ -112,7 +112,7 @@ RosterView::ImMessage(BMessage* msg)
{
int32 im_what = msg->FindInt32("im_what");
switch (im_what) {
case IM_STATUS_SET:
case IM_USER_STATUS_SET:
{
int32 status;
int64 instance;
@ -181,7 +181,7 @@ RosterView::ImMessage(BMessage* msg)
}
break;
}
case IM_CONTACT_LIST_CONTACT_REMOVED:
case IM_ROSTER_CONTACT_REMOVED:
{
int32 status = -1;
int64 instance;
@ -197,7 +197,7 @@ RosterView::ImMessage(BMessage* msg)
if (rosterItem)
fListView->RemoveItem(rosterItem);
}
case IM_AVATAR_SET:
case IM_USER_AVATAR_SET:
case IM_CONTACT_INFO:
case IM_EXTENDED_CONTACT_INFO:
{

View File

@ -308,11 +308,11 @@ MainWindow::ImMessage(BMessage* msg)
delete item->GetConversation();
break;
}
case IM_AVATAR_SET:
case IM_STATUS_SET:
case IM_USER_AVATAR_SET:
case IM_USER_STATUS_SET:
case IM_CONTACT_INFO:
case IM_EXTENDED_CONTACT_INFO:
case IM_CONTACT_LIST_CONTACT_REMOVED: {
case IM_ROSTER_CONTACT_REMOVED: {
if (fRosterWindow != NULL)
fRosterWindow->PostMessage(msg);
if (RosterEditWindow::Check() == true)

View File

@ -163,7 +163,7 @@ RosterEditWindow::MessageReceived(BMessage* message)
}
BMessage* edit = new BMessage(IM_MESSAGE);
edit->AddInt32("im_what", IM_CONTACT_LIST_EDIT_CONTACT);
edit->AddInt32("im_what", IM_ROSTER_EDIT_CONTACT);
const char* title;
if (ritem == NULL)
@ -186,7 +186,7 @@ RosterEditWindow::MessageReceived(BMessage* message)
case kAddMember:
{
BMessage* add = new BMessage(IM_MESSAGE);
add->AddInt32("im_what", IM_CONTACT_LIST_ADD_CONTACT);
add->AddInt32("im_what", IM_ROSTER_ADD_CONTACT);
TemplateWindow* win =
new TemplateWindow(B_TRANSLATE(kAddTitle), "roster",
add, fServer);
@ -202,7 +202,7 @@ RosterEditWindow::MessageReceived(BMessage* message)
User* user = ritem->GetContact();
BMessage* rem = new BMessage(IM_MESSAGE);
rem->AddInt32("im_what", IM_CONTACT_LIST_REMOVE_CONTACT);
rem->AddInt32("im_what", IM_ROSTER_REMOVE_CONTACT);
rem->AddString("user_id", user->GetId());
user->GetProtocolLooper()->PostMessage(rem);

View File

@ -46,7 +46,7 @@ friendly_signature()
uint32
version()
{
return APP_VERSION_1_PRE_ALPHA_1;
return APP_VERSION_1_ALPHA_1;
}

View File

@ -284,7 +284,7 @@ PurpleApp::ImMessage(BMessage* msg)
SendMessage(purple_conversation_get_account(conv), parts);
break;
}
case IM_GET_CONTACT_LIST:
case IM_GET_ROSTER:
{
PurpleAccount* account = _AccountFromMessage(msg);
@ -297,12 +297,12 @@ PurpleApp::ImMessage(BMessage* msg)
}
BMessage roster(IM_MESSAGE);
roster.AddInt32("im_what", IM_CONTACT_LIST);
roster.AddInt32("im_what", IM_ROSTER);
roster.AddStrings("user_id", user_ids);
SendMessage(_AccountFromMessage(msg), roster);
break;
}
case IM_CONTACT_LIST_ADD_CONTACT:
case IM_ROSTER_ADD_CONTACT:
{
PurpleAccount* account = _AccountFromMessage(msg);
BString user_id = msg->FindString("user_id");
@ -317,7 +317,7 @@ PurpleApp::ImMessage(BMessage* msg)
update_buddy(buddy_cache(buddy), user_id, BString(user_name));
break;
}
case IM_CONTACT_LIST_REMOVE_CONTACT:
case IM_ROSTER_REMOVE_CONTACT:
{
PurpleAccount* account = _AccountFromMessage(msg);
BString user_id = msg->FindString("user_id");
@ -331,7 +331,7 @@ PurpleApp::ImMessage(BMessage* msg)
BEntry(buddy_cache(buddy)).Remove();
break;
}
case IM_CONTACT_LIST_EDIT_CONTACT:
case IM_ROSTER_EDIT_CONTACT:
{
PurpleAccount* account = _AccountFromMessage(msg);
BString user_id = msg->FindString("user_id");
@ -1186,7 +1186,7 @@ signal_blist_node_added(PurpleBlistNode* node)
return;
BMessage add(IM_MESSAGE);
add.AddInt32("im_what", IM_CONTACT_LIST);
add.AddInt32("im_what", IM_ROSTER);
add.AddString("user_id", purple_buddy_get_name(buddy));
((PurpleApp*)be_app)->SendMessage(purple_buddy_get_account(buddy), add);
@ -1215,7 +1215,7 @@ signal_blist_node_removed(PurpleBlistNode* node)
return;
BMessage rem(IM_MESSAGE);
rem.AddInt32("im_what", IM_CONTACT_LIST_CONTACT_REMOVED);
rem.AddInt32("im_what", IM_ROSTER_CONTACT_REMOVED);
rem.AddString("user_id", purple_buddy_get_name(buddy));
((PurpleApp*)be_app)->SendMessage(purple_buddy_get_account(buddy), rem);
}
@ -1226,7 +1226,7 @@ signal_buddy_status_changed(PurpleBuddy* buddy, PurpleStatus* old_status,
PurpleStatus* status)
{
BMessage note(IM_MESSAGE);
note.AddInt32("im_what", IM_STATUS_SET);
note.AddInt32("im_what", IM_USER_STATUS_SET);
note.AddInt32("status", purple_status_to_cardie(status));
note.AddString("user_id", purple_buddy_get_name(buddy));
((PurpleApp*)be_app)->SendMessage(purple_buddy_get_account(buddy), note);
@ -1242,7 +1242,7 @@ signal_buddy_icon_changed(PurpleBuddy* buddy)
return;
BMessage avatar(IM_MESSAGE);
avatar.AddInt32("im_what", IM_AVATAR_SET);
avatar.AddInt32("im_what", IM_USER_AVATAR_SET);
avatar.AddString("user_id", purple_buddy_get_name(buddy));
avatar.AddRef("ref", &ref);
((PurpleApp*)be_app)->SendMessage(purple_buddy_get_account(buddy), avatar);

View File

@ -85,7 +85,7 @@ friendly_signature()
uint32
version()
{
return APP_VERSION_1_PRE_ALPHA_1;
return APP_VERSION_1_ALPHA_1;
}

View File

@ -101,5 +101,4 @@ private:
BObjectList<BMessage> fCommands;
};
#endif // _PURPLE_PROTOCOL_H

View File

@ -265,7 +265,7 @@ JabberHandler::Process(BMessage* msg)
fVCardManager->fetchVCard(gloox::JID(user_id.String()), this);
break;
}
case IM_CONTACT_LIST_ADD_CONTACT:
case IM_ROSTER_ADD_CONTACT:
{
BString user_name = msg->FindString("user_name");
BString user_id;
@ -278,7 +278,7 @@ JabberHandler::Process(BMessage* msg)
fClient->rosterManager()->synchronize();
break;
}
case IM_CONTACT_LIST_REMOVE_CONTACT:
case IM_ROSTER_REMOVE_CONTACT:
{
BString user_id;
if (msg->FindString("user_id", &user_id) != B_OK)
@ -288,12 +288,12 @@ JabberHandler::Process(BMessage* msg)
fClient->rosterManager()->synchronize();
BMessage rm(IM_MESSAGE);
rm.AddInt32("im_what", IM_CONTACT_LIST_CONTACT_REMOVED);
rm.AddInt32("im_what", IM_ROSTER_CONTACT_REMOVED);
rm.AddString("user_id", user_id);
_SendMessage(&rm);
break;
}
case IM_CONTACT_LIST_EDIT_CONTACT:
case IM_ROSTER_EDIT_CONTACT:
{
BString user_id;
BString user_name = msg->FindString("user_name");
@ -1001,7 +1001,7 @@ JabberHandler::_StatusSetMsg(const char* user_id, gloox::Presence::PresenceType
const char* message, const char* resource)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_SET);
msg.AddInt32("im_what", IM_USER_STATUS_SET);
msg.AddString("user_id", user_id);
msg.AddInt32("status", _GlooxStatusToApp(type));
@ -1147,7 +1147,7 @@ JabberHandler::_AvatarChanged(const char* id, const char* filename)
if (fJid.bare() == id)
msg.AddInt32("im_what", IM_OWN_AVATAR_SET);
else {
msg.AddInt32("im_what", IM_AVATAR_SET);
msg.AddInt32("im_what", IM_USER_AVATAR_SET);
msg.AddString("user_id", id);
}
msg.AddRef("ref", &ref);
@ -1467,7 +1467,7 @@ JabberHandler::handleRoster(const gloox::Roster& roster)
std::list<BMessage> msgs;
BMessage contactListMsg(IM_MESSAGE);
contactListMsg.AddInt32("im_what", IM_CONTACT_LIST);
contactListMsg.AddInt32("im_what", IM_ROSTER);
gloox::Roster::const_iterator it = roster.begin();
for (; it != roster.end(); ++it) {
@ -1591,10 +1591,10 @@ JabberHandler::handleChatState(const gloox::JID& from, gloox::ChatStateType stat
switch (state) {
case gloox::ChatStateComposing:
msg.AddInt32("im_what", IM_USER_STARTED_TYPING);
msg.AddInt32("im_what", IM_PARTICIPANT_STARTED_TYPING);
break;
case gloox::ChatStatePaused:
msg.AddInt32("im_what", IM_USER_STOPPED_TYPING);
msg.AddInt32("im_what", IM_PARTICIPANT_STOPPED_TYPING);
break;
case gloox::ChatStateGone:
// TODO

View File

@ -51,7 +51,7 @@ friendly_signature()
uint32
version()
{
return APP_VERSION_1_PRE_ALPHA_1;
return APP_VERSION_1_ALPHA_1;
}