IT WORKS AND LOGS IN!!!!
This commit is contained in:
parent
86286c9afd
commit
fbb68deb7f
|
@ -12,5 +12,5 @@ pub fn main() !void {
|
|||
var client = initClient(allocator, &sock);
|
||||
try client.handshake();
|
||||
try client.quassel_init_packet();
|
||||
try client.quassel_login("z", "PASSWORD");
|
||||
try client.quassel_login("z", "password");
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ pub const QVariant = union(enum) {
|
|||
string: []const u8,
|
||||
stringlist: std.ArrayList([]const u8),
|
||||
qmap: std.StringHashMap(QVariant),
|
||||
qvarlist: std.ArrayList(QVariant),
|
||||
empty: bool,
|
||||
};
|
||||
|
||||
|
@ -18,6 +19,7 @@ pub const QVariantTypes = enum(u32) {
|
|||
int_1 = 2,
|
||||
int_2 = 3,
|
||||
qmap = 8,
|
||||
qvarlist = 9,
|
||||
string = 10,
|
||||
stringlist = 11,
|
||||
bytearray = 12,
|
||||
|
@ -35,6 +37,9 @@ pub fn qvariant_type_id(variant: QVariant) !u32 {
|
|||
.qmap => {
|
||||
return @enumToInt(QVariantTypes.qmap);
|
||||
},
|
||||
.qvarlist => {
|
||||
return @enumToInt(QVariantTypes.qvarlist);
|
||||
},
|
||||
.string => {
|
||||
return @enumToInt(QVariantTypes.string);
|
||||
},
|
||||
|
@ -81,6 +86,15 @@ pub fn pretty_print_variant(variant: QVariant, indentLevel: u64) void {
|
|||
pretty_print_variant(v.value, indentLevel + 2);
|
||||
}
|
||||
},
|
||||
.qvarlist => |l| {
|
||||
std.debug.print("QVarList:\n", .{});
|
||||
|
||||
for (l.items) |varient, i| {
|
||||
print_indent_level(indentLevel + 1);
|
||||
std.debug.print("Item #{d}\n", .{i});
|
||||
pretty_print_variant(varient, indentLevel + 2);
|
||||
}
|
||||
},
|
||||
.string => |s| {
|
||||
std.debug.print("String: \"{s}\"\n", .{s});
|
||||
},
|
||||
|
|
|
@ -56,6 +56,17 @@ pub fn get_string(reader: anytype, allocator: *std.mem.Allocator) ![]u8 {
|
|||
return ut8Str;
|
||||
}
|
||||
|
||||
pub fn get_qvarlist(reader: anytype, allocator: *std.mem.Allocator) !std.ArrayList(qvar.QVariant) {
|
||||
var varlist = std.ArrayList(qvar.QVariant).init(allocator);
|
||||
var size = try get_int(reader);
|
||||
var i: u32 = 0;
|
||||
while (i < size) {
|
||||
try varlist.append(try get_variant(reader, allocator));
|
||||
i = i + 1;
|
||||
}
|
||||
return varlist;
|
||||
}
|
||||
|
||||
pub fn get_stringlist(reader: anytype, allocator: *std.mem.Allocator) !std.ArrayList([]const u8) {
|
||||
var strList = std.ArrayList([]const u8).init(allocator);
|
||||
var size = try get_int(reader);
|
||||
|
@ -81,6 +92,10 @@ pub fn get_variant_t(reader: anytype, type_id: u32, allocator: *std.mem.Allocato
|
|||
var map = try get_qvariantmap(reader, allocator);
|
||||
return qvar.QVariant{ .qmap = map };
|
||||
},
|
||||
@enumToInt(qvar.QVariantTypes.qvarlist) => {
|
||||
var list = try get_qvarlist(reader, allocator);
|
||||
return qvar.QVariant{ .qvarlist = list };
|
||||
},
|
||||
@enumToInt(qvar.QVariantTypes.string) => {
|
||||
var str = try get_string(reader, allocator);
|
||||
return qvar.QVariant{ .string = str };
|
||||
|
@ -97,7 +112,10 @@ pub fn get_variant_t(reader: anytype, type_id: u32, allocator: *std.mem.Allocato
|
|||
var short = try get_short(reader);
|
||||
return qvar.QVariant{ .short = short };
|
||||
},
|
||||
else => {},
|
||||
else => {
|
||||
@panic("Unsupported!");
|
||||
|
||||
},
|
||||
}
|
||||
return qvar.QVariant{ .empty = true };
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ pub fn add_stringlist(writer: anytype, allocator: *std.mem.Allocator, strList: s
|
|||
|
||||
pub fn add_variantlist(writer: anytype, allocator: *std.mem.Allocator, varList: std.ArrayList([]qvar.QVariant)) !void {
|
||||
try add_int(writer, @intCast(u32, varList.items.len));
|
||||
for (varList.items) |var| {
|
||||
try add_variant(writer, allocator, varList);
|
||||
for (varList.items) |v| {
|
||||
try add_variant(writer, allocator, v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ pub fn add_qvariant(writer: anytype, allocator: *std.mem.Allocator, variant: qva
|
|||
try add_short(writer, out);
|
||||
},
|
||||
else => {
|
||||
return;
|
||||
@panic("Unsupported!");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue