chat history ?

7 posts / 0 new
Last post
Anonymous
chat history ?

I want to review the chat history. Does Tigase server support this? if have, where can i find ? Thank for advance.

Currently it doesn't, at least not out of the box.

Anonymous

Does tigase support to save messages on file (ex: .txt, .xml)when people chat? If not, I want to write this function, I must begin with which "class" or "interface"? Thank for advance

Writing plugin code will probably be very helpful.
Also - there is rudimentary implementation of XEP-0136.

Anonymous

I'm currently writing a plugin to archive all messages. I have referred to OfflineMessage.java (file) and edited this file a little bit. When two users chat with each other, all messages shall be saved (Absolutely), but these two people cannot see chat messages of each other.Please review my code:

SaveAllMessages.java


public class SaveAllMessages extends XMPPProcessor
implements XMPPPostprocessorIfc{

private static final Logger log = Logger.getLogger(OfflineMessages.class.getName());
private static final String ID = "savemsg";
protected static final String XMLNS = "jabber:client";
private static final String[] ELEMENTS = { Presence.PRESENCE_ELEMENT_NAME };
//private static final String[] ELEMENTS = { "message" };
private static final String[] XMLNSS = { XMLNS };
private static final Element[] DISCO_FEATURES = {
new Element("feature", new String[] { "var" }, new String[] { "savemsg" }) };

private final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

@Override
public int concurrentQueuesNo() {
return Runtime.getRuntime().availableProcessors();
}

@Override
public String id() {
return ID;
}

@Override
public void postProcess(final Packet packet, final XMPPResourceConnection conn,
final NonAuthUserRepository repo, final Queue queue, Map settings) {
{
try {
MsgSaveRepositoryIfc msg_repo = getMsgSaveRepoImpl(repo, conn);

savePacketForUser(packet, msg_repo);
} catch (UserNotFoundException e) {
if (log.isLoggable(Level.FINEST)) {
log.finest("UserNotFoundException at trying to save packet for off-line user." + packet);
}
}
}

public boolean savePacketForUser(Packet pac, MsgSaveRepositoryIfc repo)
throws UserNotFoundException {
StanzaType type = pac.getType();

if (pac.getElemName().equals("message")
&& (pac.getElement().findChild("/message/body") != null)) {
Element elem = pac.getElement().clone();
String stamp = null;

synchronized (formatter) {
stamp = formatter.format(new Date());
}

String from = pac.getStanzaTo().getDomain();

repo.storeMessage(pac.getStanzaFrom(), pac.getStanzaTo(), null, elem);
pac.processedBy(ID);

return true;
}

return false;
}

@Override
public Element[] supDiscoFeatures(final XMPPResourceConnection session) {
return DISCO_FEATURES;
}

@Override
public String[] supElements() {
return ELEMENTS;
}

@Override
public String[] supNamespaces() {
return XMLNSS;
}

protected MsgSaveRepositoryIfc getMsgSaveRepoImpl(NonAuthUserRepository repo,
XMPPResourceConnection conn) {
return new MsgSaveRepositoryImpl(repo, conn);
}

private class MsgSaveRepositoryImpl implements MsgSaveRepositoryIfc {
private XMPPResourceConnection conn = null;
private SimpleParser parser = SingletonFactory.getParserInstance();
private NonAuthUserRepository repo = null;

private MsgSaveRepositoryImpl(NonAuthUserRepository repo, XMPPResourceConnection conn) {
this.repo = repo;
this.conn = conn;
}

@Override
public Element getMessageExpired(long time, boolean delete) {
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public void storeMessage(JID from, JID to, Date expired, Element msg)
throws UserNotFoundException {
repo.addOfflineDataList(to.getBareJID(), ID, "messages", new String[] { msg.toString() });
}
}
}

Toti

Is it possible to have news about archievement message plugin ?

Apologies for getting back to you only now. Regarding your code - I assume it's not working? I can spot a few errors in there: why to you renamed interface MsgRepositoryIfc to MsgSaveRepositoryIfc? Why only implements postProcess when you want *all* messages (this would only apply to the messages that weren't processes already, i.e. messages sent to offline user), there is no implementation of loadMessagesToJID within MsgSaveRepositoryImpl class.
The rest looks OK (on quick glance) and should store all sent messages to the database. Another issu is retreiving them from the DB which is missing in your code.