void pushEventToHistory(EventHistory_t* history, time_t time, const char* type, const char* origin, const char** params, unsigned int paramCount) { // If our event history is currently too large, get rid of the oldest // element. if (json_array_size(history->root) >= history->maxSize) { popEvent(history); } json_t* eventObj = json_object(); json_object_set_new(eventObj, "time", json_integer(time)); json_object_set_new(eventObj, "type", json_string(type)); json_object_set_new(eventObj, "origin", json_string(origin)); json_object_set_new(eventObj, "params", json_array()); json_t* jsonParamArray = json_object_get(eventObj, "params"); // Fill our json parameter array. for (unsigned int i = 0; i < paramCount; i++) { json_array_append(jsonParamArray, json_string(params[i])); } json_array_append(history->root, eventObj); exportHistory(history, "messages.json"); }
void HistoryDlg::doSave() { UserListItem *u = d->pa->findFirstRelevant(d->jid); QString them = JIDUtil::nickOrJid(u->name(), u->jid().full()); QString s = JIDUtil::encode(them).toLower(); QString str = FileUtil::getSaveFileName(this, tr("Export message history"), s + ".txt", tr("Text files (*.txt);;All files (*.*)")); if (!str.isEmpty()) { exportHistory(str); } }