void friend_setname(FRIEND *f, char_t *name, STRING_IDX length){ if(f->name && (length != f->name_length || memcmp(f->name, name, length) != 0)) { MESSAGE *msg = malloc(sizeof(MESSAGE) + sizeof(" is now known as ") - 1 + f->name_length + length); msg->author = 0; msg->msg_type = MSG_TYPE_ACTION_TEXT; msg->length = sizeof(" is now known as ") - 1 + f->name_length + length; char_t *p = msg->msg; memcpy(p, f->name, f->name_length); p += f->name_length; memcpy(p, " is now known as ", sizeof(" is now known as ") - 1); p += sizeof(" is now known as ") - 1; memcpy(p, name, length); friend_addmessage(f, msg); } free(f->name); if(length == 0) { f->name = malloc(sizeof(f->cid) * 2 + 1); cid_to_string(f->name, f->cid); f->name_length = sizeof(f->cid) * 2; } else { f->name = malloc(length + 1); memcpy(f->name, name, length); f->name_length = length; } f->name[f->name_length] = 0; update_shown_list(); }
_Bool friend_set_online(FRIEND *f, _Bool online) { if (f->online == online) { return false; } f->online = online; if(!f->online) { friend_set_typing(f, 0); } update_shown_list(); return true; }
void list_start(void) { ITEM *i = item; item_add.item = ITEM_ADD; item_settings.item = ITEM_SETTINGS; button_settings.disabled = 1; selected_item = &item_settings; FRIEND *f = friend, *end = f + friends; while(f != end) { i->item = ITEM_FRIEND; i->data = f; i++; f++; } itemcount = i - item; search_string = NULL; update_shown_list(); }
void list_search(char_t *str) { search_string = str; update_shown_list(); }
void list_set_filter(uint8_t new_filter) { filter = new_filter; update_shown_list(); }
static ITEM* newitem(void) { ITEM *i = &item[itemcount++]; //TODO: .. update_shown_list(); return i; }