Skip to content

Instantly share code, notes, and snippets.

@justjanne
Last active April 14, 2016 12:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justjanne/71be557c670937d6ee93 to your computer and use it in GitHub Desktop.
Save justjanne/71be557c670937d6ee93 to your computer and use it in GitHub Desktop.
CoreSetup info

CoreSetup

Protocol Flow

When the client receives a CoreInitAck message, with "Configured" set to "False", it will display to the user a list, allowing them to choose a StorageBackend from the ones present in CoreInitAck’s "StorageBackends" attribute.

If the user chooses one such backend, and the backend has a SetupKeys attribute which is not-empty, the user will be presented with input fields for each of the keys, pre-populated with the values of the SetupDefaults map. Each field allows only inputs of the same type as the default value, so, for example, a field named "Port" which has the default value QVariant(Int, 4242) would only allow integers to be input.

As soon as the user has properly filled out and configured these settings, they will choose the username and password of the new account that is to be set up on the core.

The first account set up is a so-called "Admin Account", although this does not yet provide any special abilities.

The client will then send a new CoreSetupData message containing a SetupData attribute with all the previously specified settings.

If the client receives a CoreSetupReject, it will display the specified error to the user, and, if wished, allow them to try configuring again.

If the client receives a CoreSetupAck, the client will proceed normally in the init procedure, by sending the ClientLogin message.

Object Serialization

This document discusses how complex objects are translated to and from VariantMaps.

Complex Structs are (de-)serialized to and from VariantMaps. If the Complex Struct is sent/received during handshake, an additional key/value pair "MsgType" is added, which contains the name of the complexStruct’s type – for example "ClientInitAck" as String16

##complexStruct ClientInitAck

Field Type Description
Configured bool Is set, if the core has at least one account and a storage backend is selected
LoginEnabled bool Specifies if clients can authenticate against the core
CoreFeatures uint8 An int specifying the features the core supports
StorageBackends VariantList A VariantList of StorageBackends, see below

###complexStruct ClientInitAck.StorageBackend

Field Type Description
DisplayName string16 The name of the storage backend
Description string16 A user-readable description
SetupKeys StringList A list of keys that need to be set to configure the backend
SetupDefaults VariantMap The default values for each key

##complexStruct CoreSetupData

Field Type Description
SetupData SetupData The setup data

###complexStruct SetupData

Field Type Description
AdminUser string16 The username of the new user
AdminPasswd string16 The password of the new user
Backend string16 The DisplayName of the selected backend.
ConnectionProperties VariantMap The connection settings for the selected backend. The types of each value have to match the type of the default value

##complexStruct CoreSetupReject

Field Type Description
Error string16 The error message that will be displayed to the user as reason why configuring was not possible

##complexStruct CoreSetupAck

This type contains no fields.

Serialization of Primitives

All serialization is done in network format big-endian.

Serialization of basic types is trivial and will not be discussed here.

string8 is used to refer to UTF-8 encoded Strings, string16 is used to refer to UTF-16BE encoded strings, string8-null is used to refer to UTF-8 encoded strings with trailing null byte

Primitive types are serialized by serializing each of their fields sequentially.

##struct String

Strings are serialized as a signed int of the length in bytes (plus 1 for string8-null) plus their content in the specified encoding (plus one null-byte for string8-null).
If the length is -1, the String is to be considered equivalent to NULL.

##struct StringList

StringLists are serialized as an int32 of the amount of elements, and a string16 for each element.

##struct Variant

First, an int32 for the type, then an uint8 for an unknown value, then, if the type is a usertype, the typename as string8-null, and then the value in its own format.

###struct Variant.List

VariantLists are serialized as an int32 of the length, and a Variant for each element.

###struct Variant.Map

VariantMaps are serialized as an int32 of the amount of keys, and then for each key a string16 for the key and a Variant for each element.

###enum Variant.Type

Warning: string8 uses the id of QByteArray in the serialization.

Type Value
Void 0x00000000
Bool 0x00000001
Int 0x00000002
UInt 0x00000003
QVariantMap 0x00000008
QVariantList 0x00000009
QString 0x0000000a
QStringList 0x0000000b
QByteArray 0x0000000c
QDate 0x0000000e
QTime 0x0000000f
QDateTime 0x00000010
QRegExp 0x0000002b
UserType 0x0000007f
Long 0x00000081
Short 0x00000082
Char 0x00000083
ULong 0x00000084
UShort 0x00000085
UChar 0x00000086
QVariant 0x00000090
User 0x00000100
LastType 0xffffffff

##struct DateTime

Type Field Description
int32 julianDay Day in Julian calendar, unknown if signed or unsigned
int32 millisOfDay Milliseconds since start of day
uint8 zone Timezone of DateTime, 0x00 is local, 0x01 is UTC

##struct Time

Type Field Description
int32 millisOfDay Milliseconds since start of day

##struct Protocol

Type Field Description
uint8 flags See below
int16 extra Extra data, depends on the protocol
int8 version Protocol Version

###bitmask Protocol.Flags

Type Value
ssl 0x01
compression 0x02

##struct BufferInfo

Type Field Description
int32 id BufferId, a unique, sequential id for the buffer
int32 networkId NetworkId of the network the buffer belongs to
int16 type See below
string8 name BufferName as displayed to the user

###enum BufferInfo.Type

Type Value
Status 0x01
Channel 0x02
Query 0x04
Group 0x08

##struct Message

Type Field Description
int32 messageId The unique, sequential id for the message
ìnt32 timestamp The timestamp of the message in UNIX time (32-bit, seconds)
int32 type See below
uint8 flags See below
BufferInfo buffer The buffer the message belongs to, usually everything but BufferId is set to NULL
string8 sender The sender as nick!ident@host
string8 content The message content, already stripped from CTCP formatting, but containing mIRC format codes

###enum Message.Type

Type Value
Plain 0x00000001
Notice 0x00000002
Action 0x00000004
Nick 0x00000008
Mode 0x00000010
Join 0x00000020
Part 0x00000040
Quit 0x00000080
Kick 0x00000100
Kill 0x00000200
Server 0x00000400
Info 0x00000800
Error 0x00001000
DayChange 0x00002000
Topic 0x00004000
NetsplitJoin 0x00008000
NetsplitQuit 0x00010000
Invite 0x00020000

###bitmask Message.Flags

Type Value
Self 0x00000001
Highlight 0x00000002
Redirected 0x00000004
ServerMsg 0x00000008
Backlog 0x00000080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment