Skip to content

Commit

Permalink
Get name at startup from tox session
Browse files Browse the repository at this point in the history
  • Loading branch information
naxuroqa committed Feb 20, 2018
1 parent cb3d527 commit 5de4a0a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/tox/ToxSession.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ namespace Venom {
public abstract void self_set_status_message(string status);
public abstract void self_set_typing(uint32 friend_number, bool typing) throws ToxError;

public abstract string self_get_name();
public abstract string self_get_status_message();

public abstract uint8[] self_get_address();

public abstract void self_get_friend_list_foreach(GetFriendListCallback callback) throws ToxError;
Expand Down Expand Up @@ -311,6 +314,14 @@ namespace Venom {
return UserStatus.ONLINE;
}

public virtual string self_get_name() {
return handle.self_get_name();
}

public virtual string self_get_status_message() {
return handle.self_get_status_message();
}

public virtual void self_get_friend_list_foreach(GetFriendListCallback callback) throws ToxError {
var friend_numbers = handle.self_get_friend_list();
for (var i = 0; i < friend_numbers.length; i++) {
Expand Down
12 changes: 7 additions & 5 deletions src/tox/ToxSessionListener.vala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace Venom {
session.set_session_listener(this);

user_info.set_tox_id(Tools.bin_to_hexstring(session.self_get_address()));
set_user_info();
get_user_info();
user_info.info_changed(this);

try {
Expand All @@ -71,9 +71,9 @@ namespace Venom {
}
}

private void set_user_info() {
session.self_set_user_name(user_info.get_name());
session.self_set_status_message(user_info.get_status_message());
private void get_user_info() {
user_info.set_name(session.self_get_name());
user_info.set_status_message(session.self_get_status_message());
}

private void on_user_info_changed(GLib.Object sender) {
Expand All @@ -82,7 +82,8 @@ namespace Venom {
}

logger.d("ToxSessionListenerImpl on_user_info_changed.");
set_user_info();
session.self_set_user_name(user_info.get_name());
session.self_set_status_message(user_info.get_status_message());
}

public virtual void on_remove_friend(IContact c) throws Error {
Expand Down Expand Up @@ -273,6 +274,7 @@ namespace Venom {
var contact = conferences.@get(conference_number) as GroupchatContact;
var conversation = conversations.@get(contact);
var msg = new GroupMessage.incoming(contact, peer_number, message);
notification_listener.on_unread_message(msg);
conversation.add_message(this, msg);
}

Expand Down
3 changes: 1 addition & 2 deletions src/ui/conference_window.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2 -->
<!-- Generated with glade 3.21.0 -->
<interface domain="venom">
<requires lib="gtk+" version="3.20"/>
<template class="VenomConferenceWindow" parent="GtkBox">
Expand Down Expand Up @@ -93,7 +93,6 @@
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="action_name">win.show-peers</property>
<property name="relief">none</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
Expand Down
48 changes: 45 additions & 3 deletions src/ui/user_info_widget.ui
Original file line number Diff line number Diff line change
@@ -1,7 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2 -->
<!-- Generated with glade 3.21.0 -->
<interface domain="venom">
<requires lib="gtk+" version="3.20"/>
<object class="GtkSizeGroup"/>
<object class="GtkFileFilter" id="imagefilter">
<mime-types>
<mime-type>image/*</mime-type>
</mime-types>
</object>
<object class="GtkFileChooserDialog" id="imagechooser">
<property name="can_focus">False</property>
<property name="type_hint">dialog</property>
<property name="filter">imagefilter</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child>
<placeholder/>
</child>
</object>
<template class="VenomUserInfoWidget" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
Expand Down Expand Up @@ -200,8 +241,10 @@
<child>
<object class="GtkFileChooserButton" id="filechooser">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes"/>
<property name="dialog">imagechooser</property>
<property name="title" translatable="yes">Choose an avatar</property>
</object>
<packing>
<property name="expand">False</property>
Expand Down Expand Up @@ -441,5 +484,4 @@
</packing>
</child>
</template>
<object class="GtkSizeGroup"/>
</interface>

0 comments on commit 5de4a0a

Please sign in to comment.