diff --git a/retroshare-gui/src/gui/im_history/IMHistoryItem.cpp b/retroshare-gui/src/gui/im_history/IMHistoryItem.cpp index 263218748..648803f00 100644 --- a/retroshare-gui/src/gui/im_history/IMHistoryItem.cpp +++ b/retroshare-gui/src/gui/im_history/IMHistoryItem.cpp @@ -1,3 +1,24 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + #include "IMHistoryItem.h" //============================================================================ diff --git a/retroshare-gui/src/gui/im_history/IMHistoryItem.h b/retroshare-gui/src/gui/im_history/IMHistoryItem.h index 5d0fcae54..6b4a2d0d7 100644 --- a/retroshare-gui/src/gui/im_history/IMHistoryItem.h +++ b/retroshare-gui/src/gui/im_history/IMHistoryItem.h @@ -1,3 +1,24 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + #ifndef __IM_history_item__ #define __IM_history_item__ diff --git a/retroshare-gui/src/gui/im_history/IMHistoryKeeper.cpp b/retroshare-gui/src/gui/im_history/IMHistoryKeeper.cpp index 52290494d..fb4516fb5 100644 --- a/retroshare-gui/src/gui/im_history/IMHistoryKeeper.cpp +++ b/retroshare-gui/src/gui/im_history/IMHistoryKeeper.cpp @@ -1,3 +1,24 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + #include "IMHistoryKeeper.h" #include @@ -121,22 +142,7 @@ IMHistoryKeeper::getMessages(QStringList& messagesList, break; } } -/* - QList::iterator hii ; // history items iterator - for (hii = hitems.begin(); hii != hitems.end(); hii++) - { - //IMHistoryItem* hitem = *hii; - if ( ( (hii->sender()==fromID)&&( hii->receiver()==toID) ) || - ( (hii->receiver()== fromID)&&(hii->sender()==toID) ) ) - { - ril << *hii ; - messFound++; - if (messFound>=messagesCount) - break; - } - } -*/ - + formStringList(ril, messagesList) ; return 0; // successful end @@ -149,13 +155,7 @@ IMHistoryKeeper::formStringList(QList& itemList, QStringList& strList) { strList.clear(); -/* - QList::const_iterator hii=itemList.constBegin(); - for(hii; hii!= itemList.constEnd(); hii++) - { - strList.append( hii->text() ); - } - */ + QListIterator hii(itemList); hii.toBack(); while (hii.hasPrevious() ) diff --git a/retroshare-gui/src/gui/im_history/IMHistoryKeeper.h b/retroshare-gui/src/gui/im_history/IMHistoryKeeper.h index ced9b1fcc..9c8974c02 100644 --- a/retroshare-gui/src/gui/im_history/IMHistoryKeeper.h +++ b/retroshare-gui/src/gui/im_history/IMHistoryKeeper.h @@ -1,3 +1,24 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + #ifndef _HISTORY_KEEPER_H_ #define _HISTORY_KEEPER_H_ @@ -6,23 +27,56 @@ #include #include -//#include "IMHistoryReader.h" #include "IMHistoryItem.h" +//! An engine for instant messaging history management + +//! This class holds history for instant messages. It stores all messages +//! in xml file. Something like +//! +//! +//! +//! manual message +//! ... +//! other messages in ... tags +//! ... +//! +//! +//! The class loads all messages from the file after creation, and saves them +//! at destruction. This means, the more history user has, the more memory +//! will be used. Maybe it's not good, but it isn't so large, I think class IMHistoryKeeper//: public QObject { // Q_OBJECT public: IMHistoryKeeper(); + IMHistoryKeeper(QString historyFileName); + + //! A destructor + + //! Warning: history messages will be saved to the file here. This means, + //! a IMHistoryKeeper object must be deleted properly. virtual ~IMHistoryKeeper(); - //int setHistoryFileName(QString historyFileName) ; + //! last error description QString errorMessage(); + + //! Select messages from history + + //! Fills given list with html-decorated messages (see formStringList(..)) + //! Takes no more then messageText messages from history, where messages + //! were sent from fromID to toID, or from toID to fromID. Also, if + //! fromID id ""(empty string), all messages, sent to toID, will be + //! extracted int getMessages(QStringList& messagesList, const QString fromID, const QString toID, const int messagesCount = 5); + //! Adds new message to the history + + //! Adds new message to the history, but the message will be saved to + //! file only after destroing the object void addMessage(const QString fromID, const QString toID, const QString messageText); diff --git a/retroshare-gui/src/gui/im_history/IMHistoryReader.cpp b/retroshare-gui/src/gui/im_history/IMHistoryReader.cpp index aa7ca32cc..26cfc084a 100644 --- a/retroshare-gui/src/gui/im_history/IMHistoryReader.cpp +++ b/retroshare-gui/src/gui/im_history/IMHistoryReader.cpp @@ -1,3 +1,24 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + #include "IMHistoryReader.h" #include diff --git a/retroshare-gui/src/gui/im_history/IMHistoryReader.h b/retroshare-gui/src/gui/im_history/IMHistoryReader.h index ad6acaf4e..f3eb5efcc 100644 --- a/retroshare-gui/src/gui/im_history/IMHistoryReader.h +++ b/retroshare-gui/src/gui/im_history/IMHistoryReader.h @@ -1,3 +1,24 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + #ifndef __IM_History_reader__ #define __IM_History_reader__ diff --git a/retroshare-gui/src/gui/im_history/IMHistoryWriter.cpp b/retroshare-gui/src/gui/im_history/IMHistoryWriter.cpp index 204478937..b28554e71 100644 --- a/retroshare-gui/src/gui/im_history/IMHistoryWriter.cpp +++ b/retroshare-gui/src/gui/im_history/IMHistoryWriter.cpp @@ -1,3 +1,24 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + #include "IMHistoryWriter.h" #include diff --git a/retroshare-gui/src/gui/im_history/IMHistoryWriter.h b/retroshare-gui/src/gui/im_history/IMHistoryWriter.h index 8b2583615..b9c69f2a2 100644 --- a/retroshare-gui/src/gui/im_history/IMHistoryWriter.h +++ b/retroshare-gui/src/gui/im_history/IMHistoryWriter.h @@ -1,3 +1,24 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2009 The RetroShare Team, Oleksiy Bilyanskyy + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + #ifndef __IM_History_writer__ #define __IM_History_writer__