powered by Jive Software

Is there a way to Setup Group Avatar?

Using latest stable version (willing to test any bleeding edge version), I cannot find a way to setup group avatar. I can set user avatar just fine but I need to change user avatar. Is there a way to do that with Smack? If no how difficult to achieve that?

Am not good at the dirty XMPP Stuffs yet, but am willing to try if it is not beyond noob thing!

I think there is no “native” way to do this in Smack yet. However, I guess you can implement this quite easily by transferring this guide over to Smack.

Basically you Base64-encode the image and create a VCard item with the image data, but addressed to the MUC.

Thank you. I will try that approach and let you know!

Openfires unreleased master branch will allow an image to be set. There is, however, no user interface to do this. You can use a third party client to set an avatar for a MUC room (Conversations is known to work)

1 Like

Thanks for the tip. I want to do it on my own client using Smack

I think what you want to do is to replicate what Smack is doing when saving the users Avatar, but set the conferences address as to value.

1 Like

Exactly! I have time this night, am going to play with that idea!

I think I missed your point (which am getting now). How do I nstall that Openfire version?

Hi Paul,
your post was useful to help me find the solution. I here by put full solution for others to Copy and paste when they face the same issue. wonder if it can be incorporated in Smack, but it is simple for once to use it directly on his/her project. Here it is


import org.jivesoftware.smack.SmackException.NoResponseException
import org.jivesoftware.smack.SmackException.NotConnectedException
import org.jivesoftware.smack.XMPPException.XMPPErrorException
import org.jivesoftware.smack.packet.IQ
import org.jivesoftware.smack.tcp.XMPPTCPConnection
import org.jivesoftware.smackx.vcardtemp.packet.VCard
import org.jxmpp.jid.impl.JidCreate


object XMPPUtils {
    @Throws(
        NoResponseException::class,
        XMPPErrorException::class,
        NotConnectedException::class,
        InterruptedException::class
    )
    fun saveMUCVCard(groupId: String, data: ByteArray, connection: XMPPTCPConnection) {
        val vCard = VCard()
        vCard.to = JidCreate.entityBareFrom(groupId)
        vCard.type = IQ.Type.set
        vCard.avatar = data
        // Also make sure to generate a new stanza id (the given vcard could be a vcard result), in which case we don't
        // want to use the same stanza id again (although it wouldn't break if we did)
        vCard.setStanzaId()
        connection.createStanzaCollectorAndSend(vCard).nextResultOrThrow<VCard>()
    }
}

One have to be careful to limit avatar size or he might face issues!

1 Like

One note, it does not work with Openfire yet. Fully tested with eJabberd and it works fine!

@guus
I have found this link but only have deb and rpm builds. It mentions of generic zip/tar files but are not there. Am using Mac Os.

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.