Reverting online/offline addings
This commit reverts online/offline addings, but keeps possibly useful functions for better future. Right now functions with online functionality saved but unused, they are replaced with almost the same functions. Names was kept as much as possible.
This commit is contained in:
parent
186b4f46d4
commit
8807bbfe80
|
@ -26,14 +26,5 @@
|
||||||
</layout>
|
</layout>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="status_image">
|
|
||||||
<property name="pixel-size">12</property>
|
|
||||||
<layout>
|
|
||||||
<property name="column">2</property>
|
|
||||||
<property name="row">0</property>
|
|
||||||
</layout>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
|
@ -29,8 +29,8 @@ public class List : Box {
|
||||||
list_box.set_filter_func(filter);
|
list_box.set_filter_func(filter);
|
||||||
search_entry.search_changed.connect(refilter);
|
search_entry.search_changed.connect(refilter);
|
||||||
|
|
||||||
stream_interactor.get_module(PresenceManager.IDENTITY).show_received.connect(on_received_online_presence);
|
stream_interactor.get_module(PresenceManager.IDENTITY).show_received.connect(on_show_received);
|
||||||
stream_interactor.get_module(PresenceManager.IDENTITY).received_offline_presence.connect(on_received_offline_presence);
|
stream_interactor.get_module(PresenceManager.IDENTITY).received_offline_presence.connect(on_quit_received);
|
||||||
|
|
||||||
initialize_for_conversation(conversation);
|
initialize_for_conversation(conversation);
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,11 @@ public class List : Box {
|
||||||
this.conversation = conversation;
|
this.conversation = conversation;
|
||||||
|
|
||||||
var identity = stream_interactor.get_module(MucManager.IDENTITY);
|
var identity = stream_interactor.get_module(MucManager.IDENTITY);
|
||||||
Gee.List<Jid>? members = identity.get_all_members(conversation.counterpart, conversation.account);
|
Gee.List<Jid>? members = identity.get_members(conversation.counterpart, conversation.account);
|
||||||
if (members != null) {
|
if (members != null) {
|
||||||
// Add all members and their status to the list
|
// Add all members and their status to the list
|
||||||
foreach (Jid member in members) {
|
foreach (Jid member in members) {
|
||||||
bool online = get_status(member, conversation.account);
|
add_member(member); //use add_member_with_status if you want to get online/offline statuses
|
||||||
add_member(member, online);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list_box.invalidate_filter();
|
list_box.invalidate_filter();
|
||||||
|
@ -83,7 +82,7 @@ public class List : Box {
|
||||||
list_box.invalidate_filter();
|
list_box.invalidate_filter();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add_member(Jid jid, bool online) {
|
public void add_member_with_status(Jid jid, bool online) {
|
||||||
// HACK:
|
// HACK:
|
||||||
// Here we track members based on their names (not jids)
|
// Here we track members based on their names (not jids)
|
||||||
// Sometimes the same member can be referenced with different jids, for example:
|
// Sometimes the same member can be referenced with different jids, for example:
|
||||||
|
@ -124,6 +123,35 @@ public class List : Box {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void add_member(Jid jid) {
|
||||||
|
var row_wrapper = new ListRow(stream_interactor, conversation, jid);
|
||||||
|
var widget = row_wrapper.get_widget();
|
||||||
|
|
||||||
|
string member_name = null;
|
||||||
|
if (jid.resourcepart != null) {
|
||||||
|
member_name = jid.resourcepart;
|
||||||
|
} else {
|
||||||
|
member_name = jid.localpart;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (member_name == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
row_wrappers[widget] = row_wrapper;
|
||||||
|
rows[member_name] = widget;
|
||||||
|
list_box.append(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove_member(Jid jid) {
|
||||||
|
var member_name = jid.resourcepart;
|
||||||
|
if (member_name == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
list_box.remove(rows[member_name]);
|
||||||
|
rows.unset(member_name);
|
||||||
|
}
|
||||||
|
|
||||||
private void on_received_offline_presence(Jid jid, Account account) {
|
private void on_received_offline_presence(Jid jid, Account account) {
|
||||||
if (conversation != null && conversation.counterpart.equals_bare(jid) && jid.is_full()) {
|
if (conversation != null && conversation.counterpart.equals_bare(jid) && jid.is_full()) {
|
||||||
var member_name = jid.resourcepart;
|
var member_name = jid.resourcepart;
|
||||||
|
@ -139,6 +167,19 @@ public class List : Box {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void on_quit_received(Jid jid, Account account) {
|
||||||
|
if (conversation != null && conversation.counterpart.equals_bare(jid) && jid.is_full()) {
|
||||||
|
var member_name = jid.resourcepart;
|
||||||
|
if (member_name == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (rows.has_key(member_name)) {
|
||||||
|
remove_member(jid);
|
||||||
|
}
|
||||||
|
list_box.invalidate_filter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void on_received_online_presence(Jid jid, Account account) {
|
private void on_received_online_presence(Jid jid, Account account) {
|
||||||
if (conversation != null && conversation.counterpart.equals_bare(jid) && jid.is_full()) {
|
if (conversation != null && conversation.counterpart.equals_bare(jid) && jid.is_full()) {
|
||||||
var member_name = jid.resourcepart;
|
var member_name = jid.resourcepart;
|
||||||
|
@ -147,7 +188,7 @@ public class List : Box {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rows.has_key(member_name)) {
|
if (!rows.has_key(member_name)) {
|
||||||
add_member(jid, true);
|
add_member_with_status(jid, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
row_wrappers[rows[member_name]].set_online();
|
row_wrappers[rows[member_name]].set_online();
|
||||||
|
@ -156,6 +197,20 @@ public class List : Box {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void on_show_received(Jid jid, Account account) {
|
||||||
|
if (conversation != null && conversation.counterpart.equals_bare(jid) && jid.is_full()) {
|
||||||
|
var member_name = jid.resourcepart;
|
||||||
|
if (member_name == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!rows.has_key(member_name)) {
|
||||||
|
add_member(jid);
|
||||||
|
}
|
||||||
|
list_box.invalidate_filter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void header(ListBoxRow row, ListBoxRow? before_row) {
|
private void header(ListBoxRow row, ListBoxRow? before_row) {
|
||||||
ListRow row_wrapper1 = row_wrappers[row.get_child()];
|
ListRow row_wrapper1 = row_wrappers[row.get_child()];
|
||||||
Xmpp.Xep.Muc.Affiliation? a1 = stream_interactor.get_module(MucManager.IDENTITY).get_affiliation(conversation.counterpart, row_wrapper1.jid, row_wrapper1.conversation.account);
|
Xmpp.Xep.Muc.Affiliation? a1 = stream_interactor.get_module(MucManager.IDENTITY).get_affiliation(conversation.counterpart, row_wrapper1.jid, row_wrapper1.conversation.account);
|
||||||
|
|
|
@ -10,7 +10,6 @@ public class ListRow : Object {
|
||||||
private Grid main_grid;
|
private Grid main_grid;
|
||||||
private AvatarPicture picture;
|
private AvatarPicture picture;
|
||||||
public Label name_label;
|
public Label name_label;
|
||||||
public Image status_image;
|
|
||||||
public Conversation? conversation;
|
public Conversation? conversation;
|
||||||
public Jid? jid;
|
public Jid? jid;
|
||||||
|
|
||||||
|
@ -19,7 +18,6 @@ public class ListRow : Object {
|
||||||
main_grid = (Grid) builder.get_object("main_grid");
|
main_grid = (Grid) builder.get_object("main_grid");
|
||||||
picture = (AvatarPicture) builder.get_object("picture");
|
picture = (AvatarPicture) builder.get_object("picture");
|
||||||
name_label = (Label) builder.get_object("name_label");
|
name_label = (Label) builder.get_object("name_label");
|
||||||
status_image = (Image) builder.get_object("status_image");
|
|
||||||
main_grid.set_column_spacing(10);
|
main_grid.set_column_spacing(10);
|
||||||
main_grid.set_column_homogeneous(false);
|
main_grid.set_column_homogeneous(false);
|
||||||
main_grid.set_baseline_row(1);
|
main_grid.set_baseline_row(1);
|
||||||
|
@ -43,11 +41,9 @@ public class ListRow : Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set_online() {
|
public void set_online() {
|
||||||
status_image.icon_name = "dino-status-online-bright";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set_offline() {
|
public void set_offline() {
|
||||||
status_image.icon_name = "dino-status-offline";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue