aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdino/src/entity/conversation.vala21
-rw-r--r--libdino/src/entity/jid.vala2
-rw-r--r--libdino/src/entity/message.vala11
-rw-r--r--libdino/src/service/conversation_manager.vala24
-rw-r--r--libdino/src/service/database.vala11
-rw-r--r--libdino/src/service/message_manager.vala98
-rw-r--r--main/CMakeLists.txt1
-rw-r--r--main/src/ui/conversation_selector/chat_row.vala22
-rw-r--r--main/src/ui/conversation_selector/conversation_row.vala23
-rw-r--r--main/src/ui/conversation_selector/groupchat_pm_row.vala54
-rw-r--r--main/src/ui/conversation_selector/list.vala9
-rw-r--r--main/src/ui/conversation_summary/view.vala2
-rw-r--r--main/src/ui/util.vala3
-rw-r--r--xmpp-vala/CMakeLists.txt2
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/flag.vala23
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/identity.vala18
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala36
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/item.vala15
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/module.vala153
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/module.vala4
-rw-r--r--xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala5
21 files changed, 370 insertions, 167 deletions
diff --git a/libdino/src/entity/conversation.vala b/libdino/src/entity/conversation.vala
index 55413785..5a41c7fb 100644
--- a/libdino/src/entity/conversation.vala
+++ b/libdino/src/entity/conversation.vala
@@ -6,7 +6,8 @@ public class Conversation : Object {
public enum Type {
CHAT,
- GROUPCHAT
+ GROUPCHAT,
+ GROUPCHAT_PM
}
public int id { get; set; }
@@ -30,8 +31,8 @@ public class Conversation : Object {
private Database? db;
public Conversation(Jid jid, Account account, Type type) {
- this.counterpart = jid;
this.account = account;
+ this.counterpart = jid;
this.type_ = type;
}
@@ -39,8 +40,10 @@ public class Conversation : Object {
this.db = db;
id = row[db.conversation.id];
- counterpart = new Jid(db.get_jid_by_id(row[db.conversation.jid_id]));
account = db.get_account_by_id(row[db.conversation.account_id]);
+ string? resource = row[db.conversation.resource];
+ string jid = db.get_jid_by_id(row[db.conversation.jid_id]);
+ counterpart = resource != null ? new Jid.with_resource(jid, resource) : new Jid(jid);
active = row[db.conversation.active];
int64? last_active = row[db.conversation.last_active];
if (last_active != null) this.last_active = new DateTime.from_unix_local(last_active);
@@ -55,12 +58,15 @@ public class Conversation : Object {
public void persist(Database db) {
this.db = db;
var insert = db.conversation.insert()
- .value(db.conversation.jid_id, db.get_jid_id(counterpart))
.value(db.conversation.account_id, account.id)
+ .value(db.conversation.jid_id, db.get_jid_id(counterpart))
.value(db.conversation.type_, type_)
.value(db.conversation.encryption, encryption)
//.value(conversation.read_up_to, new_conversation.read_up_to)
.value(db.conversation.active, active);
+ if (counterpart.is_full()) {
+ insert.value(db.conversation.resource, counterpart.resourcepart);
+ }
if (last_active != null) {
insert.value(db.conversation.last_active, (long) last_active.to_unix());
}
@@ -90,7 +96,12 @@ public class Conversation : Object {
case "encryption":
update.set(db.conversation.encryption, encryption); break;
case "read-up-to":
- update.set(db.conversation.read_up_to, read_up_to.id); break;
+ if (read_up_to != null) {
+ update.set(db.conversation.read_up_to, read_up_to.id);
+ } else {
+ update.set_null(db.conversation.read_up_to);
+ }
+ break;
case "active":
update.set(db.conversation.active, active); break;
case "last-active":
diff --git a/libdino/src/entity/jid.vala b/libdino/src/entity/jid.vala
index 96948ca4..edd3bc91 100644
--- a/libdino/src/entity/jid.vala
+++ b/libdino/src/entity/jid.vala
@@ -19,7 +19,7 @@ public class Dino.Entities.Jid : Object {
public Jid.with_resource(string bare_jid, string resource) {
Jid? parsed = Jid.parse(bare_jid);
- this.components(parsed.localpart, parsed.domainpart, resourcepart);
+ this.components(parsed.localpart, parsed.domainpart, resource);
}
public Jid.components(string? localpart, string domainpart, string? resourcepart) {
diff --git a/libdino/src/entity/message.vala b/libdino/src/entity/message.vala
index b5686159..4624aa87 100644
--- a/libdino/src/entity/message.vala
+++ b/libdino/src/entity/message.vala
@@ -20,8 +20,8 @@ public class Message : Object {
ERROR,
CHAT,
GROUPCHAT,
- HEADLINE,
- NORMAL
+ GROUPCHAT_PM,
+ UNKNOWN
}
public int? id { get; set; }
@@ -36,7 +36,7 @@ public class Message : Object {
}
public bool direction { get; set; }
public string? real_jid { get; set; }
- public Type type_ { get; set; }
+ public Type type_ { get; set; default = Type.UNKNOWN; }
public string? body { get; set; }
public string? stanza_id { get; set; }
public DateTime? time { get; set; }
@@ -48,10 +48,9 @@ public class Message : Object {
private Database? db;
- public Message(string? body, Type type) {
+ public Message(string? body) {
this.id = -1;
this.body = body;
- this.type_ = type;
}
public Message.from_row(Database db, Qlite.Row row) {
@@ -107,8 +106,6 @@ public class Message : Object {
type_ = Type.CHAT; break;
case Xmpp.Message.Stanza.TYPE_GROUPCHAT:
type_ = Type.GROUPCHAT; break;
- default:
- type_ = Type.NORMAL; break;
}
}
diff --git a/libdino/src/service/conversation_manager.vala b/libdino/src/service/conversation_manager.vala
index 25d355c4..ff4717ee 100644
--- a/libdino/src/service/conversation_manager.vala
+++ b/libdino/src/service/conversation_manager.vala
@@ -31,7 +31,7 @@ public class ConversationManager : StreamInteractionModule, Object {
stream_interactor.get_module(MessageManager.IDENTITY).message_sent.connect(on_message_sent);
}
- public Conversation create_conversation(Jid jid, Account account, Conversation.Type type) {
+ public Conversation create_conversation(Jid jid, Account account, Conversation.Type? type = null) {
assert(conversations.has_key(account));
if (conversations[account].has_key(jid)) {
return conversations[account][jid];
@@ -43,6 +43,26 @@ public class ConversationManager : StreamInteractionModule, Object {
}
}
+ public Conversation? get_conversation_for_message(Entities.Message message) {
+ if (message.type_ == Entities.Message.Type.CHAT) {
+ return create_conversation(message.counterpart.bare_jid, message.account, Conversation.Type.CHAT);
+ } else if (message.type_ == Entities.Message.Type.GROUPCHAT) {
+ return create_conversation(message.counterpart.bare_jid, message.account, Conversation.Type.GROUPCHAT);
+ } else if (message.type_ == Entities.Message.Type.GROUPCHAT_PM) {
+ return create_conversation(message.counterpart, message.account, Conversation.Type.GROUPCHAT_PM);
+ }
+ return null;
+ }
+
+ public Gee.List<Conversation> get_conversations_for_presence(Show show, Account account) {
+ Gee.List<Conversation> ret = new ArrayList<Conversation>(Conversation.equals_func);
+ Conversation? bare_conversation = get_conversation(show.jid, account);
+ if (bare_conversation != null) ret.add(bare_conversation);
+ Conversation? full_conversation = get_conversation(show.jid.bare_jid, account);
+ if (full_conversation != null) ret.add(full_conversation);
+ return ret;
+ }
+
public Conversation? get_conversation(Jid jid, Account account) {
if (conversations.has_key(account)) {
return conversations[account][jid];
@@ -77,7 +97,7 @@ public class ConversationManager : StreamInteractionModule, Object {
}
private void on_account_added(Account account) {
- conversations[account] = new HashMap<Jid, Conversation>(Jid.hash_bare_func, Jid.equals_bare_func);
+ conversations[account] = new HashMap<Jid, Conversation>(Jid.hash_func, Jid.equals_func);
foreach (Conversation conversation in db.get_conversations(account)) {
add_conversation(conversation);
}
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala
index 4115bcfa..ad12cbac 100644
--- a/libdino/src/service/database.vala
+++ b/libdino/src/service/database.vala
@@ -79,6 +79,7 @@ public class Database : Qlite.Database {
public Column<int> id = new Column.Integer("id") { primary_key = true, auto_increment = true };
public Column<int> account_id = new Column.Integer("account_id") { not_null = true };
public Column<int> jid_id = new Column.Integer("jid_id") { not_null = true };
+ public Column<string> resource = new Column.Text("resource");
public Column<bool> active = new Column.BoolInt("active");
public Column<long> last_active = new Column.Long("last_active");
public Column<int> type_ = new Column.Integer("type");
@@ -87,7 +88,7 @@ public class Database : Qlite.Database {
internal ConversationTable(Database db) {
base(db, "conversation");
- init({id, account_id, jid_id, active, last_active, type_, encryption, read_up_to});
+ init({id, account_id, jid_id, resource, active, last_active, type_, encryption, read_up_to});
}
}
@@ -164,12 +165,18 @@ public class Database : Qlite.Database {
}
}
- public Gee.List<Message> get_messages(Jid jid, Account account, int count, Message? before) {
+ public Gee.List<Message> get_messages(Jid jid, Account account, Message.Type? type, int count, Message? before) {
QueryBuilder select = message.select()
.with(message.counterpart_id, "=", get_jid_id(jid))
.with(message.account_id, "=", account.id)
.order_by(message.id, "DESC")
.limit(count);
+ if (jid.resourcepart != null) {
+ select.with(message.counterpart_resource, "=", jid.resourcepart);
+ }
+ if (type != null) {
+ select.with(message.type_, "=", (int) type);
+ }
if (before != null) {
select.with(message.time, "<", (long) before.time.to_unix());
}
diff --git a/libdino/src/service/message_manager.vala b/libdino/src/service/message_manager.vala
index 314a466b..73f49237 100644
--- a/libdino/src/service/message_manager.vala
+++ b/libdino/src/service/message_manager.vala
@@ -43,11 +43,11 @@ public class MessageManager : StreamInteractionModule, Object {
public Gee.List<Entities.Message>? get_messages(Conversation conversation, int count = 50) {
if (messages.has_key(conversation) && messages[conversation].size > 0) {
- Gee.List<Entities.Message> db_messages = db.get_messages(conversation.counterpart, conversation.account, count, messages[conversation][0]);
+ Gee.List<Entities.Message> db_messages = db.get_messages(conversation.counterpart, conversation.account, get_message_type_for_conversation(conversation), count, messages[conversation][0]);
db_messages.add_all(messages[conversation]);
return db_messages;
} else {
- Gee.List<Entities.Message> db_messages = db.get_messages(conversation.counterpart, conversation.account, count, null);
+ Gee.List<Entities.Message> db_messages = db.get_messages(conversation.counterpart, conversation.account, get_message_type_for_conversation(conversation), count, null);
return db_messages;
}
}
@@ -56,7 +56,7 @@ public class MessageManager : StreamInteractionModule, Object {
if (messages.has_key(conversation) && messages[conversation].size > 0) {
return messages[conversation][messages[conversation].size - 1];
} else {
- Gee.List<Entities.Message> db_messages = db.get_messages(conversation.counterpart, conversation.account, 1, null);
+ Gee.List<Entities.Message> db_messages = db.get_messages(conversation.counterpart, conversation.account, get_message_type_for_conversation(conversation), 1, null);
if (db_messages.size >= 1) {
return db_messages[0];
}
@@ -65,10 +65,22 @@ public class MessageManager : StreamInteractionModule, Object {
}
public Gee.List<Entities.Message>? get_messages_before(Conversation? conversation, Entities.Message before) {
- Gee.List<Entities.Message> db_messages = db.get_messages(conversation.counterpart, conversation.account, 20, before);
+ Gee.List<Entities.Message> db_messages = db.get_messages(conversation.counterpart, conversation.account, get_message_type_for_conversation(conversation), 20, before);
return db_messages;
}
+ private Entities.Message.Type get_message_type_for_conversation(Conversation conversation) {
+ switch (conversation.type_) {
+ case Conversation.Type.CHAT:
+ return Entities.Message.Type.CHAT;
+ case Conversation.Type.GROUPCHAT:
+ return Entities.Message.Type.GROUPCHAT;
+ case Conversation.Type.GROUPCHAT_PM:
+ return Entities.Message.Type.GROUPCHAT_PM;
+ }
+ assert_not_reached();
+ }
+
private void on_account_added(Account account) {
stream_interactor.module_manager.get_module(account, Xmpp.Message.Module.IDENTITY).received_message.connect( (stream, message) => {
on_message_received(account, message);
@@ -88,8 +100,15 @@ public class MessageManager : StreamInteractionModule, Object {
private void on_message_received(Account account, Xmpp.Message.Stanza message) {
if (message.body == null) return;
- Entities.Message.Type type_ = message.type_ == Xmpp.Message.Stanza.TYPE_GROUPCHAT ? Entities.Message.Type.GROUPCHAT : Entities.Message.Type.CHAT;
- Entities.Message new_message = new Entities.Message(message.body, type_);
+ Entities.Message new_message = create_in_message(account, message);
+
+ determine_message_type(account, message, new_message);
+ Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation_for_message(new_message);
+ if (conversation != null) process_message(new_message, message);
+ }
+
+ private Entities.Message create_in_message(Account account, Xmpp.Message.Stanza message) {
+ Entities.Message new_message = new Entities.Message(message.body);
new_message.account = account;
new_message.stanza_id = message.id;
Jid from_jid = new Jid(message.from);
@@ -105,18 +124,59 @@ public class MessageManager : StreamInteractionModule, Object {
Xep.DelayedDelivery.MessageFlag? deleyed_delivery_flag = Xep.DelayedDelivery.MessageFlag.get_flag(message);
new_message.time = deleyed_delivery_flag != null ? deleyed_delivery_flag.datetime : new DateTime.now_local();
new_message.local_time = new DateTime.now_local();
- Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(new_message.counterpart, account, Conversation.Type.CHAT);
- pre_message_received(new_message, message, conversation);
-
- bool is_uuid = new_message.stanza_id != null && Regex.match_simple("""[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}""", new_message.stanza_id);
- if ((is_uuid && !db.contains_message_by_stanza_id(new_message.stanza_id, conversation.account)) ||
- (!is_uuid && !db.contains_message(new_message, conversation.account))) {
- new_message.persist(db);
- add_message(new_message, conversation);
- if (new_message.direction == Entities.Message.DIRECTION_SENT) {
- message_sent(new_message, conversation);
+ return new_message;
+ }
+
+ private void process_message(Entities.Message new_message, Xmpp.Message.Stanza stanza) {
+ Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation_for_message(new_message);
+ if (conversation != null) {
+ pre_message_received(new_message, stanza, conversation);
+
+ bool is_uuid = new_message.stanza_id != null && Regex.match_simple("""[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}""", new_message.stanza_id);
+ if ((is_uuid && !db.contains_message_by_stanza_id(new_message.stanza_id, conversation.account)) ||
+ (!is_uuid && !db.contains_message(new_message, conversation.account))) {
+ new_message.persist(db);
+ add_message(new_message, conversation);
+ if (new_message.direction == Entities.Message.DIRECTION_SENT) {
+ message_sent(new_message, conversation);
+ } else {
+ message_received(new_message, conversation);
+ }
+ }
+ }
+ }
+
+ private void determine_message_type(Account account, Xmpp.Message.Stanza message_stanza, Entities.Message message) {
+ if (message_stanza.type_ == Xmpp.Message.Stanza.TYPE_GROUPCHAT) {
+ message.type_ = Entities.Message.Type.GROUPCHAT;
+ process_message(message, message_stanza);
+ } else if (message_stanza.type_ == Xmpp.Message.Stanza.TYPE_CHAT) {
+ Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(message.counterpart.bare_jid, account);
+ if (conversation != null) {
+ if (conversation.type_ == Conversation.Type.CHAT) {
+ message.type_ = Entities.Message.Type.CHAT;
+ } else if (conversation.type_ == Conversation.Type.GROUPCHAT) {
+ message.type_ = Entities.Message.Type.GROUPCHAT_PM;
+ }
} else {
- message_received(new_message, conversation);
+ Core.XmppStream stream = stream_interactor.get_stream(account);
+ if (stream != null) stream.get_module(Xep.ServiceDiscovery.Module.IDENTITY).get_entity_categories(stream, message.counterpart.bare_jid.to_string(), (stream, identities, store) => {
+ Triple<MessageManager, Entities.Message, Xmpp.Message.Stanza> triple = store as Triple<MessageManager, Entities.Message, Xmpp.Message.Stanza>;
+ Entities.Message m = triple.b;
+ if (identities == null) {
+ m.type_ = Entities.Message.Type.CHAT;
+ triple.a.process_message(m, triple.c);
+ return;
+ }
+ foreach (Xep.ServiceDiscovery.Identity identity in identities) {
+ if (identity.category == Xep.ServiceDiscovery.Identity.CATEGORY_CONFERENCE) {
+ m.type_ = Entities.Message.Type.GROUPCHAT_PM;
+ } else {
+ m.type_ = Entities.Message.Type.CHAT;
+ }
+ triple.a.process_message(m, triple.c);
+ }
+ }, Triple.create(this, message, message_stanza));
}
}
}
@@ -129,8 +189,8 @@ public class MessageManager : StreamInteractionModule, Object {
}
private Entities.Message create_out_message(string text, Conversation conversation) {
- Entities.Message.Type type_ = conversation.type_ == Conversation.Type.GROUPCHAT ? Entities.Message.Type.GROUPCHAT : Entities.Message.Type.CHAT;
- Entities.Message message = new Entities.Message(text, type_);
+ Entities.Message message = new Entities.Message(text);
+ message.type_ = get_message_type_for_conversation(conversation);
message.stanza_id = random_uuid();
message.account = conversation.account;
message.body = text;
diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt
index dced6ae6..f0a8953c 100644
--- a/main/CMakeLists.txt
+++ b/main/CMakeLists.txt
@@ -74,6 +74,7 @@ SOURCES
src/ui/conversation_list_titlebar.vala
src/ui/conversation_selector/chat_row.vala
src/ui/conversation_selector/conversation_row.vala
+ src/ui/conversation_selector/groupchat_pm_row.vala
src/ui/conversation_selector/groupchat_row.vala
src/ui/conversation_selector/list.vala
src/ui/conversation_selector/view.vala
diff --git a/main/src/ui/conversation_selector/chat_row.vala b/main/src/ui/conversation_selector/chat_row.vala
index 5e3270aa..83ad3a11 100644
--- a/main/src/ui/conversation_selector/chat_row.vala
+++ b/main/src/ui/conversation_selector/chat_row.vala
@@ -57,27 +57,7 @@ public class ChatRow : ConversationRow {
ArrayList<Jid>? full_jids = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(conversation.counterpart, conversation.account);
if (full_jids != null) {
for (int i = 0; i < full_jids.size; i++) {
- Box box = new Box(Orientation.HORIZONTAL, 5);
-
- Show show = stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jids[i], conversation.account);
- Image image = new Image();
- if (show.as == Show.AWAY) {
- image.set_from_icon_name("dino-status-away", IconSize.SMALL_TOOLBAR);
- } else if (show.as == Show.XA || show.as == Show.DND) {
- image.set_from_icon_name("dino-status-dnd", IconSize.SMALL_TOOLBAR);
- } else if (show.as == Show.CHAT) {
- image.set_from_icon_name("dino-status-chat", IconSize.SMALL_TOOLBAR);
- } else {
- image.set_from_icon_name("dino-status-online", IconSize.SMALL_TOOLBAR);
- }
- box.add(image);
-
- Label resource = new Label(full_jids[i].resourcepart);
- resource.xalign = 0;
- box.add(resource);
- box.show_all();
-
- inner_box.add(box);
+ inner_box.add(get_fulljid_box(full_jids[i]));
}
}
return main_box;
diff --git a/main/src/ui/conversation_selector/conversation_row.vala b/main/src/ui/conversation_selector/conversation_row.vala
index 6930db67..ce8845f2 100644
--- a/main/src/ui/conversation_selector/conversation_row.vala
+++ b/main/src/ui/conversation_selector/conversation_row.vala
@@ -120,6 +120,29 @@ public abstract class ConversationRow : ListBoxRow {
message_label.label = message_label.label;
}
+ protected Box get_fulljid_box(Jid full_jid) {
+ Box box = new Box(Orientation.HORIZONTAL, 5) { visible=true };
+
+ Show show = stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jid, conversation.account);
+ Image image = new Image() { visible=true };
+ if (show.as == Show.AWAY) {
+ image.set_from_icon_name("dino-status-away", IconSize.SMALL_TOOLBAR);
+ } else if (show.as == Show.XA || show.as == Show.DND) {
+ image.set_from_icon_name("dino-status-dnd", IconSize.SMALL_TOOLBAR);
+ } else if (show.as == Show.CHAT) {
+ image.set_from_icon_name("dino-status-chat", IconSize.SMALL_TOOLBAR);
+ } else {
+ image.set_from_icon_name("dino-status-online", IconSize.SMALL_TOOLBAR);
+ }
+ box.add(image);
+
+ Label resource = new Label(full_jid.resourcepart) { visible=true };
+ resource.xalign = 0;
+ box.add(resource);
+ box.show_all();
+ return box;
+ }
+
private void on_x_button_clicked() {
main_revealer.set_transition_type(RevealerTransitionType.SLIDE_UP);
main_revealer.set_reveal_child(false);
diff --git a/main/src/ui/conversation_selector/groupchat_pm_row.vala b/main/src/ui/conversation_selector/groupchat_pm_row.vala
new file mode 100644
index 00000000..f556b45d
--- /dev/null
+++ b/main/src/ui/conversation_selector/groupchat_pm_row.vala
@@ -0,0 +1,54 @@
+using Gdk;
+using Gee;
+using Gtk;
+
+using Xmpp;
+using Dino.Entities;
+
+namespace Dino.Ui.ConversationSelector {
+
+public class GroupchatPmRow : ConversationRow {
+
+ public GroupchatPmRow(StreamInteractor stream_interactor, Conversation conversation) {
+ base(stream_interactor, conversation);
+ has_tooltip = true;
+ query_tooltip.connect ((x, y, keyboard_tooltip, tooltip) => {
+ tooltip.set_custom(generate_tooltip());
+ return true;
+ });
+ update_avatar();
+ }
+
+ public override void on_show_received(Show show) {
+ update_avatar();
+ }
+
+ public override void network_connection(bool connected) {
+ if (!connected) {
+ set_avatar((new AvatarGenerator(AVATAR_SIZE, AVATAR_SIZE, image.scale_factor)).set_greyscale(true).draw_conversation(stream_interactor, conversation), image.scale_factor);
+ } else {
+ update_avatar();
+ }
+ }
+
+ public void update_avatar() {
+ ArrayList<Jid> full_jids = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(conversation.counterpart, conversation.account);
+ set_avatar((new AvatarGenerator(AVATAR_SIZE, AVATAR_SIZE, image.scale_factor))
+ .set_greyscale(full_jids == null)
+ .draw_conversation(stream_interactor, conversation), image.scale_factor);
+ }
+
+ private Widget generate_tooltip() {
+ Builder builder = new Builder.from_resource("/org/dino-im/conversation_selector/chat_row_tooltip.ui");
+ Box main_box = builder.get_object("main_box") as Box;
+ Box inner_box = builder.get_object("inner_box") as Box;
+ Label jid_label = builder.get_object("jid_label") as Label;
+ jid_label.label = conversation.counterpart.to_string();
+ if (stream_interactor.get_module(MucManager.IDENTITY).get_nick(conversation.counterpart, conversation.account) != null) {
+ inner_box.add(get_fulljid_box(conversation.counterpart));
+ }
+ return main_box;
+ }
+}
+
+} \ No newline at end of file
diff --git a/main/src/ui/conversation_selector/list.vala b/main/src/ui/conversation_selector/list.vala
index dee70e4b..f580c4c5 100644
--- a/main/src/ui/conversation_selector/list.vala
+++ b/main/src/ui/conversation_selector/list.vala
@@ -39,8 +39,9 @@ public class List : ListBox {
});
stream_interactor.get_module(PresenceManager.IDENTITY).show_received.connect((show, jid, account) => {
Idle.add(() => {
- Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jid, account);
- if (conversation != null && rows.has_key(conversation)) rows[conversation].on_show_received(show);
+ foreach (Conversation conversation in stream_interactor.get_module(ConversationManager.IDENTITY).get_conversations_for_presence(show, account)) {
+ if (rows.has_key(conversation)) rows[conversation].on_show_received(show);
+ }
return false;
});
});
@@ -123,6 +124,8 @@ public class List : ListBox {
if (!rows.has_key(conversation)) {
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
row = new GroupchatRow(stream_interactor, conversation);
+ } else if (conversation.type_ == Conversation.Type.GROUPCHAT_PM){
+ row = new GroupchatPmRow(stream_interactor, conversation);
} else {
row = new ChatRow(stream_interactor, conversation);
}
@@ -186,6 +189,8 @@ public class List : ListBox {
if (cr1 != null && cr2 != null) {
Conversation c1 = cr1.conversation;
Conversation c2 = cr2.conversation;
+ if (c1.last_active == null) return -1;
+ if (c2.last_active == null) return 1;
int comp = c2.last_active.compare(c1.last_active);
if (comp == 0) {
return Util.get_conversation_display_name(stream_interactor, c1)
diff --git a/main/src/ui/conversation_summary/view.vala b/main/src/ui/conversation_summary/view.vala
index 0e06a80a..d264de32 100644
--- a/main/src/ui/conversation_summary/view.vala
+++ b/main/src/ui/conversation_summary/view.vala
@@ -151,6 +151,8 @@ public class View : Box {
}
private void load_earlier_messages() {
+ if (earliest_message == null) return;
+
was_value = scrolled.vadjustment.value;
lock(reloading_lock) {
if(reloading) return;
diff --git a/main/src/ui/util.vala b/main/src/ui/util.vala
index 810ab13d..993a996f 100644
--- a/main/src/ui/util.vala
+++ b/main/src/ui/util.vala
@@ -40,6 +40,9 @@ public class Util : Object {
}
public static string get_conversation_display_name(StreamInteractor stream_interactor, Conversation conversation) {
+ if (conversation.type_ == Conversation.Type.GROUPCHAT_PM) {
+ return conversation.counterpart.resourcepart + " from " + get_display_name(stream_interactor, conversation.counterpart.bare_jid, conversation.account);
+ }
return get_display_name(stream_interactor, conversation.counterpart, conversation.account);
}
diff --git a/xmpp-vala/CMakeLists.txt b/xmpp-vala/CMakeLists.txt
index 32162f0c..3294b472 100644
--- a/xmpp-vala/CMakeLists.txt
+++ b/xmpp-vala/CMakeLists.txt
@@ -34,7 +34,9 @@ SOURCES
"src/module/util.vala"
"src/module/xep/0030_service_discovery/flag.vala"
+ "src/module/xep/0030_service_discovery/identity.vala"
"src/module/xep/0030_service_discovery/info_result.vala"
+ "src/module/xep/0030_service_discovery/item.vala"
"src/module/xep/0030_service_discovery/items_result.vala"
"src/module/xep/0030_service_discovery/module.vala"
"src/module/xep/0045_muc/flag.vala"
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala b/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
index 0f82f498..7c49fc30 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/flag.vala
@@ -7,15 +7,34 @@ namespace Xmpp.Xep.ServiceDiscovery {
public class Flag : XmppStreamFlag {
public static FlagIdentity<Flag> IDENTITY = new FlagIdentity<Flag>(NS_URI, "service_discovery");
- private HashMap<string, ArrayList<string>> entity_features = new HashMap<string, ArrayList<string>>();
+ private HashMap<string, ArrayList<string>?> entity_features = new HashMap<string, ArrayList<string>?>();
+ private HashMap<string, ArrayList<Identity>?> entity_identities = new HashMap<string, ArrayList<Identity>?>();
public ArrayList<string> features = new ArrayList<string>();
+ public ArrayList<Identity>? get_entity_categories(string jid) {
+ return entity_identities.has_key(jid) ? entity_identities[jid] : null; // TODO isnt this default for hashmap
+ }
+
+ public bool? has_entity_identity(string jid, string category, string type) {
+ if (!entity_identities.has_key(jid)) return null;
+ if (entity_identities[jid] == null) return false;
+ foreach (Identity identity in entity_identities[jid]) {
+ if (identity.category == category && identity.type_ == type) return true;
+ }
+ return false;
+ }
+
public bool? has_entity_feature(string jid, string feature) {
if (!entity_features.has_key(jid)) return null;
+ if (entity_features[jid] == null) return false;
return entity_features[jid].contains(feature);
}
- public void set_entitiy_features(string jid, ArrayList<string> features) {
+ public void set_entity_identities(string jid, ArrayList<Identity>? identities) {
+ entity_identities[jid] = identities;
+ }
+
+ public void set_entity_features(string jid, ArrayList<string>? features) {
entity_features[jid] = features;
}
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/identity.vala b/xmpp-vala/src/module/xep/0030_service_discovery/identity.vala
new file mode 100644
index 00000000..e29eb111
--- /dev/null
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/identity.vala
@@ -0,0 +1,18 @@
+namespace Xmpp.Xep.ServiceDiscovery {
+
+public class Identity {
+ public const string CATEGORY_CLIENT = "client";
+ public const string CATEGORY_CONFERENCE = "conference";
+
+ public string category { get; set; }
+ public string type_ { get; set; }
+ public string? name { get; set; }
+
+ public Identity(string category, string type, string? name = null) {
+ this.category = category;
+ this.type_ = type;
+ this.name = name;
+ }
+}
+
+} \ No newline at end of file
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala b/xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala
index 7e0f0ea4..ae6b9caf 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/info_result.vala
@@ -39,30 +39,16 @@ public class InfoResult {
}
}
- public void add_feature(string feature) {
- iq.stanza.get_subnode("query", NS_URI_INFO).put_node(new StanzaNode.build("feature", NS_URI_INFO).put_attribute("var", feature));
- }
-
- public void add_identity(Identity identity) {
- StanzaNode identity_node = new StanzaNode.build("identity", NS_URI_INFO)
- .put_attribute("category", identity.category)
- .put_attribute("type", identity.type_);
- if (identity.name != null) {
- identity_node.put_attribute("name", identity.name);
- }
- iq.stanza.get_subnode("query", NS_URI_INFO).put_node(identity_node);
- }
-
- private InfoResult.from_iq(Iq.Stanza iq) {
- this.iq = iq;
- }
-
public InfoResult(Iq.Stanza iq_request) {
iq = new Iq.Stanza.result(iq_request);
iq.to = iq_request.from;
iq.stanza.put_node(new StanzaNode.build("query", NS_URI_INFO).add_self_xmlns());
}
+ private InfoResult.from_iq(Iq.Stanza iq) {
+ this.iq = iq;
+ }
+
public static InfoResult? create_from_iq(Iq.Stanza iq) {
if (iq.is_error()) return null;
StanzaNode query_node = iq.stanza.get_subnode("query", NS_URI_INFO);
@@ -73,6 +59,20 @@ public class InfoResult {
if (identity_node == null) return null;
return new ServiceDiscovery.InfoResult.from_iq(iq);
}
+
+ public void add_feature(string feature) {
+ iq.stanza.get_subnode("query", NS_URI_INFO).put_node(new StanzaNode.build("feature", NS_URI_INFO).put_attribute("var", feature));
+ }
+
+ public void add_identity(Identity identity) {
+ StanzaNode identity_node = new StanzaNode.build("identity", NS_URI_INFO)
+ .put_attribute("category", identity.category)
+ .put_attribute("type", identity.type_);
+ if (identity.name != null) {
+ identity_node.put_attribute("name", identity.name);
+ }
+ iq.stanza.get_subnode("query", NS_URI_INFO).put_node(identity_node);
+ }
}
} \ No newline at end of file
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/item.vala b/xmpp-vala/src/module/xep/0030_service_discovery/item.vala
new file mode 100644
index 00000000..9d8f1f3e
--- /dev/null
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/item.vala
@@ -0,0 +1,15 @@
+namespace Xmpp.Xep.ServiceDiscovery {
+
+public class Item {
+ public string jid;
+ public string? name;
+ public string? node;
+
+ public Item(string jid, string? name = null, string? node = null) {
+ this.jid = jid;
+ this.name = name;
+ this.node = node;
+ }
+}
+
+} \ No newline at end of file
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
index 4b51e230..2ec0f630 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
@@ -3,109 +3,94 @@ using Gee;
using Xmpp.Core;
namespace Xmpp.Xep.ServiceDiscovery {
- private const string NS_URI = "http://jabber.org/protocol/disco";
- public const string NS_URI_INFO = NS_URI + "#info";
- public const string NS_URI_ITEMS = NS_URI + "#items";
- public class Module : XmppStreamModule, Iq.Handler {
- public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0030_service_discovery_module");
+private const string NS_URI = "http://jabber.org/protocol/disco";
+public const string NS_URI_INFO = NS_URI + "#info";
+public const string NS_URI_ITEMS = NS_URI + "#items";
- public ArrayList<Identity> identities = new ArrayList<Identity>();
+public class Module : XmppStreamModule, Iq.Handler {
+ public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0030_service_discovery_module");
- public Module.with_identity(string category, string type, string? name = null) {
- add_identity(category, type, name);
- }
-
- public void add_feature(XmppStream stream, string feature) {
- stream.get_flag(Flag.IDENTITY).add_own_feature(feature);
- }
-
- public void add_feature_notify(XmppStream stream, string feature) {
- add_feature(stream, feature + "+notify");
- }
-
- public void add_identity(string category, string type, string? name = null) {
- identities.add(new Identity(category, type, name));
- }
-
- [CCode (has_target = false)] public delegate void OnInfoResult(XmppStream stream, InfoResult query_result, Object? store);
- public void request_info(XmppStream stream, string jid, OnInfoResult listener, Object? store) {
- Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_INFO).add_self_xmlns());
- iq.to = jid;
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_request_info_response, Tuple.create(listener, store));
- }
-
- [CCode (has_target = false)] public delegate void OnItemsResult(XmppStream stream, ItemsResult query_result);
- public void request_items(XmppStream stream, string jid, OnItemsResult listener, Object? store) {
- Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_ITEMS).add_self_xmlns());
- iq.to = jid;
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
- }
-
- public void on_iq_get(XmppStream stream, Iq.Stanza iq) {
- StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI_INFO);
- if (query_node != null) {
- send_query_result(stream, iq);
- }
- }
+ public ArrayList<Identity> identities = new ArrayList<Identity>();
- public void on_iq_set(XmppStream stream, Iq.Stanza iq) { }
+ public Module.with_identity(string category, string type, string? name = null) {
+ add_identity(category, type, name);
+ }
- public override void attach(XmppStream stream) {
- Iq.Module.require(stream);
- stream.get_module(Iq.Module.IDENTITY).register_for_namespace(NS_URI_INFO, this);
- stream.add_flag(new Flag());
- add_feature(stream, NS_URI_INFO);
- }
+ public void add_feature(XmppStream stream, string feature) {
+ stream.get_flag(Flag.IDENTITY).add_own_feature(feature);
+ }
- public override void detach(XmppStream stream) { }
+ public void add_feature_notify(XmppStream stream, string feature) {
+ add_feature(stream, feature + "+notify");
+ }
- public static void require(XmppStream stream) {
- if (stream.get_module(IDENTITY) == null) stream.add_module(new ServiceDiscovery.Module());
- }
+ public void add_identity(string category, string type, string? name = null) {
+ identities.add(new Identity(category, type, name));
+ }
- public override string get_ns() { return NS_URI; }
- public override string get_id() { return IDENTITY.id; }
+ [CCode (has_target = false)] public delegate void HasEntryCategoryRes(XmppStream stream, ArrayList<Identity>? identities, Object? store);
+ public void get_entity_categories(XmppStream stream, string jid, HasEntryCategoryRes on_result, Object? store) {
+ ArrayList<Identity>? res = stream.get_flag(Flag.IDENTITY).get_entity_categories(jid);
+ if (res != null) on_result(stream, res, store);
+ request_info(stream, jid, (stream, query_result, store) => {
+ Tuple<HasEntryCategoryRes, Object> tuple = store as Tuple<HasEntryCategoryRes, Object>;
+ tuple.a(stream, query_result != null ? query_result.identities : null, tuple.b);
+ }, Tuple.create(on_result, store));
+ }
- private static void on_request_info_response(XmppStream stream, Iq.Stanza iq, Object o) {
+ [CCode (has_target = false)] public delegate void OnInfoResult(XmppStream stream, InfoResult? query_result, Object? store);
+ public void request_info(XmppStream stream, string jid, OnInfoResult listener, Object? store) {
+ Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_INFO).add_self_xmlns());
+ iq.to = jid;
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq, o) => {
Tuple<OnInfoResult, Object> tuple = o as Tuple<OnInfoResult, Object>;
OnInfoResult on_result = tuple.a;
InfoResult? result = InfoResult.create_from_iq(iq);
- if (result != null) {
- stream.get_flag(Flag.IDENTITY).set_entitiy_features(iq.from, result.features);
- on_result(stream, result, tuple.b);
- }
- }
+ stream.get_flag(Flag.IDENTITY).set_entity_features(iq.from, result != null ? result.features : null);
+ stream.get_flag(Flag.IDENTITY).set_entity_identities(iq.from, result != null ? result.identities : null);
+ on_result(stream, result, tuple.b);
+ }, Tuple.create(listener, store));
+ }
+
+ [CCode (has_target = false)] public delegate void OnItemsResult(XmppStream stream, ItemsResult query_result);
+ public void request_items(XmppStream stream, string jid, OnItemsResult listener, Object? store) {
+ Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_ITEMS).add_self_xmlns());
+ iq.to = jid;
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
+ }
- private void send_query_result(XmppStream stream, Iq.Stanza iq_request) {
- InfoResult query_result = new ServiceDiscovery.InfoResult(iq_request);
- query_result.features = stream.get_flag(Flag.IDENTITY).features;
- query_result.identities = identities;
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, query_result.iq);
+ public void on_iq_get(XmppStream stream, Iq.Stanza iq) {
+ StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI_INFO);
+ if (query_node != null) {
+ send_query_result(stream, iq);
}
}
- public class Identity {
- public string category { get; set; }
- public string type_ { get; set; }
- public string? name { get; set; }
+ public void on_iq_set(XmppStream stream, Iq.Stanza iq) { }
- public Identity(string category, string type, string? name = null) {
- this.category = category;
- this.type_ = type;
- this.name = name;
- }
+ public override void attach(XmppStream stream) {
+ Iq.Module.require(stream);
+ stream.get_module(Iq.Module.IDENTITY).register_for_namespace(NS_URI_INFO, this);
+ stream.add_flag(new Flag());
+ add_feature(stream, NS_URI_INFO);
}
- public class Item {
- public string jid;
- public string? name;
- public string? node;
+ public override void detach(XmppStream stream) { }
- public Item(string jid, string? name = null, string? node = null) {
- this.jid = jid;
- this.name = name;
- this.node = node;
- }
+ public static void require(XmppStream stream) {
+ if (stream.get_module(IDENTITY) == null) stream.add_module(new ServiceDiscovery.Module());
}
+
+ public override string get_ns() { return NS_URI; }
+ public override string get_id() { return IDENTITY.id; }
+
+ private void send_query_result(XmppStream stream, Iq.Stanza iq_request) {
+ InfoResult query_result = new ServiceDiscovery.InfoResult(iq_request);
+ query_result.features = stream.get_flag(Flag.IDENTITY).features;
+ query_result.identities = identities;
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, query_result.iq);
+ }
+}
+
}
diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala
index 624d8421..486c342a 100644
--- a/xmpp-vala/src/module/xep/0045_muc/module.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/module.vala
@@ -129,7 +129,7 @@ public class Module : XmppStreamModule {
string bare_jid = get_bare_jid(presence.from);
ErrorStanza? error_stanza = presence.get_error();
if (flag.get_enter_id(bare_jid) == error_stanza.original_id) {
- ListenerHolder listener = flag.get_enter_listener(bare_jid);
+ ListenerHolder? listener = flag.get_enter_listener(bare_jid);
MucEnterError? error = null;
if (error_stanza.condition == ErrorStanza.CONDITION_NOT_AUTHORIZED && ErrorStanza.TYPE_AUTH == error_stanza.type_) {
error = MucEnterError.PASSWORD_REQUIRED;
@@ -144,7 +144,7 @@ public class Module : XmppStreamModule {
} else if (ErrorStanza.CONDITION_ITEM_NOT_FOUND == error_stanza.condition && ErrorStanza.TYPE_CANCEL == error_stanza.type_) {
error = MucEnterError.ROOM_DOESNT_EXIST;
}
- if (error == null) listener.on_error(stream, error, listener.reference);
+ if (error != null && listener != null) listener.on_error(stream, error, listener.reference);
flag.finish_muc_enter(bare_jid);
}
}
diff --git a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
index e1d6e6ff..a3f0a704 100644
--- a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
+++ b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
@@ -59,12 +59,13 @@ namespace Xmpp.Xep.EntityCapabilities {
if (capabilities.size == 0) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, presence.from, on_received_info_response, Tuple.create(storage, ver_attribute));
} else {
- stream.get_flag(ServiceDiscovery.Flag.IDENTITY).set_entitiy_features(presence.from, capabilities);
+ stream.get_flag(ServiceDiscovery.Flag.IDENTITY).set_entity_features(presence.from, capabilities);
}
}
}
- private static void on_received_info_response(XmppStream stream, ServiceDiscovery.InfoResult query_result, Object? store) {
+ private static void on_received_info_response(XmppStream stream, ServiceDiscovery.InfoResult? query_result, Object? store) {
+ if (query_result == null) return;
Tuple<Storage, string> tuple = store as Tuple<Storage, string>;
Storage storage = tuple.a;
string entity = tuple.b;