int box_notify2(ToxWindow* self, Notification notif, uint64_t flags, int id, const char* format, ...) { if ((flags & NT_RESTOL && Control.cooldown > time(NULL)) || ((flags & NT_NOFOCUS && Control.this_window == get_focused_window_id()) )) return -1; #ifdef _BOX_NOTIFY if (sound_notify2(self, notif, flags, id) == -1) return -1; control_lock(); if (!actives[id].box || actives[id].size >= 128 ) { control_unlock(); return -1; } va_list __ARGS__; va_start (__ARGS__, format); vsnprintf (actives[id].messages[actives[id].size], 127, format, __ARGS__); va_end (__ARGS__); if (strlen(actives[id].messages[actives[id].size]) > 124) strcpy(actives[id].messages[actives[id].size] + 124, "..."); actives[id].size ++; actives[id].n_timeout = time(NULL) + Control.notif_timeout / 1000; char formated[128 * 129] = {'\0'}; int i = 0; for (; i <actives[id].size; i ++) { strcat(formated, actives[id].messages[i]); strcat(formated, "\n"); } formated[strlen(formated) - 1] = '\0'; notify_notification_update(actives[id].box, actives[id].title, formated, NULL); notify_notification_show(actives[id].box, NULL); control_unlock(); return id; #else return sound_notify2(self, notif, flags, id); #endif }
int box_notify2(ToxWindow* self, Notification notif, uint64_t flags, int id, const char* format, ...) { if (notifications_are_disabled(flags)) { tab_notify(self, flags); return -1; } #ifdef BOX_NOTIFY if (sound_notify2(self, notif, flags, id) == -1) return -1; control_lock(); if (!actives[id].box || actives[id].size >= MAX_BOX_MSG_LEN + 1) { control_unlock(); return -1; } va_list __ARGS__; va_start (__ARGS__, format); vsnprintf (actives[id].messages[actives[id].size], MAX_BOX_MSG_LEN, format, __ARGS__); va_end (__ARGS__); if (strlen(actives[id].messages[actives[id].size]) > MAX_BOX_MSG_LEN - 3) strcpy(actives[id].messages[actives[id].size] + MAX_BOX_MSG_LEN - 3, "..."); actives[id].size++; actives[id].n_timeout = get_unix_time() + Control.notif_timeout / 1000; char formated[128 * 129] = {'\0'}; int i = 0; for (; i <actives[id].size; i ++) { strcat(formated, actives[id].messages[i]); strcat(formated, "\n"); } formated[strlen(formated) - 1] = '\0'; notify_notification_update(actives[id].box, actives[id].title, formated, NULL); notify_notification_show(actives[id].box, NULL); control_unlock(); return id; #else return sound_notify2(self, notif, flags, id); #endif }