diff --git a/libretroshare/src/retroshare/rsiface.h b/libretroshare/src/retroshare/rsiface.h index c9fcb1cb2..f2817a275 100644 --- a/libretroshare/src/retroshare/rsiface.h +++ b/libretroshare/src/retroshare/rsiface.h @@ -87,9 +87,6 @@ public: virtual void lockData() = 0; virtual void unlockData() = 0; - const std::list &getRecommendList() - { return mRecommendList; } - const RsConfig &getConfig() { return mConfig; } /****************************************/ @@ -125,8 +122,6 @@ bool hasChanged(DataFlags set); /* resets it */ void fillLists(); /* create some dummy data to display */ /* Internals */ - std::list mRecommendList; - bool mChanged[NumOfFlags]; RsConfig mConfig; @@ -154,19 +149,10 @@ class RsControl /* The Main Interface Class - for controlling the server */ /****************************************/ /* Flagging Persons / Channels / Files in or out of a set (CheckLists) */ - virtual int SetInChat(std::string id, bool in) = 0; /* friend : chat msgs */ - virtual int SetInMsg(std::string id, bool in) = 0; /* friend : msg receipients */ virtual int SetInBroadcast(std::string id, bool in) = 0; /* channel : channel broadcast */ virtual int SetInSubscribe(std::string id, bool in) = 0; /* channel : subscribed channels */ - virtual int SetInRecommend(std::string id, bool in) = 0; /* file : recommended file */ - virtual int ClearInChat() = 0; - virtual int ClearInMsg() = 0; virtual int ClearInBroadcast() = 0; virtual int ClearInSubscribe() = 0; - virtual int ClearInRecommend() = 0; - - virtual bool IsInChat(std::string id) = 0; /* friend : chat msgs */ - virtual bool IsInMsg(std::string id) = 0; /* friend : msg recpts*/ /****************************************/ /* Config */ diff --git a/libretroshare/src/rsserver/p3face-msgs.cc b/libretroshare/src/rsserver/p3face-msgs.cc index ee8bdf442..359246f0e 100644 --- a/libretroshare/src/rsserver/p3face-msgs.cc +++ b/libretroshare/src/rsserver/p3face-msgs.cc @@ -39,118 +39,6 @@ const int p3facemsgzone = 11453; /* Flagging Persons / Channels / Files in or out of a set (CheckLists) */ -int RsServer::ClearInChat() -{ - lockRsCore(); /* LOCK */ - - mInChatList.clear(); - - unlockRsCore(); /* UNLOCK */ - - return 1; -} - - - /* Flagging Persons / Channels / Files in or out of a set (CheckLists) */ -int RsServer::SetInChat(std::string id, bool in) /* friend : chat msgs */ -{ - /* so we send this.... */ - lockRsCore(); /* LOCK */ - - //std::cerr << "Set InChat(" << id << ") to " << (in ? "True" : "False") << std::endl; - std::list::iterator it; - it = std::find(mInChatList.begin(), mInChatList.end(), id); - if (it == mInChatList.end()) - { - if (in) - { - mInChatList.push_back(id); - } - } - else - { - if (!in) - { - mInChatList.erase(it); - } - } - - unlockRsCore(); /* UNLOCK */ - - return 1; -} - - -int RsServer::ClearInMsg() -{ - lockRsCore(); /* LOCK */ - - mInMsgList.clear(); - - unlockRsCore(); /* UNLOCK */ - - return 1; -} - - -int RsServer::SetInMsg(std::string id, bool in) /* friend : msgs */ -{ - /* so we send this.... */ - lockRsCore(); /* LOCK */ - - //std::cerr << "Set InMsg(" << id << ") to " << (in ? "True" : "False") << std::endl; - std::list::iterator it; - it = std::find(mInMsgList.begin(), mInMsgList.end(), id); - if (it == mInMsgList.end()) - { - if (in) - { - mInMsgList.push_back(id); - } - } - else - { - if (!in) - { - mInMsgList.erase(it); - } - } - - unlockRsCore(); /* UNLOCK */ - return 1; -} - -bool RsServer::IsInChat(std::string id) /* friend : chat msgs */ -{ - /* so we send this.... */ - lockRsCore(); /* LOCK */ - - std::list::iterator it; - it = std::find(mInChatList.begin(), mInChatList.end(), id); - bool inChat = (it != mInChatList.end()); - - unlockRsCore(); /* UNLOCK */ - - return inChat; -} - - -bool RsServer::IsInMsg(std::string id) /* friend : msg recpts*/ -{ - /* so we send this.... */ - lockRsCore(); /* LOCK */ - - std::list::iterator it; - it = std::find(mInMsgList.begin(), mInMsgList.end(), id); - bool inMsg = (it != mInMsgList.end()); - - unlockRsCore(); /* UNLOCK */ - - return inMsg; -} - - - int RsServer::ClearInBroadcast() { @@ -171,53 +59,3 @@ int RsServer::SetInSubscribe(std::string id, bool in) /* channel : su { return 1; } - -int RsServer::ClearInRecommend() -{ - /* find in people ... set chat flag */ - RsIface &iface = getIface(); - iface.lockData(); /* LOCK IFACE */ - - std::list &recs = iface.mRecommendList; - std::list::iterator it; - - for(it = recs.begin(); it != recs.end(); it++) - { - it -> inRecommend = false; - } - - iface.unlockData(); /* UNLOCK IFACE */ - - return 1; -} - - -int RsServer::SetInRecommend(std::string id, bool in) /* file : recommended file */ -{ - /* find in people ... set chat flag */ - RsIface &iface = getIface(); - iface.lockData(); /* LOCK IFACE */ - - std::list &recs = iface.mRecommendList; - std::list::iterator it; - - for(it = recs.begin(); it != recs.end(); it++) - { - if (it -> fname == id) - { - /* set flag */ - it -> inRecommend = in; - //std::cerr << "Set InRecommend (" << id << ") to " << (in ? "True" : "False") << std::endl; - } - } - - iface.unlockData(); /* UNLOCK IFACE */ - - return 1; -} - - - - - - diff --git a/libretroshare/src/rsserver/p3face.h b/libretroshare/src/rsserver/p3face.h index 347e9850c..8e88eaece 100644 --- a/libretroshare/src/rsserver/p3face.h +++ b/libretroshare/src/rsserver/p3face.h @@ -109,25 +109,13 @@ class RsServer: public RsControl, public RsThread public: /* Flagging Persons / Channels / Files in or out of a set (CheckLists) */ - virtual int SetInChat(std::string id, bool in); /* friend : chat msgs */ - virtual int SetInMsg(std::string id, bool in); /* friend : msg receipients */ virtual int SetInBroadcast(std::string id, bool in); /* channel : channel broadcast */ virtual int SetInSubscribe(std::string id, bool in); /* channel : subscribed channels */ - virtual int SetInRecommend(std::string id, bool in); /* file : recommended file */ - virtual int ClearInChat(); - virtual int ClearInMsg(); virtual int ClearInBroadcast(); virtual int ClearInSubscribe(); - virtual int ClearInRecommend(); - - virtual bool IsInChat(std::string id); /* friend : chat msgs */ - virtual bool IsInMsg(std::string id); /* friend : msg recpts*/ - private: - std::list mInChatList, mInMsgList; - void initRsMI(RsMsgItem *msg, MessageInfo &mi); /****************************************/ diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index daa401a23..11fd219ef 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -1545,23 +1545,23 @@ void PeersDialog::insertSendList() /* to toggle the state */ -void PeersDialog::toggleSendItem( QTreeWidgetItem *item, int col ) -{ - #ifdef PEERS_DEBUG - std::cerr << "ToggleSendItem()" << std::endl; - #endif - - /* extract id */ - std::string id = (item -> text(4)).toStdString(); - - /* get state */ - bool inChat = (Qt::Checked == item -> checkState(0)); /* alway column 0 */ - - /* call control fns */ - - rsicontrol -> SetInChat(id, inChat); - return; -} +//void PeersDialog::toggleSendItem( QTreeWidgetItem *item, int col ) +//{ +// #ifdef PEERS_DEBUG +// std::cerr << "ToggleSendItem()" << std::endl; +// #endif +// +// /* extract id */ +// std::string id = (item -> text(4)).toStdString(); +// +// /* get state */ +// bool inChat = (Qt::Checked == item -> checkState(0)); /* alway column 0 */ +// +// /* call control fns */ +// +// rsicontrol -> SetInChat(id, inChat); +// return; +//} //============================================================================ diff --git a/retroshare-gui/src/gui/PeersDialog.h b/retroshare-gui/src/gui/PeersDialog.h index 6d8808d90..6c051b395 100644 --- a/retroshare-gui/src/gui/PeersDialog.h +++ b/retroshare-gui/src/gui/PeersDialog.h @@ -71,7 +71,7 @@ public slots: void insertPeers(); void publicChatChanged(int type); - void toggleSendItem( QTreeWidgetItem *item, int col ); +// void toggleSendItem( QTreeWidgetItem *item, int col ); void insertChat(); void setChatInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText)); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index a5a45be28..047bd428f 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include "rshare.h" #include "MessageComposer.h" @@ -56,11 +58,11 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags) setupEditActions(); setupViewActions(); setupInsertActions(); - + Settings->loadWidgetInformation(this); setAttribute ( Qt::WA_DeleteOnClose, true ); - + // connect up the buttons. connect( ui.actionSend, SIGNAL( triggered (bool)), this, SLOT( sendMessage( ) ) ); //connect( ui.actionReply, SIGNAL( triggered (bool)), this, SLOT( replyMessage( ) ) ); @@ -83,20 +85,14 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags) connect(ui.codeButton, SIGNAL (clicked()), this, SLOT (toggleCode())); connect(ui.msgText, SIGNAL( checkSpellingChanged( bool ) ), this, SLOT( spellChecking( bool ) ) ); - - connect(ui.msgText, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), - this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); - connect(ui.msgText, SIGNAL(cursorPositionChanged()), - this, SLOT(cursorPositionChanged())); - - connect(ui.msgText->document(), SIGNAL(modificationChanged(bool)), - actionSave, SLOT(setEnabled(bool))); - connect(ui.msgText->document(), SIGNAL(modificationChanged(bool)), - this, SLOT(setWindowModified(bool))); - connect(ui.msgText->document(), SIGNAL(undoAvailable(bool)), - actionUndo, SLOT(setEnabled(bool))); - connect(ui.msgText->document(), SIGNAL(redoAvailable(bool)), - actionRedo, SLOT(setEnabled(bool))); + + connect(ui.msgText, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); + connect(ui.msgText, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); + + connect(ui.msgText->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); + connect(ui.msgText->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); + connect(ui.msgText->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); + connect(ui.msgText->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified(ui.msgText->document()->isModified()); actionSave->setEnabled(ui.msgText->document()->isModified()); @@ -120,13 +116,12 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags) connect(ui.msgSendList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ), this, SLOT(togglePersonItem( QTreeWidgetItem *, int ) )); - connect(ui.msgFileList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ), - this, SLOT(toggleRecommendItem( QTreeWidgetItem *, int ) )); + connect(ui.msgFileList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ), this, SLOT(toggleRecommendItem( QTreeWidgetItem *, int ) )); /* hide the Tree +/- */ ui.msgSendList -> setRootIsDecorated( false ); ui.msgFileList -> setRootIsDecorated( false ); - + /* to hide the header */ //ui.msgSendList->header()->hide(); @@ -173,7 +168,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags) ui.comboSize->setCurrentIndex(ui.comboSize->findText(QString::number(QApplication::font().pointSize()))); ui.textalignmentbtn->setIcon(QIcon(QString(":/images/textedit/textcenter.png"))); - + QMenu * alignmentmenu = new QMenu(); alignmentmenu->addAction(actionAlignLeft); alignmentmenu->addAction(actionAlignCenter); @@ -184,13 +179,13 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags) QPixmap pxm(24,24); pxm.fill(Qt::black); ui.colorbtn->setIcon(pxm); - - /* Set header resize modes and initial section sizes */ + + /* Set header resize modes and initial section sizes */ ui.msgFileList->setColumnCount(5); ui.msgFileList->setColumnHidden ( 4, true); - + QHeaderView * _smheader = ui.msgFileList->header () ; - + _smheader->resizeSection ( 0, 200 ); _smheader->resizeSection ( 1, 60 ); _smheader->resizeSection ( 2, 60 ); @@ -205,7 +200,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags) /* set focus to subject */ ui.titleEdit->setFocus(); - /* Hide platform specific features */ + /* Hide platform specific features */ #ifdef Q_WS_WIN #endif @@ -215,18 +210,14 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags) { // std::cerr << "MessageComposer::msgfriend()" << std::endl; - rsicontrol -> ClearInMsg(); - rsicontrol -> SetInMsg(id, true); - std::list sslIds; - rsPeers->getSSLChildListOfGPGId(id, sslIds); - for (std::list::iterator it = sslIds.begin(); it != sslIds.end(); it++) { - //put all sslChilds in message list - rsicontrol -> SetInMsg(*it, true); - } - /* create a message */ + MessageComposer *pMsgDialog = new MessageComposer(); + pMsgDialog->m_sslIds.clear(); + //put all sslChilds in message list + rsPeers->getSSLChildListOfGPGId(id, pMsgDialog->m_sslIds); + pMsgDialog->newMsg(); pMsgDialog->show(); @@ -241,9 +232,6 @@ void MessageComposer::recommendFriend(std::list &peerids) return; } -// rsicontrol -> ClearInMsg(); -// rsicontrol -> SetInMsg(id, true); - /* create a message */ MessageComposer *pMsgDialog = new MessageComposer(); @@ -255,7 +243,7 @@ void MessageComposer::recommendFriend(std::list &peerids) sMsgText += "

"; /* process peer ids */ - std::list files_info; +// std::list files_info; std::list ::iterator peerid; for (peerid = peerids.begin(); peerid != peerids.end(); peerid++) { RsPeerDetails detail; @@ -371,7 +359,7 @@ void MessageComposer::insertSendList() item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); item -> setCheckState(0, Qt::Unchecked); - if (rsicontrol->IsInMsg(detail.id)) + if (std::find(m_sslIds.begin(), m_sslIds.end(), detail.id) != m_sslIds.end()) { item -> setCheckState(0, Qt::Checked); } @@ -432,8 +420,6 @@ void MessageComposer::insertFileList(const std::list& dir_info) void MessageComposer::insertFileList(const std::list& files_info) { -// rsiface->lockData(); /* Lock Interface */ - _recList.clear() ; // const std::list &recList = rsiface->getRecommendList(); @@ -467,8 +453,6 @@ void MessageComposer::insertFileList(const std::list& files_info) /* add the items in! */ tree->insertTopLevelItems(0, items); -// rsiface->unlockData(); /* UnLock Interface */ - tree->update(); /* update display */ } @@ -600,14 +584,10 @@ void MessageComposer::sendMessage_internal(bool bDraftbox) mi.title = ui.titleEdit->text().toStdWString(); mi.msg = ui.msgText->toHtml().toStdWString(); - rsiface->lockData(); /* Lock Interface */ - for(std::list::const_iterator it(_recList.begin()); it != _recList.end(); ++it) if (it -> inRecommend) mi.files.push_back(*it); - rsiface->unlockData(); /* UnLock Interface */ - /* get the ids from the send list */ std::list peers; std::list::iterator iit; @@ -615,7 +595,7 @@ void MessageComposer::sendMessage_internal(bool bDraftbox) rsPeers->getFriendList(peers); for(iit = peers.begin(); iit != peers.end(); iit++) { - if (rsicontrol->IsInMsg(*iit)) { + if (std::find(m_sslIds.begin(), m_sslIds.end(), *iit) != m_sslIds.end()) { mi.msgto.push_back(*iit); } } @@ -661,34 +641,43 @@ void MessageComposer::addRecipient(std::string id) /* First the Msg (People) ones */ void MessageComposer::togglePersonItem( QTreeWidgetItem *item, int col ) { - //std::cerr << "TogglePersonItem()" << std::endl; + //std::cerr << "TogglePersonItem()" << std::endl; - /* extract id */ - std::string id = (item -> text(1)).toStdString(); + /* extract id */ + std::string id = (item -> text(1)).toStdString(); - /* get state */ - bool inMsg = (Qt::Checked == item -> checkState(0)); /* alway column 0 */ + /* get state */ + bool inMsg = (Qt::Checked == item -> checkState(0)); /* alway column 0 */ - /* call control fns */ + /* call control fns */ - rsicontrol -> SetInMsg(id, inMsg); - return; + std::list::iterator sslIt = std::find(m_sslIds.begin(), m_sslIds.end(), id); + if (sslIt == m_sslIds.end()) { + if (inMsg) { + m_sslIds.push_back(id); + } + } else { + if (inMsg == false) { + m_sslIds.erase(sslIt); + } + } } void MessageComposer::toggleRecommendItem( QTreeWidgetItem *item, int col ) { - //std::cerr << "ToggleRecommendItem()" << std::endl; + //std::cerr << "ToggleRecommendItem()" << std::endl; - /* extract name */ - std::string id = (item -> text(0)).toStdString(); + /* extract hash */ + std::string hash = (item -> text(3)).toStdString(); - /* get state */ - bool inRecommend = (Qt::Checked == item -> checkState(0)); /* alway column 0 */ + /* get state */ + bool inRecommend = (Qt::Checked == item -> checkState(0)); /* alway column 0 */ - /* call control fns */ - - rsicontrol -> SetInRecommend(id, inRecommend); - return; + for(std::list::iterator it(_recList.begin()); it != _recList.end(); ++it) { + if (it->hash == hash) { + it->inRecommend = inRecommend; + } + } } diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index e234e9a31..82b65046a 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -183,6 +183,7 @@ private: /* maps of files */ std::list mAttachments; + std::list m_sslIds; bool mCheckAttachment;