Skip to content

Commit

Permalink
Finish toxav vapi, move toxcore errors out of class, remove unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
naxuroqa committed Feb 13, 2018
1 parent 8be8c17 commit ce07db3
Show file tree
Hide file tree
Showing 27 changed files with 689 additions and 1,262 deletions.
2 changes: 1 addition & 1 deletion data/venom.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Version=1.0
Type=Application
Name=Venom
Comment=A GTK+/Vala GUI for Tox
Comment=A modern user interface for Tox
TryExec=venom
Exec=venom %u
Icon=venom
Expand Down
35 changes: 0 additions & 35 deletions sounds/CMakeLists.txt

This file was deleted.

Binary file removed sounds/contact-logs-in.wav
Binary file not shown.
Binary file removed sounds/contact-logs-out.wav
Binary file not shown.
Binary file removed sounds/contact-request-accepted.wav
Binary file not shown.
Binary file removed sounds/error.wav
Binary file not shown.
Binary file removed sounds/incoming-call.wav
Binary file not shown.
Binary file removed sounds/incoming-video-call.wav
Binary file not shown.
1 change: 0 additions & 1 deletion sounds/license

This file was deleted.

Binary file removed sounds/log-in.wav
Binary file not shown.
Binary file removed sounds/log-out.wav
Binary file not shown.
Binary file removed sounds/new-message.wav
Binary file not shown.
Binary file removed sounds/outgoing-call.wav
Binary file not shown.
Binary file removed sounds/outgoing-video-call.wav
Binary file not shown.
Binary file removed sounds/transfer-complete.wav
Binary file not shown.
Binary file removed sounds/transfer-pending.wav
Binary file not shown.
2 changes: 2 additions & 0 deletions src/core/Contact.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

