parent
d5aebac5c5
commit
560be5a810
|
@ -396,7 +396,14 @@ enum im_what_code {
|
|||
// Requires: String "_label", Message "_msg", String "class" = "BMenuItem"
|
||||
// Bool "x_to_protocol", int32 "x_perms"
|
||||
// Allowed: int64 "instance"
|
||||
IM_REGISTER_CHATLIST_ITEM = 1102
|
||||
IM_REGISTER_CHATLIST_ITEM = 1102,
|
||||
|
||||
//! Register a "Protocol" menu item →Caya
|
||||
// Just an archived BMenuItem with extra slots; it adds a menu item to
|
||||
// the menubar's "Protocol" menu.
|
||||
// Requires: String "_label", Message "_msg", String "class" = "BMenuItem"
|
||||
// Bool "x_to_protocol", int64 "instance"
|
||||
IM_REGISTER_MENUBAR_ITEM = 1103
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -192,6 +192,20 @@ ProtocolLooper::AddChatPopUpItem(BMessage* archived)
|
|||
}
|
||||
|
||||
|
||||
BObjectList<BMessage>
|
||||
ProtocolLooper::MenuBarItems() const
|
||||
{
|
||||
return fMenuItems;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProtocolLooper::AddMenuBarItem(BMessage* archived)
|
||||
{
|
||||
fMenuItems.AddItem(archived);
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
ProtocolLooper::GetOwnId()
|
||||
{
|
||||
|
|
|
@ -61,6 +61,10 @@ public:
|
|||
ChatPopUpItems() const;
|
||||
void AddChatPopUpItem(BMessage* archived);
|
||||
|
||||
BObjectList<BMessage>
|
||||
MenuBarItems() const;
|
||||
void AddMenuBarItem(BMessage* archived);
|
||||
|
||||
BString GetOwnId();
|
||||
void SetOwnId(BString user_id);
|
||||
|
||||
|
@ -82,6 +86,7 @@ private:
|
|||
CommandMap fCommands;
|
||||
BObjectList<BMessage> fUserItems;
|
||||
BObjectList<BMessage> fChatItems;
|
||||
BObjectList<BMessage> fMenuItems;
|
||||
|
||||
ConversationAccountItem*
|
||||
fListItem;
|
||||
|
|
|
@ -550,6 +550,13 @@ Server::ImMessage(BMessage* msg)
|
|||
looper->AddChatPopUpItem(new BMessage(*msg));
|
||||
break;
|
||||
}
|
||||
case IM_REGISTER_MENUBAR_ITEM:
|
||||
{
|
||||
ProtocolLooper* looper = _LooperFromMessage(msg);
|
||||
if (looper != NULL)
|
||||
looper->AddMenuBarItem(new BMessage(*msg));
|
||||
break;
|
||||
}
|
||||
case IM_PROTOCOL_READY:
|
||||
{
|
||||
// Ready notification
|
||||
|
|
|
@ -348,6 +348,36 @@ MainWindow::SetConversation(Conversation* chat)
|
|||
fRightView->SetItemWeight(0, weightChat, true);
|
||||
fRightView->SetItemWeight(1, weightSend, true);
|
||||
}
|
||||
|
||||
// Remove "Protocol" menu
|
||||
BMenuItem* chatMenuItem = fMenuBar->FindItem("Protocol");
|
||||
BMenu* chatMenu;
|
||||
if (chatMenuItem != NULL && (chatMenu = chatMenuItem->Submenu()) != NULL)
|
||||
fMenuBar->RemoveItem(chatMenu);
|
||||
|
||||
// Add and populate "Protocol" menu, if appropriate
|
||||
if (fConversation != NULL) {
|
||||
ProtocolLooper* looper = fConversation->GetProtocolLooper();
|
||||
BObjectList<BMessage> menuItems = looper->MenuBarItems();
|
||||
for (int i = 0; i < menuItems.CountItems(); i++) {
|
||||
BMessage* itemMsg = menuItems.ItemAt(i);
|
||||
BMessage* msg = new BMessage(*itemMsg);
|
||||
BMessage toSend;
|
||||
msg->FindMessage("_msg", &toSend);
|
||||
toSend.AddString("chat_id", fConversation->GetId());
|
||||
toSend.AddInt64("instance", looper->GetInstance());
|
||||
msg->ReplaceMessage("_msg", &toSend);
|
||||
|
||||
BMenuItem* item = new BMenuItem(msg);
|
||||
if (item == NULL)
|
||||
continue;
|
||||
if (msg->GetBool("x_to_protocol", true) == true)
|
||||
item->SetTarget(looper);
|
||||
else
|
||||
item->SetTarget(this);
|
||||
chatMenu->AddItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Ŝarĝante…
Reference in New Issue