Example #1
0
func (conv *conversationPane) sendMessage(message string) error {
	trace, delayed, err := conv.account.session.EncryptAndSendTo(conv.to, conv.currentResource(), message)

	if err != nil {
		oerr, isoff := err.(*access.OfflineError)
		if !isoff {
			return err
		}

		conv.displayNotification(oerr.Error())
	} else {
		//TODO: review whether it should create a conversation
		//TODO: this should be whether the message was encrypted or not, rather than
		//whether the conversation is encrypted or not
		conversation, _ := conv.account.session.ConversationManager().EnsureConversationWith(conv.to, conv.currentResource())

		if delayed {
			conv.storeDelayedMessage(trace, conv.to, conv.currentResource(), message)
			conv.appendDelayed(conv.account.session.DisplayName(), time.Now(), ui.StripSomeHTML([]byte(message)))
		} else {
			conv.appendMessage(conv.account.session.DisplayName(), time.Now(), conversation.IsEncrypted(), ui.StripSomeHTML([]byte(message)), true)
		}
	}
	return nil
}
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
}
Example #4
0
func (r *roster) messageReceived(account *account, from, resource string, timestamp time.Time, encrypted bool, message []byte) {
	p, ok := r.ui.getPeer(account, from)
	if ok {
		p.LastResource(resource)
	}

	doInUIThread(func() {
		conv, err := r.openConversationView(account, from, false)
		if err != nil {
			return
		}

		conv.appendMessage(r.displayNameFor(account, from), timestamp, encrypted, ui.StripSomeHTML(message), false)

		if !conv.isVisible() && r.deNotify != nil {
			r.maybeNotify(timestamp, account, from, string(ui.StripSomeHTML(message)))
		}
	})
}
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()
}
Example #6
0
func (conv *conversationPane) appendPendingDelayed() {
	conv.pendingDelayedLock.Lock()
	defer conv.pendingDelayedLock.Unlock()

	current := conv.pendingDelayed
	conv.pendingDelayed = nil

	for _, ctrace := range current {
		dm, ok := conv.delayed[ctrace]
		if ok {
			delete(conv.delayed, ctrace)
			conversation, _ := conv.account.session.ConversationManager().EnsureConversationWith(dm.to, dm.resource)
			conv.appendMessage(conv.account.session.DisplayName(), time.Now(), conversation.IsEncrypted(), ui.StripSomeHTML([]byte(dm.message)), true)
		}
	}
}