diff --git a/libretroshare/src/dbase/fistore.cc b/libretroshare/src/dbase/fistore.cc index eaf5fb8b9..bd2a345b4 100644 --- a/libretroshare/src/dbase/fistore.cc +++ b/libretroshare/src/dbase/fistore.cc @@ -322,20 +322,32 @@ int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, uint32_t f /* cannot be null -> no files at root level */ parent=file->parent; } + // Well, yes, it can be null, beleive me. In such a case it may be that + // file is a person entry. - /* NEW add path (to dir - if dir, or parent dir - if file? */ - details.path = parent->path; - - while(parent->parent) - parent = parent->parent; - - /* we should end up on the PersonEntry */ - if (NULL == (person = dynamic_cast(parent))) + if(parent==NULL) { - std::cerr << "Major Error- Not PersonEntry!"; - exit(1); + if(NULL == (person = dynamic_cast(file))) + { + std::cerr << "Major Error- Not PersonEntry!"; + exit(1); + } } + else + { + /* NEW add path (to dir - if dir, or parent dir - if file? */ + details.path = parent->path; + while(parent->parent) + parent = parent->parent; + + /* we should end up on the PersonEntry */ + if (NULL == (person = dynamic_cast(parent))) + { + std::cerr << "Major Error- Not PersonEntry!"; + exit(1); + } + } details.id = person->id; } diff --git a/libretroshare/src/pqi/gpgauthmgr.cc b/libretroshare/src/pqi/gpgauthmgr.cc index 2d7b2cea3..86d5b7d0e 100644 --- a/libretroshare/src/pqi/gpgauthmgr.cc +++ b/libretroshare/src/pqi/gpgauthmgr.cc @@ -155,6 +155,7 @@ std::string GPGAuthMgr::OwnId() bool GPGAuthMgr::getAllList(std::list &ids) { + std::cout << "344444555533333333" << std::endl ; std::map::iterator it; for(it = mKeyList.begin(); it != mKeyList.end(); it++) { diff --git a/libretroshare/src/rsiface/rsiface.h b/libretroshare/src/rsiface/rsiface.h index bac572462..215e54f54 100644 --- a/libretroshare/src/rsiface/rsiface.h +++ b/libretroshare/src/rsiface/rsiface.h @@ -202,13 +202,14 @@ class NotifyBase virtual void notifyHashingInfo(std::string fileinfo) { (void)fileinfo; return ; } }; -const int NOTIFY_LIST_NEIGHBOURS = 1; -const int NOTIFY_LIST_FRIENDS = 2; -const int NOTIFY_LIST_DIRLIST = 3; -const int NOTIFY_LIST_SEARCHLIST = 4; -const int NOTIFY_LIST_MESSAGELIST = 5; -const int NOTIFY_LIST_CHANNELLIST = 6; +const int NOTIFY_LIST_NEIGHBOURS = 1; +const int NOTIFY_LIST_FRIENDS = 2; +const int NOTIFY_LIST_DIRLIST = 3; +const int NOTIFY_LIST_SEARCHLIST = 4; +const int NOTIFY_LIST_MESSAGELIST = 5; +const int NOTIFY_LIST_CHANNELLIST = 6; const int NOTIFY_LIST_TRANSFERLIST = 7; +const int NOTIFY_LIST_CONFIG = 8; const int NOTIFY_TYPE_SAME = 0x01; const int NOTIFY_TYPE_MOD = 0x02; /* general purpose, check all */ diff --git a/libretroshare/src/rsserver/p3face-config.cc b/libretroshare/src/rsserver/p3face-config.cc index 3bf9ec936..3f15cbd1d 100644 --- a/libretroshare/src/rsserver/p3face-config.cc +++ b/libretroshare/src/rsserver/p3face-config.cc @@ -141,7 +141,8 @@ int RsServer::UpdateAllConfig() config.DHTActive = mConnMgr->getDHTEnabled(); /* Notify of Changes */ - iface.setChanged(RsIface::Config); +// iface.setChanged(RsIface::Config); + rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CONFIG, NOTIFY_TYPE_MOD); /* unlock Mutexes */ iface.unlockData(); /* UNLOCK */ diff --git a/libretroshare/src/rsserver/p3face-people.cc b/libretroshare/src/rsserver/p3face-people.cc index d2040ffa3..4ed6f9ffa 100644 --- a/libretroshare/src/rsserver/p3face-people.cc +++ b/libretroshare/src/rsserver/p3face-people.cc @@ -480,9 +480,9 @@ void RsServer::intNotifyChangeCert(RsCertId &id) /* send the notify message */ if (mods) { - NotifyBase &cb = getNotify(); - cb.notifyListChange(NOTIFY_LIST_NEIGHBOURS, NOTIFY_TYPE_MOD); - cb.notifyListChange(NOTIFY_LIST_FRIENDS, NOTIFY_TYPE_MOD); + std::cerr << "************** Notifying neighbor change *******************" << std::endl ; + getNotify().notifyListChange(NOTIFY_LIST_NEIGHBOURS, NOTIFY_TYPE_MOD); + getNotify().notifyListChange(NOTIFY_LIST_FRIENDS, NOTIFY_TYPE_MOD); } } @@ -668,6 +668,7 @@ int RsServer::UpdateAllNetwork() { /* PreNotify of the Change */ NotifyBase &cb = getNotify(); + std::cerr << "************** Notifying neighbor change 2 *******************" << std::endl ; cb.notifyListPreChange(NOTIFY_LIST_NEIGHBOURS, NOTIFY_TYPE_MOD); lockRsCore(); /* LOCK */ @@ -709,6 +710,7 @@ int RsServer::UpdateAllNetwork() unlockRsCore(); /* UNLOCK */ /* Now Notify of the Change */ + std::cerr << "************** Notifying neighbor change 3 *******************" << std::endl ; cb.notifyListChange(NOTIFY_LIST_NEIGHBOURS, NOTIFY_TYPE_MOD); return ret; diff --git a/libretroshare/src/serialiser/rsdiscitems.cc b/libretroshare/src/serialiser/rsdiscitems.cc index 5cbe14db3..a28209165 100644 --- a/libretroshare/src/serialiser/rsdiscitems.cc +++ b/libretroshare/src/serialiser/rsdiscitems.cc @@ -352,24 +352,21 @@ bool RsDiscSerialiser::serialiseReply(RsDiscReply *item, void *data, uint32_ offset += 8; /* add mandatory parts first */ - ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset, - TLV_TYPE_IPV4_LOCAL, &(item->laddr)); - ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset, - TLV_TYPE_IPV4_REMOTE, &(item->saddr)); + ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset, TLV_TYPE_IPV4_LOCAL, &(item->laddr)); + ok &= SetTlvIpAddrPortV4(data, tlvsize, &offset, TLV_TYPE_IPV4_REMOTE, &(item->saddr)); ok &= setRawUInt16(data, tlvsize, &offset, item->contact_tf); ok &= setRawUInt32(data, tlvsize, &offset, item->discFlags); - ok &= SetTlvString(data, tlvsize, &offset, - TLV_TYPE_STR_PEERID, item->aboutId); + ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, item->aboutId); ok &= item->certDER.SetTlv(data, tlvsize, &offset); if (offset != tlvsize) { ok = false; -#ifdef RSSERIAL_DEBUG +//#ifdef RSSERIAL_DEBUG std::cerr << "RsDiscSerialiser::serialiseReply() Size Error! " << std::endl; -#endif +//#endif } return ok; diff --git a/libretroshare/src/serialiser/rsmsgitems.cc b/libretroshare/src/serialiser/rsmsgitems.cc index c01bf42b8..0f209ce29 100644 --- a/libretroshare/src/serialiser/rsmsgitems.cc +++ b/libretroshare/src/serialiser/rsmsgitems.cc @@ -93,10 +93,10 @@ bool RsChatSerialiser::serialiseItem(RsChatItem *item, void *data, uint32_t ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize); -#ifdef RSSERIAL_DEBUG +//#ifdef RSSERIAL_DEBUG std::cerr << "RsChatSerialiser::serialiseItem() Header: " << ok << std::endl; std::cerr << "RsChatSerialiser::serialiseItem() Size: " << tlvsize << std::endl; -#endif +//#endif /* skip the header */ offset += 8; @@ -109,10 +109,11 @@ bool RsChatSerialiser::serialiseItem(RsChatItem *item, void *data, uint32_t if (offset != tlvsize) { ok = false; -#ifdef RSSERIAL_DEBUG +//#ifdef RSSERIAL_DEBUG std::cerr << "RsChatSerialiser::serialiseItem() Size Error! " << std::endl; -#endif +//#endif } + std::cerr << "computed size: " << 256*((unsigned char*)data)[6]+((unsigned char*)data)[7] << std::endl ; return ok; } diff --git a/libretroshare/src/serialiser/rsserial.cc b/libretroshare/src/serialiser/rsserial.cc index bafb3588d..6d0e2fe9a 100644 --- a/libretroshare/src/serialiser/rsserial.cc +++ b/libretroshare/src/serialiser/rsserial.cc @@ -371,7 +371,7 @@ bool setRsItemHeader(void *data, uint32_t size, uint32_t type, uint32_t pktsiz uint32_t getRsItemId(void *data) { - uint32_t type; + uint32_t type = 0; uint32_t offset = 0; getRawUInt32(data, 4, &offset, &type); return type; @@ -380,7 +380,7 @@ uint32_t getRsItemId(void *data) uint32_t getRsItemSize(void *data) { - uint32_t size; + uint32_t size = 0; uint32_t offset = 4; getRawUInt32(data, 8, &offset, &size); return size; diff --git a/libretroshare/src/services/forum_test.cc b/libretroshare/src/services/forum_test.cc index c7a8e8421..f4e3fb653 100644 --- a/libretroshare/src/services/forum_test.cc +++ b/libretroshare/src/services/forum_test.cc @@ -75,13 +75,14 @@ int main(int argc, char **argv) } /* cleanup */ - CRYPTO_cleanup_all_ex_data(); - ERR_free_strings(); - ERR_remove_state(0); - EVP_cleanup(); - //CRYPTO_mem_leaks(bio_err); - if (bio_err != NULL) BIO_free(bio_err); + CRYPTO_cleanup_all_ex_data(); + ERR_free_strings(); + ERR_remove_state(0); + EVP_cleanup(); + //CRYPTO_mem_leaks(bio_err); + if (bio_err != NULL) BIO_free(bio_err); + return 1; } @@ -146,5 +147,6 @@ int testForums(p3Forums *forum) #else sleep(1); #endif + return 1 ; } diff --git a/libretroshare/src/services/p3chatservice.cc b/libretroshare/src/services/p3chatservice.cc index 814f6f5f7..cf4f778af 100644 --- a/libretroshare/src/services/p3chatservice.cc +++ b/libretroshare/src/services/p3chatservice.cc @@ -109,19 +109,25 @@ int p3ChatService::sendChat(std::wstring msg) class p3ChatService::AvatarInfo { public: + AvatarInfo() + { + _peer_is_new = false ; // true when the peer has a new avatar + _own_is_new = false ; // true when I myself a new avatar to send to this peer. + } + AvatarInfo(const unsigned char *jpeg_data,int size) { int n_c = size ; - int p = sizeof(wchar_t) ; + int p = 2 ;// minimum value for sizeof(wchar_t) over win/mac/linux ; int n = n_c/p + 1 ; _jpeg_wstring = std::wstring(n,0) ; for(int i=0;i=0;--j) { h = h << 8 ; h += jpeg_data[p*i+j] ; @@ -135,7 +141,7 @@ class p3ChatService::AvatarInfo void toUnsignedChar(unsigned char *& data,int& size) const { - int p = sizeof(wchar_t) ; + int p = 2 ;// minimum value for sizeof(wchar_t) over win/mac/linux ; int n = _jpeg_wstring.size() ; int n_c = p*n ; @@ -146,7 +152,7 @@ class p3ChatService::AvatarInfo { wchar_t h = _jpeg_wstring[i] ; - for(int j=p-1;j>=0;--j) + for(int j=0;j> 8 ; @@ -177,16 +183,23 @@ int p3ChatService::sendPrivateChat(std::wstring msg, std::string id) std::map::iterator it = _avatars.find(id) ; + if(it == _avatars.end()) + { + _avatars[id] = new AvatarInfo ; + it = _avatars.find(id) ; + } if(it != _avatars.end() && it->second->_own_is_new) { +#ifdef CHAT_DEBUG std::cerr << "p3ChatService::sendPrivateChat: new avatar never sent to peer " << id << ". Setting flag to packet." << std::endl; +#endif ci->chatFlags |= RS_CHAT_FLAG_AVATAR_AVAILABLE ; it->second->_own_is_new = false ; } - std::cerr << "Sending msg to peer " << id << ", flags = " << ci->chatFlags << std::endl ; #ifdef CHAT_DEBUG + std::cerr << "Sending msg to peer " << id << ", flags = " << ci->chatFlags << std::endl ; std::cerr << "p3ChatService::sendPrivateChat() Item:"; std::cerr << std::endl; ci->print(std::cerr); @@ -212,8 +225,8 @@ std::list p3ChatService::getChatQueue() std::cerr << std::endl; ci->print(std::cerr); std::cerr << std::endl; -#endif std::cerr << "Got msg. Flags = " << ci->chatFlags << std::endl ; +#endif if(ci->chatFlags & RS_CHAT_FLAG_CONTAINS_AVATAR) // no msg here. Just an avatar. receiveAvatarJpegData(ci) ; diff --git a/libretroshare/src/services/p3disc.cc b/libretroshare/src/services/p3disc.cc index d33f8dc6c..00c63783f 100644 --- a/libretroshare/src/services/p3disc.cc +++ b/libretroshare/src/services/p3disc.cc @@ -24,6 +24,7 @@ */ +#include "rsiface/rsiface.h" #include "rsiface/rspeers.h" #include "services/p3disc.h" @@ -298,13 +299,13 @@ void p3disc::sendOwnDetails(std::string to) // Then send message. { -//#ifdef P3DISC_DEBUG +#ifdef P3DISC_DEBUG std::ostringstream out; out << "p3disc::sendOwnDetails()"; out << "Constructing a RsDiscItem Message!" << std::endl; out << "Sending to: " << to; std::cerr << out.str() << std::endl; -//#endif +#endif } // Construct a message @@ -370,13 +371,13 @@ void p3disc::sendPeerDetails(std::string to, std::string about) /* send it off */ { -//#ifdef P3DISC_DEBUG +#ifdef P3DISC_DEBUG std::ostringstream out; out << "p3disc::sendPeerDetails()"; out << " Sending details of: " << about; out << " to: " << to << std::endl; std::cerr << out.str() << std::endl; -//#endif +#endif } @@ -447,13 +448,19 @@ void p3disc::sendPeerDetails(std::string to, std::string about) if(*it == name) { di->discFlags |= P3DISC_FLAGS_PEER_TRUSTS_ME; +#ifdef P3DISC_DEBUG std::cerr << " Peer " << about << "(" << name << ")" << " is trusting " << to << ", sending info." << std::endl ; +#endif } uint32_t certLen = 0; unsigned char **binptr = (unsigned char **) &(di -> certDER.bin_data); + mAuthMgr->SaveCertificateToBinary(about, binptr, &certLen); +#ifdef P3DISC_DEBUG + std::cerr << "Saved certificate to binary in p3discReply. Length=" << certLen << std::endl ; +#endif if (certLen > 0) { di -> certDER.bin_len = certLen; @@ -483,9 +490,9 @@ void p3disc::sendPeerDetails(std::string to, std::string about) /*************************************************************************************/ void p3disc::recvPeerOwnMsg(RsDiscItem *item) { -//#ifdef P3DISC_DEBUG +#ifdef P3DISC_DEBUG std::cerr << "p3disc::recvPeerOwnMsg() From: " << item->PeerId() << std::endl; -//#endif +#endif /* tells us their exact address (mConnectMgr can ignore if it looks wrong) */ uint32_t type = 0; @@ -530,8 +537,7 @@ void p3disc::recvPeerOwnMsg(RsDiscItem *item) /* now reply with all details */ respondToPeer(item->PeerId()); - addDiscoveryData(item->PeerId(), item->PeerId(), - item->laddr, item->saddr, item->discFlags, time(NULL)); + addDiscoveryData(item->PeerId(), item->PeerId(), item->laddr, item->saddr, item->discFlags, time(NULL)); /* cleanup (handled by caller) */ } @@ -540,11 +546,11 @@ void p3disc::recvPeerOwnMsg(RsDiscItem *item) void p3disc::recvPeerFriendMsg(RsDiscReply *item) { -//#ifdef P3DISC_DEBUG +#ifdef P3DISC_DEBUG std::cerr << "p3disc::recvPeerFriendMsg() From: " << item->PeerId(); std::cerr << " About " << item->aboutId; std::cerr << std::endl; -//#endif +#endif /* tells us their exact address (mConnectMgr can ignore if it looks wrong) */ @@ -595,6 +601,8 @@ void p3disc::recvPeerFriendMsg(RsDiscReply *item) addDiscoveryData(item->PeerId(), peerId, item->laddr, item->saddr, item->discFlags, time(NULL)); + rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_NEIGHBOURS, NOTIFY_TYPE_MOD); + /* cleanup (handled by caller) */ } @@ -604,8 +612,7 @@ void p3disc::recvPeerFriendMsg(RsDiscReply *item) /*************************************************************************************/ -int p3disc::addDiscoveryData(std::string fromId, std::string aboutId, - struct sockaddr_in laddr, struct sockaddr_in raddr, uint32_t flags, time_t ts) +int p3disc::addDiscoveryData(std::string fromId, std::string aboutId, struct sockaddr_in laddr, struct sockaddr_in raddr, uint32_t flags, time_t ts) { RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 5a8dedc58..60019f9c7 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -24,6 +24,8 @@ */ +#include "rsiface/rsiface.h" + #include "pqi/pqibin.h" #include "pqi/pqiarchive.h" #include "pqi/p3connmgr.h" @@ -121,8 +123,11 @@ int p3MsgService::incomingMsgs() { RsMsgItem *mi; int i = 0; + bool changed = false ; + while((mi = (RsMsgItem *) recvItem()) != NULL) { + changed = true ; ++i; mi -> recvTime = time(NULL); mi -> msgFlags = RS_MSG_FLAGS_NEW; @@ -162,6 +167,9 @@ int p3MsgService::incomingMsgs() /**** STACK UNLOCKED ***/ } + if(changed) + rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD); + return 1; } @@ -472,56 +480,70 @@ bool p3MsgService::removeMsgId(std::string mid) { std::map::iterator mit; uint32_t msgId = atoi(mid.c_str()); + bool changed = false ; - RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ - - mit = imsg.find(msgId); - if (mit != imsg.end()) { - RsMsgItem *mi = mit->second; - imsg.erase(mit); - delete mi; - msgChanged.IndicateChanged(); + RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ - IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ + mit = imsg.find(msgId); + if (mit != imsg.end()) + { + changed = true ; + RsMsgItem *mi = mit->second; + imsg.erase(mit); + delete mi; + // msgChanged.IndicateChanged(); - return true; + IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ + + return true; + } + + mit = msgOutgoing.find(msgId); + if (mit != msgOutgoing.end()) + { + changed = true ; + RsMsgItem *mi = mit->second; + msgOutgoing.erase(mit); + delete mi; + // msgChanged.IndicateChanged(); + + IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ + + return true; + } } - mit = msgOutgoing.find(msgId); - if (mit != msgOutgoing.end()) - { - RsMsgItem *mi = mit->second; - msgOutgoing.erase(mit); - delete mi; - msgChanged.IndicateChanged(); - - IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - - return true; - } + if(changed) + rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD); return false; } bool p3MsgService::markMsgIdRead(std::string mid) { - std::map::iterator mit; + std::map::iterator mit; uint32_t msgId = atoi(mid.c_str()); + bool changed = false ; - RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ - - mit = imsg.find(msgId); - if (mit != imsg.end()) { - RsMsgItem *mi = mit->second; - mi -> msgFlags &= ~(RS_MSG_FLAGS_NEW); - msgChanged.IndicateChanged(); - - IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - return true; + RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ + + mit = imsg.find(msgId); + if (mit != imsg.end()) + { + changed = true ; + RsMsgItem *mi = mit->second; + mi -> msgFlags &= ~(RS_MSG_FLAGS_NEW); + + IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ + } } - return false; + + if(changed) // no need to notify, because the msg is always + return true; // marked as read from the gui itself, so the gui + else // can mark it as read. + return false; } /****************************************/ diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index 5f344da90..b2e1305dc 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -85,7 +85,7 @@ ForumsDialog::ForumsDialog(QWidget *parent) // SLOT( changedThread( QTreeWidgetItem *, QTreeWidgetItem * ) ) ); connect( ui.threadTreeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( changedThread2() ) ); - connect( ui.viewBox, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( changedThread2() ) ); + connect( ui.viewBox, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( insertThreads() ) ); connect(ui.expandButton, SIGNAL(clicked()), this, SLOT(togglefileview())); diff --git a/retroshare-gui/src/gui/ForumsDialog.h b/retroshare-gui/src/gui/ForumsDialog.h index d8ed5bc32..89dd24496 100644 --- a/retroshare-gui/src/gui/ForumsDialog.h +++ b/retroshare-gui/src/gui/ForumsDialog.h @@ -33,11 +33,11 @@ public: ForumsDialog(QWidget *parent = 0); void insertForums(); - void insertThreads(); void insertPost(); private slots: + void insertThreads(); /** Create the context popup menu and it's submenus */ void forumListCustomPopupMenu( QPoint point ); void threadListCustomPopupMenu( QPoint point ); diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 4585e7d7c..5a4f7e34e 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -65,7 +65,7 @@ MessagesDialog::MessagesDialog(QWidget *parent) connect( ui.msgWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) ); - connect( ui.msgWidget, SIGNAL( itemClicked ( QTreeWidgetItem *, int) ), this, SLOT( updateMessages ( QTreeWidgetItem *, int) ) ); + connect( ui.msgWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem *,QTreeWidgetItem * ) ), this, SLOT( updateCurrentMessage( QTreeWidgetItem *, QTreeWidgetItem *) ) ); connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) ); connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage())); @@ -448,11 +448,9 @@ void MessagesDialog::getallrecommended() } } -void MessagesDialog::changeBox( int newrow ) +void MessagesDialog::changeBox(int) { - //std::cerr << "MessagesDialog::changeBox()" << std::endl; - insertMessages(); - insertMsgTxtAndFiles(); + insertMessages(); // show current msg list } void MessagesDialog::insertMessages() @@ -463,7 +461,7 @@ void MessagesDialog::insertMessages() rsMsgs -> getMessageSummaries(msgList); /* get a link to the table */ - QTreeWidget *msgWidget = ui.msgWidget; + QTreeWidget *msgWidget = ui.msgWidget; /* get the MsgId of the current one ... */ @@ -500,7 +498,7 @@ void MessagesDialog::insertMessages() break; } - QList items; + QList items; for(it = msgList.begin(); it != msgList.end(); it++) { /* check the message flags, to decide which @@ -529,7 +527,7 @@ void MessagesDialog::insertMessages() } /* make a widget per friend */ - QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); + QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); /* So Text should be: * (1) Msg / Broadcast @@ -581,7 +579,7 @@ void MessagesDialog::insertMessages() QFont qf = item->font(i); qf.setBold(true); item->setFont(i, qf); - item -> setIcon(2, (QIcon(":/images/message-mail.png"))); + item -> setIcon(2, (QIcon(":/images/message-mail.png"))); //std::cerr << "Setting Item BOLD!" << std::endl; } @@ -601,12 +599,27 @@ void MessagesDialog::insertMessages() } } -void MessagesDialog::updateMessages( QTreeWidgetItem * item, int column ) +void MessagesDialog::updateCurrentMessage( QTreeWidgetItem *item , QTreeWidgetItem * ) { - //std::cerr << "MessagesDialog::insertMsgTxtAndFiles()" << std::endl; insertMsgTxtAndFiles(); + setMsgAsRead(item) ; } +void MessagesDialog::setMsgAsRead(QTreeWidgetItem *item) +{ + if(item == NULL) + return ; + + for(int i = 0; i < 10; i++) + { + QFont qf = item->font(i); + qf.setBold(false); + item->setFont(i, qf); + } + + std::string mid(item->text(5).toStdString()); + rsMsgs->MessageRead(mid); +} void MessagesDialog::insertMsgTxtAndFiles() { @@ -654,7 +667,7 @@ void MessagesDialog::insertMsgTxtAndFiles() return; } - const std::list &recList = msgInfo.files; + const std::list &recList = msgInfo.files; std::list::const_iterator it; /* get a link to the table */ @@ -662,18 +675,18 @@ void MessagesDialog::insertMsgTxtAndFiles() /* get the MessageInfo */ - tree->clear(); - tree->setColumnCount(5); + tree->clear(); + tree->setColumnCount(5); - QList items; + QList items; for(it = recList.begin(); it != recList.end(); it++) { /* make a widget per person */ - QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); + QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); /* (0) Filename */ item -> setText(0, QString::fromStdString(it->fname)); //std::cerr << "Msg FileItem(" << it->fname.length() << ") :" << it->fname << std::endl; - + /* (1) Size */ { std::ostringstream out; @@ -686,9 +699,9 @@ void MessagesDialog::insertMsgTxtAndFiles() out << it->rank; item -> setText(2, QString::fromStdString(out.str())); } - + item -> setText(3, QString::fromStdString(it->hash)); - + /* add to the list */ items.append(item); } @@ -747,12 +760,8 @@ void MessagesDialog::insertMsgTxtAndFiles() } std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Msg Displayed OK!" << std::endl; - - /* finally mark message as read! */ - rsMsgs -> MessageRead(mid); } - bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid) { /* Locate the current Message */ @@ -774,39 +783,21 @@ bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid) void MessagesDialog::removemessage() { -#ifdef TO_REMOVE - //std::cerr << "MessagesDialog::removemessage()" << std::endl; - std::string cid, mid; - if (!getCurrentMsg(cid, mid)) - { - //std::cerr << "MessagesDialog::removemessage()"; - //std::cerr << " No Message selected" << std::endl; - return; - } -#endif - QList list(ui.msgWidget->selectedItems()) ; + int maxrow = -1 ; + for(QList::const_iterator it(list.begin());it!=list.end();++it) + maxrow = std::max(maxrow,ui.msgWidget->indexOfTopLevelItem(*it)) ; + + QTreeWidgetItem *next = ui.msgWidget->topLevelItem(maxrow+1) ; + for(QList::const_iterator it(list.begin());it!=list.end();++it) rsMsgs->MessageDelete((*it)->text(5).toStdString()); - return; -} - - -void MessagesDialog::markMsgAsRead() -{ - //std::cerr << "MessagesDialog::markMsgAsRead()" << std::endl; - std::string cid, mid; - if (!getCurrentMsg(cid, mid)) - { - //std::cerr << "MessagesDialog::markMsgAsRead()"; - //std::cerr << " No Message selected" << std::endl; - return; - } - - rsMsgs -> MessageRead(mid); + if(next != NULL) + ui.msgWidget->setCurrentItem(next) ; + insertMessages(); return; } diff --git a/retroshare-gui/src/gui/MessagesDialog.h b/retroshare-gui/src/gui/MessagesDialog.h index d7dd9a973..e682ba010 100644 --- a/retroshare-gui/src/gui/MessagesDialog.h +++ b/retroshare-gui/src/gui/MessagesDialog.h @@ -35,21 +35,19 @@ public: /** Default Constructor */ MessagesDialog(QWidget *parent = 0); /** Default Destructor */ - - - void insertMessages(); void insertMsgTxtAndFiles(); - - virtual void keyPressEvent(QKeyEvent *) ; + +public slots: + void insertMessages(); private slots: /** Create the context popup menu and it's submenus */ void messageslistWidgetCostumPopupMenu( QPoint point ); void msgfilelistWidgetCostumPopupMenu(QPoint); -void changeBox( int newrow ); -void updateMessages ( QTreeWidgetItem * item, int column ); + void changeBox( int newrow ); + void updateCurrentMessage ( QTreeWidgetItem * item, QTreeWidgetItem * item2 ); void newmessage(); @@ -61,7 +59,6 @@ void updateMessages ( QTreeWidgetItem * item, int column ); void printpreview(); void removemessage(); - void markMsgAsRead(); void getcurrentrecommended(); void getallrecommended(); @@ -72,6 +69,7 @@ void updateMessages ( QTreeWidgetItem * item, int column ); private: bool getCurrentMsg(std::string &cid, std::string &mid); + void setMsgAsRead(QTreeWidgetItem *); std::string mCurrCertId; std::string mCurrMsgId; diff --git a/retroshare-gui/src/gui/MessengerWindow.h b/retroshare-gui/src/gui/MessengerWindow.h index 0cbb48d30..2e9b7802d 100644 --- a/retroshare-gui/src/gui/MessengerWindow.h +++ b/retroshare-gui/src/gui/MessengerWindow.h @@ -42,7 +42,6 @@ public: MessengerWindow(QWidget *parent = 0, Qt::WFlags flags = 0); /** Default Destructor */ - void insertPeers(); void setChatDialog(PeersDialog *cd); NetworkDialog *networkDialog2; @@ -51,6 +50,7 @@ public: public slots: + void insertPeers(); /** Called when this dialog is to be displayed */ void show(); diff --git a/retroshare-gui/src/gui/NetworkDialog.h b/retroshare-gui/src/gui/NetworkDialog.h index 43957d648..64c9bdf59 100644 --- a/retroshare-gui/src/gui/NetworkDialog.h +++ b/retroshare-gui/src/gui/NetworkDialog.h @@ -42,10 +42,10 @@ public: NetworkDialog(QWidget *parent = 0); /** Default Destructor */ - void insertConnect(); void showpeerdetails(std::string id); public slots: + void insertConnect(); std::string loadneighbour(); /* void loadneighbour(); */ void setLogInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText)); diff --git a/retroshare-gui/src/gui/PeersDialog.h b/retroshare-gui/src/gui/PeersDialog.h index 2bab4dd53..30cea8d86 100644 --- a/retroshare-gui/src/gui/PeersDialog.h +++ b/retroshare-gui/src/gui/PeersDialog.h @@ -48,13 +48,11 @@ public: void clearOldChats(); void loadEmoticonsgroupchat(); - - void insertPeers(); - void setChatDialog(ChatDialog *cd); public slots: + void insertPeers(); void toggleSendItem( QTreeWidgetItem *item, int col ); void insertChat(); diff --git a/retroshare-gui/src/gui/TransfersDialog.cpp b/retroshare-gui/src/gui/TransfersDialog.cpp index c22cb9053..22bb3ada5 100644 --- a/retroshare-gui/src/gui/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/TransfersDialog.cpp @@ -70,6 +70,7 @@ TransfersDialog::TransfersDialog(QWidget *parent) DLDelegate = new DLListDelegate(); ui.downloadList->setItemDelegate(DLDelegate); + ui.downloadList->setAutoScroll(false) ; //Selection Setup selection = ui.downloadList->selectionModel(); @@ -108,6 +109,7 @@ TransfersDialog::TransfersDialog(QWidget *parent) ULDelegate = new ULListDelegate(); ui.uploadsList->setItemDelegate(ULDelegate); + ui.uploadsList->setAutoScroll(false) ; ui.uploadsList->setRootIsDecorated(false); //Selection Setup diff --git a/retroshare-gui/src/gui/TransfersDialog.h b/retroshare-gui/src/gui/TransfersDialog.h index ae792290f..f37ab479f 100644 --- a/retroshare-gui/src/gui/TransfersDialog.h +++ b/retroshare-gui/src/gui/TransfersDialog.h @@ -39,35 +39,33 @@ class QStandardItemModel; class TransfersDialog : public MainPage { - Q_OBJECT + Q_OBJECT -public: - /** Default Constructor */ - TransfersDialog(QWidget *parent = 0); - /** Default Destructor */ - ~TransfersDialog(); + public: + /** Default Constructor */ + TransfersDialog(QWidget *parent = 0); + /** Default Destructor */ + ~TransfersDialog(); + public slots: + void insertTransfers(); + private slots: + /** Create the context popup menu and it's submenus */ + void downloadListCostumPopupMenu( QPoint point ); - void insertTransfers(); + void cancel(); + /** removes finished Downloads**/ + void clearcompleted(); + void playSelectedTransfer(); -private slots: - - /** Create the context popup menu and it's submenus */ - void downloadListCostumPopupMenu( QPoint point ); - - void cancel(); - /** removes finished Downloads**/ - void clearcompleted(); - void playSelectedTransfer(); + signals: + void playFiles(QStringList files); -signals: - void playFiles(QStringList files); - -private: - QStandardItemModel *DLListModel; - QStandardItemModel *ULListModel; + private: + QStandardItemModel *DLListModel; + QStandardItemModel *ULListModel; QItemSelectionModel *selection; DLListDelegate *DLDelegate; ULListDelegate *ULDelegate; @@ -78,26 +76,26 @@ private: qlonglong completed, remaining; - /** Create the actions on the tray menu or menubar */ - void createActions(); + /** Create the actions on the tray menu or menubar */ + void createActions(); - /** Define the popup menus for the Context menu */ - QMenu* contextMnu; - /** Defines the actions for the context menu */ - QAction* showdowninfoAct; - QAction* cancelAct; - QAction* clearcompletedAct; + /** Define the popup menus for the Context menu */ + QMenu* contextMnu; + /** Defines the actions for the context menu */ + QAction* showdowninfoAct; + QAction* cancelAct; + QAction* clearcompletedAct; - QTreeView *downloadList; + QTreeView *downloadList; - /** Adds a new action to the toolbar. */ - void addAction(QAction *action, const char *slot = 0); + /** Adds a new action to the toolbar. */ + void addAction(QAction *action, const char *slot = 0); - /** Qt Designer generated object */ - Ui::TransfersDialog ui; - -public slots: - int addItem(QString symbol, QString name, QString coreID, qlonglong size, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining); + /** Qt Designer generated object */ + Ui::TransfersDialog ui; + + public slots: + int addItem(QString symbol, QString name, QString coreID, qlonglong size, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining); void delItem(int row); int addUploadItem(QString symbol, QString name, QString coreID, qlonglong size, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining); @@ -105,7 +103,7 @@ public slots: void editItem(int row, int column, QVariant data); void updateProgress(int value); - + double getProgress(int row, QStandardItemModel *model); double getSpeed(int row, QStandardItemModel *model); QString getFileName(int row, QStandardItemModel *model); diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 054183f21..814cb2352 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -152,9 +152,15 @@ int main(int argc, char *argv[]) // I'm using a signal to transfer the hashing info to the mainwindow, because Qt schedules signals properly to // avoid clashes between infos from threads. // - QObject::connect(notify,SIGNAL(hashingInfo(const QString&)),w,SLOT(updateHashingInfo(const QString&))) ; - QObject::connect(notify,SIGNAL(filesPreMod( bool)),w->sharedfilesDialog,SLOT(preModDirectories(bool))) ; - QObject::connect(notify,SIGNAL(filesPostMod( bool)),w->sharedfilesDialog,SLOT(postModDirectories(bool))) ; + QObject::connect(notify,SIGNAL(hashingInfoChanged(const QString&)),w ,SLOT(updateHashingInfo(const QString&))) ; + QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->sharedfilesDialog,SLOT(preModDirectories(bool) )) ; + QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog,SLOT(postModDirectories(bool) )) ; + QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; + QObject::connect(notify,SIGNAL(friendsChanged()) ,w->messengerWindow ,SLOT(insertPeers() )) ; + QObject::connect(notify,SIGNAL(friendsChanged()) ,w->peersDialog ,SLOT(insertPeers() )) ; + QObject::connect(notify,SIGNAL(neighborsChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ; + QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ; + QObject::connect(notify,SIGNAL(configChanged()) ,w->messagesDialog ,SLOT(displayConfig() )) ; /* only show window, if not startMinimized */ if (!startMinimised) diff --git a/retroshare-gui/src/rsiface/notifyqt.cpp b/retroshare-gui/src/rsiface/notifyqt.cpp index 933dd3360..63d33145c 100644 --- a/retroshare-gui/src/rsiface/notifyqt.cpp +++ b/retroshare-gui/src/rsiface/notifyqt.cpp @@ -38,7 +38,7 @@ void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) void NotifyQt::notifyHashingInfo(std::string fileinfo) { - emit hashingInfo(QString::fromStdString(fileinfo)) ; + emit hashingInfoChanged(QString::fromStdString(fileinfo)) ; } void NotifyQt::notifyChat() @@ -56,27 +56,30 @@ void NotifyQt::notifyListChange(int list, int type) switch(list) { case NOTIFY_LIST_NEIGHBOURS: - //displayNeighbours(); + emit neighborsChanged(); break; case NOTIFY_LIST_FRIENDS: - //displayFriends(); + emit friendsChanged() ; break; case NOTIFY_LIST_DIRLIST: - emit filesPostMod(false) ; /* Remote */ - emit filesPostMod(true) ; /* Local */ + emit filesPostModChanged(false) ; /* Remote */ + emit filesPostModChanged(true) ; /* Local */ break; case NOTIFY_LIST_SEARCHLIST: //displaySearch(); break; case NOTIFY_LIST_MESSAGELIST: - //displayMessages(); + emit messagesChanged() ; break; case NOTIFY_LIST_CHANNELLIST: //displayChannels(); break; case NOTIFY_LIST_TRANSFERLIST: - //displayTransfers(); + emit transfersChanged() ; break; + case NOTIFY_LIST_CONFIG: + emit configChanged() ; + break ; default: break; } @@ -95,11 +98,11 @@ void NotifyQt::notifyListPreChange(int list, int type) //preDisplayNeighbours(); break; case NOTIFY_LIST_FRIENDS: - //preDisplayFriends(); + emit friendsChanged() ; break; case NOTIFY_LIST_DIRLIST: - emit filesPreMod(false) ; /* remote */ - emit filesPreMod(true) ; /* local */ + emit filesPreModChanged(false) ; /* remote */ + emit filesPreModChanged(true) ; /* local */ break; case NOTIFY_LIST_SEARCHLIST: //preDisplaySearch(); @@ -127,63 +130,31 @@ void NotifyQt::notifyListPreChange(int list, int type) void NotifyQt::UpdateGUI() { - iface->lockData(); /* Lock Interface */ - - /* make local -> so we can release iface */ - bool uNeigh = iface->hasChanged(RsIface::Neighbour); - bool uFri = iface->hasChanged(RsIface::Friend); - bool uTrans = iface->hasChanged(RsIface::Transfer); - //bool uChat = iface->hasChanged(RsIface::Chat); - bool uMsg = iface->hasChanged(RsIface::Message); - bool uChan = iface->hasChanged(RsIface::Channel); - bool uRecom = iface->hasChanged(RsIface::Recommend); - bool uConf = iface->hasChanged(RsIface::Config); - - iface->unlockData(); /* UnLock Interface */ - /* hack to force updates until we've fixed that part */ -static time_t lastTs = 0; + static time_t lastTs = 0; - if (time(NULL) > lastTs + 5) + if (time(NULL) > lastTs) // always update, every 1 sec. { - lastTs = time(NULL); - - uNeigh = true; - uFri = true; - uTrans = true; - //uChat = true; - uMsg = true; - uChan = true; - uRecom = true; - uConf = true; + emit transfersChanged(); + emit friendsChanged() ; } - if (uNeigh) - displayNeighbours(); - - if (uFri) - displayFriends(); - - if (uTrans) - displayTransfers(); - - //if (uChat) - // displayChat(); - - if (uMsg) - displayMessages(); - - if (uChan) + if (time(NULL) > lastTs + 5) // update every 5 seconds. I don't know what to do with these. + { displayChannels(); + } + + static bool already_updated = false ; // these only update once at start because they may already have been set before + // the gui is running, then they get updated by callbacks. + if(!already_updated) + { + emit messagesChanged() ; + emit neighborsChanged(); + emit configChanged(); + + already_updated = true ; + } - /* TODO - if (uRecom) - displayRecommends(); - - if (uConf) - displayConfig(); - */ - /* Finally Check for PopupMessages / System Error Messages */ if (rsNotify) @@ -265,22 +236,6 @@ static time_t lastTs = 0; } } - -void NotifyQt::displayNeighbours() -{ - /* Do the GUI */ - if (cDialog) - cDialog->insertConnect(); -} - -void NotifyQt::displayFriends() -{ - if (pDialog) - pDialog->insertPeers(); - if (mWindow) - mWindow->insertPeers(); -} - void NotifyQt::displaySearch() { iface->lockData(); /* Lock Interface */ @@ -293,13 +248,6 @@ void NotifyQt::displaySearch() iface->unlockData(); /* UnLock Interface */ } - -void NotifyQt::displayMessages() -{ - if (mDialog) - mDialog -> insertMessages(); -} - void NotifyQt::displayChat() { iface->lockData(); /* Lock Interface */ diff --git a/retroshare-gui/src/rsiface/notifyqt.h b/retroshare-gui/src/rsiface/notifyqt.h index c2de85b49..39d3c414d 100644 --- a/retroshare-gui/src/rsiface/notifyqt.h +++ b/retroshare-gui/src/rsiface/notifyqt.h @@ -51,9 +51,14 @@ class NotifyQt: public QObject, public NotifyBase // It's beneficial to send info to the GUI using signals, because signals are thread-safe // as they get queued by Qt. // - void hashingInfo(const QString&) const ; - void filesPreMod(bool) const ; - void filesPostMod(bool) const ; + void hashingInfoChanged(const QString&) const ; + void filesPreModChanged(bool) const ; + void filesPostModChanged(bool) const ; + void transfersChanged() const ; + void friendsChanged() const ; + void neighborsChanged() const ; + void messagesChanged() const ; + void configChanged() const ; public slots: diff --git a/retroshare-gui/src/rsiface/rsiface.h b/retroshare-gui/src/rsiface/rsiface.h index bac572462..215e54f54 100644 --- a/retroshare-gui/src/rsiface/rsiface.h +++ b/retroshare-gui/src/rsiface/rsiface.h @@ -202,13 +202,14 @@ class NotifyBase virtual void notifyHashingInfo(std::string fileinfo) { (void)fileinfo; return ; } }; -const int NOTIFY_LIST_NEIGHBOURS = 1; -const int NOTIFY_LIST_FRIENDS = 2; -const int NOTIFY_LIST_DIRLIST = 3; -const int NOTIFY_LIST_SEARCHLIST = 4; -const int NOTIFY_LIST_MESSAGELIST = 5; -const int NOTIFY_LIST_CHANNELLIST = 6; +const int NOTIFY_LIST_NEIGHBOURS = 1; +const int NOTIFY_LIST_FRIENDS = 2; +const int NOTIFY_LIST_DIRLIST = 3; +const int NOTIFY_LIST_SEARCHLIST = 4; +const int NOTIFY_LIST_MESSAGELIST = 5; +const int NOTIFY_LIST_CHANNELLIST = 6; const int NOTIFY_LIST_TRANSFERLIST = 7; +const int NOTIFY_LIST_CONFIG = 8; const int NOTIFY_TYPE_SAME = 0x01; const int NOTIFY_TYPE_MOD = 0x02; /* general purpose, check all */