func (dn *desktopNotifications) show(jid, from, message string) error { if dn.notificationStyle == "off" || !dn.supported { return nil } notification := notify.Notification{ AppName: "CoyIM", AppIcon: "coyim", Timeout: dn.expiration(), Hints: dn.hints(), ReplacesID: dn.notifications[jid], } from = ui.EscapeAllHTMLTags(string(ui.StripSomeHTML([]byte(from)))) notification.Summary, notification.Body = dn.format(from, message, true) nid, err := notification.Show() if err != nil { return fmt.Errorf("Error showing notification: %v", err) } if dn.notificationExpires { go expireNotification(nid, defaultExpirationMs) } dn.notifications[jid] = nid dn.notification = notification return nil }
func (dn *desktopNotifications) show(jid, from, message string) error { if dn.notificationStyle == "off" { return nil } from = ui.EscapeAllHTMLTags(string(ui.StripSomeHTML([]byte(from)))) summary, body := dn.format(from, message, false) note := gosxnotifier.NewNotification(body) note.Title = summary note.Group = fmt.Sprintf("im.coy.coyim.%s", from) if hasBundle { note.Sender = "im.coy.coyim" } else { note.ContentImage = coyimIcon.getPath() } err := note.Push() if err != nil { return fmt.Errorf("Error showing notification: %v", err) } return nil }
func (dn *desktopNotifications) show(jid, from, message string) error { from = ui.EscapeAllHTMLTags(string(ui.StripSomeHTML([]byte(from)))) summary, body := dn.format(from, message, false) notification := Notification{ Title: "CoyIM", Message: summary + body, Icon: coyimIcon.getPath(), } return notification.Popup() }
func (dn *desktopNotifications) format(from, message string) (summary, body string) { switch dn.notificationStyle { case "only-presence-of-new-information": return "New message!", "" case "with-author-but-no-content": return "New message!", "From: <b>" + from + "</b>" case "with-content": smsg := strings.Split(message, "\n")[0] smsg = ui.EscapeAllHTMLTags(smsg) if len(smsg) > 254 { smsg = smsg[0:253] stok := strings.Split(smsg, " ") if len(stok) > 1 { smsg = strings.Join(stok[0:len(stok)-2], " ") } smsg = smsg + "..." } return "From: " + from, smsg } return "", "" }