namespace Venom {
public interface IContact : Object {
public signal void changed();

public abstract string get_id();
public abstract string get_name_string();
public abstract string get_status_string();
Expand Down
3 changes: 2 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sqlite_dep = dependency('sqlite3')
json_dep = dependency('json-glib-1.0')
soup_dep = dependency('libsoup-2.4')
tox_dep = dependency('toxcore')
toxav_dep = dependency('toxav')

config_vapi = meson.get_compiler('vala').find_library('config', dirs: join_paths(meson.current_source_dir(), 'vapi'))
config_dep = declare_dependency(dependencies: [config_vapi], include_directories : include_directories('.'))
Expand Down Expand Up @@ -75,6 +76,6 @@ venom_icons_resources = gnome.compile_resources( 'venom_icons_resources', 'icons
root_source_dir = meson.current_source_dir()

venom_binary = executable('venom', [venom_source, venom_ui_resources, venom_icons_resources],
dependencies : [gtk_dep, gio_dep, gmodule_dep, sqlite_dep, json_dep, tox_dep, config_dep, soup_dep],
dependencies : [gtk_dep, gio_dep, gmodule_dep, sqlite_dep, json_dep, tox_dep, toxav_dep, config_dep, soup_dep],
install : true
)
68 changes: 35 additions & 33 deletions src/testing/GroupBot.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@
* along with Venom. If not, see <http://www.gnu.org/licenses/>.
*/

using ToxCore;

namespace Testing {
public class GroupBot : Object {
private const string DEFAULT_CHANNEL = "tox-ontopic";

private ToxCore.Tox tox;
private Tox tox;
private HashTable<string, uint32> channels;

public GroupBot() {
channels = new HashTable<string, uint32>(str_hash, str_equal);

var err = ToxCore.ErrNew.OK;
tox = new ToxCore.Tox(null, ref err);
if (err != ToxCore.ErrNew.OK) {
var err = ErrNew.OK;
tox = new Tox(null, ref err);
if (err != ErrNew.OK) {
stderr.printf("[FTL] Could not create new tox instance: %s\n", err.to_string());
assert_not_reached();
}
Expand All @@ -46,9 +48,9 @@ namespace Testing {
}

private uint32 add_channel(string name) {
var err = ToxCore.Tox.ErrConferenceNew.OK;
var err = ErrConferenceNew.OK;
var channel_number = tox.conference_new(ref err);
if (err != ToxCore.Tox.ErrConferenceNew.OK) {
if (err != ErrConferenceNew.OK) {
stderr.printf("[ERR] Creating new channel \"%s\" failed: %s\n", name, err.to_string());
} else {
stdout.printf("[LOG] Created new channel #%s [%u]\n", name, channel_number);
Expand All @@ -57,54 +59,54 @@ namespace Testing {
return channel_number;
}

private static string get_name(ToxCore.Tox tox, uint32 friend_number) {
var err = ToxCore.Tox.ErrFriendQuery.OK;
private static string get_name(Tox tox, uint32 friend_number) {
var err = ErrFriendQuery.OK;
var name = tox.friend_get_name(friend_number, ref err);
if (err != ToxCore.Tox.ErrFriendQuery.OK) {
if (err != ErrFriendQuery.OK) {
stderr.printf("[ERR]Could not query friend name: %s\n", err.to_string());
name = "FRIEND #%u".printf(friend_number);
}
return name;
}

private static void on_conference_message(ToxCore.Tox tox, uint32 conference_number, uint32 peer_number, ToxCore.MessageType type, uint8[] message, void* data) {
var err = ToxCore.Tox.ErrConferencePeerQuery.OK;
private static void on_conference_message(Tox tox, uint32 conference_number, uint32 peer_number, MessageType type, uint8[] message, void* data) {
var err = ErrConferencePeerQuery.OK;
var name = tox.conference_peer_get_name(conference_number, peer_number, ref err);
if (err != ToxCore.Tox.ErrConferencePeerQuery.OK) {
if (err != ErrConferencePeerQuery.OK) {
stderr.printf("[ERR] Could not get name for peer #%u: %s\n", peer_number, err.to_string());
name = "PEER #%u".printf(peer_number);
}
stdout.printf("[CM ] %s: %s\n", name, (string) message);
}

private static void on_conference_namelist_change(ToxCore.Tox tox, uint32 conference_number, uint32 peer_number, ToxCore.Tox.ConferenceStateChange change, void* data) {
if (change == ToxCore.Tox.ConferenceStateChange.PEER_JOIN || change == ToxCore.Tox.ConferenceStateChange.PEER_EXIT) {
private static void on_conference_namelist_change(Tox tox, uint32 conference_number, uint32 peer_number, ConferenceStateChange change, void* data) {
if (change == ConferenceStateChange.PEER_JOIN || change == ConferenceStateChange.PEER_EXIT) {
stdout.printf("[LOG] Peer #%u connected/disconnect, updating status message\n", peer_number);
}
}

private static void on_friend_request(ToxCore.Tox tox, uint8[] key, uint8[] message, void* data) {
var pub_key = new uint8[ToxCore.address_size()];
private static void on_friend_request(Tox tox, uint8[] key, uint8[] message, void* data) {
var pub_key = new uint8[address_size()];
Memory.copy(pub_key, key, pub_key.length);
stdout.printf("[LOG] Friend request from %s received.\n", Venom.Tools.bin_to_hexstring(pub_key));
var err = ToxCore.Tox.ErrFriendAdd.OK;
var err = ErrFriendAdd.OK;
tox.friend_add_norequest(pub_key, ref err);
if (err != ToxCore.Tox.ErrFriendAdd.OK) {
if (err != ErrFriendAdd.OK) {
stderr.printf("[ERR] Could not add friend: %s\n", err.to_string());
}
}

private static void on_friend_connection_status(ToxCore.Tox tox, uint32 friend_number, ToxCore.Tox.Connection connection_status, void* data) {
private static void on_friend_connection_status(Tox tox, uint32 friend_number, Connection connection_status, void* data) {
var name = get_name(tox, friend_number);
stdout.printf("[LOG] Connection status changed for friend #%u (%s): %s\n", friend_number, name, connection_status.to_string());
var err = ToxCore.Tox.ErrFriendSendMessage.OK;
tox.friend_send_message(friend_number, ToxCore.MessageType.NORMAL, "invite", ref err);
if (err != ToxCore.Tox.ErrFriendSendMessage.OK) {
var err = ErrFriendSendMessage.OK;
tox.friend_send_message(friend_number, MessageType.NORMAL, "invite", ref err);
if (err != ErrFriendSendMessage.OK) {
stderr.printf("[ERR] Could not send message to %u: %s", friend_number, err.to_string());
}
}

private static void on_friend_message(ToxCore.Tox tox, uint32 friend_number, ToxCore.MessageType type, uint8[] message, void* data) {
private static void on_friend_message(Tox tox, uint32 friend_number, MessageType type, uint8[] message, void* data) {
var name = get_name(tox, friend_number);
var message_str = (string) message;
stdout.printf("[LOG] Message from %s: %s\n", name, message_str);
Expand All @@ -115,11 +117,11 @@ namespace Testing {
stdout.printf("[LOG] Running Group Bot\n");
var pub_key = Venom.Tools.hexstring_to_bin(pub_key_string);

assert(pub_key.length == ToxCore.public_key_size());
assert(pub_key.length == public_key_size());
stdout.printf("[LOG] Bootstrap node: %s:%u.\n", ip_string, port);

stdout.printf("[LOG] Bootstrapping...\n");
var error_bootstrap = ToxCore.ErrBootstrap.OK;
var error_bootstrap = ErrBootstrap.OK;
if (!tox.bootstrap(ip_string, (uint16) port, pub_key, ref error_bootstrap)) {
stderr.printf("[ERR] Bootstrapping failed: %s\n", error_bootstrap.to_string());
return;
Expand All @@ -128,29 +130,29 @@ namespace Testing {
stdout.printf("[LOG] Bootstrapping done.\n");
stdout.printf("[LOG] Tox ID: %s\n", Venom.Tools.bin_to_hexstring(tox.self_get_address()));

var setNameError = ToxCore.ErrSetInfo.OK;
if (!tox.self_set_name("Group Bot", ref setNameError) || setNameError != ToxCore.ErrSetInfo.OK) {
var setNameError = ErrSetInfo.OK;
if (!tox.self_set_name("Group Bot", ref setNameError) || setNameError != ErrSetInfo.OK) {
stderr.printf("[ERR] Setting user name failed: %s\n", setNameError.to_string());
return;
}

stdout.printf("[LOG] Connecting...\n");
var connection_status = ToxCore.Tox.Connection.NONE;
var connection_status = Connection.NONE;
var running = true;
while (running) {
var new_connection_status = tox.self_get_connection_status();
if (new_connection_status != connection_status) {
switch (new_connection_status) {
case ToxCore.Tox.Connection.NONE:
case Connection.NONE:
stdout.printf("[LOG] Not Connected.\n");
break;
case ToxCore.Tox.Connection.UDP:
case ToxCore.Tox.Connection.TCP:
case Connection.UDP:
case Connection.TCP:
stdout.printf("[LOG] Connected.\n");
var groupbot_pub_key = Venom.Tools.hexstring_to_bin("56A1ADE4B65B86BCD51CC73E2CD4E542179F47959FE3E0E21B4B0ACDADE51855D34D34D37CB5");
var addFriendErr = ToxCore.Tox.ErrFriendAdd.OK;
var addFriendErr = ErrFriendAdd.OK;
tox.friend_add(groupbot_pub_key, "please add me", ref addFriendErr);
if (addFriendErr != ToxCore.Tox.ErrFriendAdd.OK) {
if (addFriendErr != ErrFriendAdd.OK) {
stderr.printf("[ERR] Could not add friend: %s\n", addFriendErr.to_string());
}
stdout.printf("[LOG] Friend request sent.\n");
Expand Down
88 changes: 45 additions & 43 deletions src/testing/TestToxCore.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* along with Venom. If not, see <http://www.gnu.org/licenses/>.
*/

using ToxCore;

namespace TestToxCore {

private static void testToxVersion() {
Expand All @@ -29,9 +31,9 @@ namespace TestToxCore {
}

private static void testToxOptions() {
var e = ToxCore.ErrOptionsNew.OK;
var options = new ToxCore.Options(ref e);
var default_options = new ToxCore.Options(ref e);
var e = ErrOptionsNew.OK;
var options = new Options(ref e);
var default_options = new Options(ref e);
default_options.default ();
assert(options != null);
assert(default_options != null);
Expand All @@ -47,98 +49,98 @@ namespace TestToxCore {
}

private static void testToxCoreSession() {
var e = ToxCore.ErrOptionsNew.OK;
var options = new ToxCore.Options(ref e);
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
assert(error == ToxCore.ErrNew.OK);
tox = new ToxCore.Tox(options, ref error);
assert(error == ToxCore.ErrNew.OK);
var e = ErrOptionsNew.OK;
var options = new Options(ref e);
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
assert(error == ErrNew.OK);
tox = new Tox(options, ref error);
assert(error == ErrNew.OK);
}

private static void testToxSaveData() {
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
var savedata = tox.get_savedata();
assert(savedata != null);
assert(savedata.length > 0);
}

private static void testToxUserStatus() {
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
var user_status = ToxCore.UserStatus.AWAY;
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
var user_status = UserStatus.AWAY;
tox.user_status = user_status;
assert(tox.user_status == user_status);
}

private static void testToxPersistentUserStatus() {
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
var user_status = ToxCore.UserStatus.BUSY;
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
var user_status = UserStatus.BUSY;
tox.user_status = user_status;
tox = new ToxCore.Tox(null, ref error);
tox = new Tox(null, ref error);
assert(tox.user_status != user_status);
}

private static void testToxStatusMessage() {
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
var message = "message";
var setStatusError = ToxCore.ErrSetInfo.OK;
var setStatusError = ErrSetInfo.OK;
assert(tox.self_set_status_message(message, ref setStatusError));
assert(tox.self_get_status_message() == message);
}

private static void testToxName() {
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
var name = "test";
var setNameError = ToxCore.ErrSetInfo.OK;
var setNameError = ErrSetInfo.OK;
assert(tox.self_set_name(name, ref setNameError));
assert(tox.self_get_name() == name);
}

private static void testToxConnection() {
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
assert(tox.self_get_connection_status() == ToxCore.Tox.Connection.NONE);
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
assert(tox.self_get_connection_status() == Connection.NONE);
}

private static void testToxPersistentAddress() {
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
var address = tox.self_get_address();
assert(equals(tox.self_get_address(), address));
tox = new ToxCore.Tox(null, ref error);
tox = new Tox(null, ref error);
assert(!equals(tox.self_get_address(), address));
}

private static void testToxBootstrapNull() {
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
var bootstrapError = ToxCore.ErrBootstrap.OK;
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
var bootstrapError = ErrBootstrap.OK;
string s = null;
assert(!tox.bootstrap(s, 0, {}, ref bootstrapError));
assert(bootstrapError == ToxCore.ErrBootstrap.NULL);
assert(bootstrapError == ErrBootstrap.NULL);
}

private static void testToxBootstrapBadPort() {
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
var bootstrapError = ToxCore.ErrBootstrap.OK;
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
var bootstrapError = ErrBootstrap.OK;
var pubkey = new uint8[ToxCore.public_key_size()];
assert(!tox.bootstrap("", 0, pubkey, ref bootstrapError));
assert(bootstrapError == ToxCore.ErrBootstrap.BAD_PORT);
assert(bootstrapError == ErrBootstrap.BAD_PORT);
}

private static void testToxBootstrapBadHost() {
var error = ToxCore.ErrNew.OK;
var tox = new ToxCore.Tox(null, ref error);
var bootstrapError = ToxCore.ErrBootstrap.OK;
var error = ErrNew.OK;
var tox = new Tox(null, ref error);
var bootstrapError = ErrBootstrap.OK;
var pubkey = new uint8[ToxCore.public_key_size()];
assert(!tox.bootstrap("", 1, pubkey, ref bootstrapError));
assert(bootstrapError == ToxCore.ErrBootstrap.BAD_HOST);
assert(bootstrapError == ErrBootstrap.BAD_HOST);
}

private static bool equals(uint8[] a, uint8[] b) {
Expand Down

0 comments on commit ce07db3

Please sign in to comment.