mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 17:56:21 +00:00
Update status in contact list on notification
This commit is contained in:
@@ -98,8 +98,20 @@ int contact_list_add(const char * const name, const char * const show)
|
|||||||
|
|
||||||
while(curr) {
|
while(curr) {
|
||||||
contact_t *curr_contact = curr->contact;
|
contact_t *curr_contact = curr->contact;
|
||||||
if (strcmp(curr_contact->name, name) == 0)
|
if (strcmp(curr_contact->name, name) == 0) {
|
||||||
|
if (curr_contact->show != NULL) {
|
||||||
|
free(curr_contact->show);
|
||||||
|
curr_contact->show = NULL;
|
||||||
|
|
||||||
|
if (show != NULL) {
|
||||||
|
curr_contact->show =
|
||||||
|
(char *) malloc((strlen(show) + 1) * sizeof(char));
|
||||||
|
strcpy(curr_contact->show, show);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
prev = curr;
|
prev = curr;
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
@@ -159,7 +171,7 @@ static contact_t * _new_contact(const char * const name, const char * const show
|
|||||||
new->name = (char *) malloc((strlen(name) + 1) * sizeof(char));
|
new->name = (char *) malloc((strlen(name) + 1) * sizeof(char));
|
||||||
strcpy(new->name, name);
|
strcpy(new->name, name);
|
||||||
|
|
||||||
if (show) {
|
if (show != NULL) {
|
||||||
new->show = (char *) malloc((strlen(show) + 1) * sizeof(char));
|
new->show = (char *) malloc((strlen(show) + 1) * sizeof(char));
|
||||||
strcpy(new->show, show);
|
strcpy(new->show, show);
|
||||||
} else {
|
} else {
|
||||||
@@ -173,7 +185,7 @@ static void _destroy_contact(contact_t *contact)
|
|||||||
{
|
{
|
||||||
free(contact->name);
|
free(contact->name);
|
||||||
|
|
||||||
if (contact->show) {
|
if (contact->show != NULL) {
|
||||||
free(contact->show);
|
free(contact->show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user