http://stackoverflow.com/questions/6635034/read-chat-histroy-from-openfire-server-with-smack
Openfire server can surely save chat histories. To turn it on, you should go to Server/Server Settings/Message Audit Policy and select Enable Message Auditing. As you can see there, messages will be held under the /.../openfire/logs folder in some kind of XML format. You can parse this XML and get your messages very easily