1 #include "self.h"
2
3 #include "avatar.h"
4 #include "debug.h"
5 #include "qr.h"
6 #include "tox.h"
7
8 #include "ui/edit.h"
9 #include "layout/settings.h"
10 #include "native/filesys.h"
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15
16 struct utox_self self;
17
init_self(Tox * tox)18 void init_self(Tox *tox) {
19 /* Set local info for self */
20 edit_setstr(&edit_name, self.name, self.name_length);
21 edit_setstr(&edit_status_msg, self.statusmsg, self.statusmsg_length);
22
23 /* Get tox id, and gets the hex version for utox */
24 tox_self_get_address(tox, self.id_binary);
25 id_to_string(self.id_str, self.id_binary);
26 self.id_str_length = TOX_ADDRESS_SIZE * 2;
27 LOG_TRACE("Self INIT", "Tox ID: %.*s" , (int)self.id_str_length, self.id_str);
28
29 qr_setup(self.id_str, &self.qr_data, &self.qr_data_size, &self.qr_image, &self.qr_image_size);
30
31 /* Get nospam */
32 self.nospam = tox_self_get_nospam(tox);
33 self.old_nospam = self.nospam;
34 sprintf(self.nospam_str, "%08X", self.nospam);
35 edit_setstr(&edit_nospam, self.nospam_str, sizeof(uint32_t) * 2);
36
37 avatar_init_self();
38 }
39