mirror of
				https://github.com/RetroShare/RetroShare.git
				synced 2025-10-30 14:19:14 -04:00 
			
		
		
		
	in ChatLobbyWidget: show dialog to create a new identity when there is no own identity
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8269 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
		
							parent
							
								
									789b76f7b4
								
							
						
					
					
						commit
						699dc50b3f
					
				
					 8 changed files with 70 additions and 23 deletions
				
			
		|  | @ -1578,13 +1578,11 @@ bool DistributedChatService::setDefaultIdentityForChatLobby(const RsGxsId& nick) | |||
| 	triggerConfigSave() ; | ||||
| 	return true ; | ||||
| } | ||||
| bool DistributedChatService::getDefaultIdentityForChatLobby(RsGxsId& nick) | ||||
| void DistributedChatService::getDefaultIdentityForChatLobby(RsGxsId& nick) | ||||
| { | ||||
|     RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ | ||||
| 
 | ||||
|     nick = locked_getDefaultIdentity() ; | ||||
| 
 | ||||
|     return true ; | ||||
| } | ||||
| 
 | ||||
| RsGxsId DistributedChatService::locked_getDefaultIdentity() | ||||
|  |  | |||
|  | @ -71,7 +71,7 @@ class DistributedChatService | |||
|         bool setIdentityForChatLobby(const ChatLobbyId& lobby_id,const RsGxsId& nick) ; | ||||
|         bool getIdentityForChatLobby(const ChatLobbyId& lobby_id,RsGxsId& nick) ; | ||||
|         bool setDefaultIdentityForChatLobby(const RsGxsId& nick) ; | ||||
|         bool getDefaultIdentityForChatLobby(RsGxsId& nick) ; | ||||
|         void getDefaultIdentityForChatLobby(RsGxsId& nick) ; | ||||
| 		void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe); | ||||
| 		bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id); | ||||
| 		void sendLobbyStatusString(const ChatLobbyId& id,const std::string& status_string) ; | ||||
|  |  | |||
|  | @ -471,7 +471,7 @@ virtual void unsubscribeChatLobby(const ChatLobbyId& lobby_id) = 0; | |||
| virtual bool setIdentityForChatLobby(const ChatLobbyId& lobby_id,const RsGxsId& nick) = 0; | ||||
| virtual bool getIdentityForChatLobby(const ChatLobbyId& lobby_id,RsGxsId& nick) = 0 ; | ||||
| virtual bool setDefaultIdentityForChatLobby(const RsGxsId& nick) = 0; | ||||
| virtual bool getDefaultIdentityForChatLobby(RsGxsId& id) = 0 ; | ||||
| virtual void getDefaultIdentityForChatLobby(RsGxsId& id) = 0 ; | ||||
|     virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe) = 0 ; | ||||
|     virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id) = 0 ; | ||||
| virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::set<RsPeerId>& invited_friends,ChatLobbyFlags lobby_privacy_type) = 0 ; | ||||
|  |  | |||
|  | @ -471,9 +471,9 @@ bool p3Msgs::setDefaultIdentityForChatLobby(const RsGxsId& nick) | |||
| { | ||||
|     return mChatSrv->setDefaultIdentityForChatLobby(nick) ; | ||||
| } | ||||
| bool p3Msgs::getDefaultIdentityForChatLobby(RsGxsId& nick_name) | ||||
| void p3Msgs::getDefaultIdentityForChatLobby(RsGxsId& nick_name) | ||||
| { | ||||
|     return mChatSrv->getDefaultIdentityForChatLobby(nick_name) ; | ||||
|     mChatSrv->getDefaultIdentityForChatLobby(nick_name) ; | ||||
| } | ||||
| 
 | ||||
| bool p3Msgs::setIdentityForChatLobby(const ChatLobbyId& lobby_id,const RsGxsId& nick) | ||||
|  |  | |||
|  | @ -150,7 +150,7 @@ class p3Msgs: public RsMsgs | |||
|       virtual bool setIdentityForChatLobby(const ChatLobbyId& lobby_id,const RsGxsId&) ; | ||||
|       virtual bool getIdentityForChatLobby(const ChatLobbyId&,RsGxsId& nick) ; | ||||
|       virtual bool setDefaultIdentityForChatLobby(const RsGxsId&) ; | ||||
|       virtual bool getDefaultIdentityForChatLobby(RsGxsId& nick) ; | ||||
|       virtual void getDefaultIdentityForChatLobby(RsGxsId& nick) ; | ||||
|     virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe); | ||||
|     virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id); | ||||
|       virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const RsGxsId& lobby_identity,const std::string& lobby_topic,const std::set<RsPeerId>& invited_friends,ChatLobbyFlags privacy_type) ; | ||||
|  |  | |||
|  | @ -439,7 +439,10 @@ bool p3IdService::getOwnIds(std::list<RsGxsId> &ownIds) | |||
|     RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/ | ||||
| 
 | ||||
|     if(!mOwnIdsLoaded) | ||||
|     { | ||||
|         std::cerr << "p3IdService::getOwnIds(): own identities are not loaded yet." << std::endl; | ||||
|         return false ; | ||||
|     } | ||||
| 
 | ||||
|     ownIds = mOwnIds; | ||||
|     return true ; | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ | |||
| #include "util/QtVersion.h" | ||||
| #include "gui/settings/rsharesettings.h" | ||||
| #include "gui/gxs/GxsIdDetails.h" | ||||
| #include "gui/Identity/IdEditDialog.h" | ||||
| 
 | ||||
| #include "retroshare/rsmsgs.h" | ||||
| #include "retroshare/rspeers.h" | ||||
|  | @ -244,14 +245,14 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) | |||
|             QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem(); | ||||
|             uint32_t item_flags = item->data(COLUMN_DATA,ROLE_ID).toUInt() ; | ||||
| 
 | ||||
|             if(own_identities.size() <= 1) | ||||
|             if(own_identities.empty()) | ||||
|             { | ||||
|                 contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Create a nickname and enter this lobby"), this, SLOT(createIdentityAndSubscribe())); | ||||
|             } | ||||
|             else if(own_identities.size() == 1) | ||||
|             { | ||||
|                 QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Enter this lobby"), this, SLOT(subscribeChatLobbyAs())); | ||||
| 
 | ||||
|                 if(own_identities.empty()) | ||||
|                     action->setEnabled(false) ; | ||||
|                 else | ||||
|                     action->setData(QString::fromStdString((own_identities.front()).toStdString())) ; | ||||
|                 action->setData(QString::fromStdString((own_identities.front()).toStdString())) ; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|  | @ -636,6 +637,28 @@ void ChatLobbyWidget::showLobby(QTreeWidgetItem *item) | |||
| 		ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ; | ||||
| } | ||||
| 
 | ||||
| // this function is for the case where we don't have any identity yet
 | ||||
| void ChatLobbyWidget::createIdentityAndSubscribe() | ||||
| { | ||||
|     QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem(); | ||||
| 
 | ||||
|     if(!item) | ||||
|         return ; | ||||
| 
 | ||||
|     ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong(); | ||||
| 
 | ||||
|     IdEditDialog dlg(this); | ||||
|     dlg.setupNewId(false); | ||||
|     dlg.exec(); | ||||
|     // fetch new id
 | ||||
|     std::list<RsGxsId> own_ids; | ||||
|     if(!rsIdentity->getOwnIds(own_ids) || own_ids.empty()) | ||||
|         return; | ||||
| 
 | ||||
|     if(rsMsgs->joinVisibleChatLobby(id,own_ids.front())) | ||||
|         ChatDialog::chatFriend(ChatId(id),true) ; | ||||
| } | ||||
| 
 | ||||
| void ChatLobbyWidget::subscribeChatLobbyAs() | ||||
| { | ||||
|     QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem(); | ||||
|  | @ -689,7 +712,29 @@ void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item) | |||
|     ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong(); | ||||
|     RsGxsId gxs_id ; | ||||
| 
 | ||||
|     if(rsMsgs->getDefaultIdentityForChatLobby(gxs_id) && !gxs_id.isNull() && rsMsgs->joinVisibleChatLobby(id,gxs_id)) | ||||
|     std::list<RsGxsId> own_ids; | ||||
|     // not using rsMsgs->getDefaultIdentityForChatLobby(), to check if we have an identity
 | ||||
|     // to work around the case when the identity was deleted and is invalid
 | ||||
|     // (the chatservervice does not know if a default identity was deleted)
 | ||||
|     // only rsIdentity knows the truth at the moment!
 | ||||
|     if(!rsIdentity->getOwnIds(own_ids)) | ||||
|         return; | ||||
| 
 | ||||
|     // if there is no identity yet, show the dialog to create a new identity
 | ||||
|     if(own_ids.empty()) | ||||
|     { | ||||
|         IdEditDialog dlg(this); | ||||
|         dlg.setupNewId(false); | ||||
|         dlg.exec(); | ||||
|         // fetch new id
 | ||||
|         if(!rsIdentity->getOwnIds(own_ids) || own_ids.empty()) | ||||
|             return; | ||||
|         gxs_id = own_ids.front(); | ||||
|     } | ||||
|     else | ||||
|         rsMsgs->getDefaultIdentityForChatLobby(gxs_id); | ||||
| 
 | ||||
|     if(rsMsgs->joinVisibleChatLobby(id,gxs_id)) | ||||
|         ChatDialog::chatFriend(ChatId(id),true) ; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ | |||
| #include <retroshare/rsmsgs.h> | ||||
| #include "ui_ChatLobbyWidget.h" | ||||
| #include "RsAutoUpdatePage.h" | ||||
| #include "chat/ChatLobbyUserNotify.h" | ||||
| #include "chat/ChatLobbyUserNotify.h" | ||||
| 
 | ||||
| #define IMAGE_CHATLOBBY			    ":/images/chat_32.png" | ||||
| 
 | ||||
|  | @ -38,13 +38,13 @@ public: | |||
| 	virtual QString pageName() const { return tr("Chat Lobbies") ; } //MainPage
 | ||||
| 	virtual QString helpText() const { return ""; } //MainPage
 | ||||
| 
 | ||||
| 	virtual UserNotify *getUserNotify(QObject *parent); //MainPage
 | ||||
| 	virtual UserNotify *getUserNotify(QObject *parent); //MainPage
 | ||||
| 
 | ||||
| 	virtual void updateDisplay(); | ||||
| 
 | ||||
| 	void setCurrentChatPage(ChatLobbyDialog *) ;	// used by ChatLobbyDialog to raise.
 | ||||
| 	void addChatPage(ChatLobbyDialog *) ; | ||||
| 	void showLobbyAnchor(ChatLobbyId id, QString anchor) ; | ||||
| 	void showLobbyAnchor(ChatLobbyId id, QString anchor) ; | ||||
| 
 | ||||
| 	uint unreadCount(); | ||||
| 
 | ||||
|  | @ -64,10 +64,11 @@ protected slots: | |||
| 	void showLobby(QTreeWidgetItem *lobby_item) ; | ||||
| 	void showBlankPage(ChatLobbyId id) ; | ||||
|     void unsubscribeChatLobby(ChatLobbyId id) ; | ||||
|     void createIdentityAndSubscribe(); | ||||
|     void subscribeChatLobbyAs() ; | ||||
|     void updateTypingStatus(ChatLobbyId id) ; | ||||
| 	void resetLobbyTreeIcons() ; | ||||
| 	void updateMessageChanged(bool incoming, ChatLobbyId, QDateTime time, QString senderName, QString msg); | ||||
| 	void updateMessageChanged(bool incoming, ChatLobbyId, QDateTime time, QString senderName, QString msg); | ||||
| 	void updatePeerEntering(ChatLobbyId); | ||||
| 	void updatePeerLeaving(ChatLobbyId); | ||||
| 	void autoSubscribeItem(); | ||||
|  | @ -80,8 +81,8 @@ private slots: | |||
|     void setShowTopicColumn(bool show); | ||||
|     void setShowSubscribeColumn(bool show); | ||||
| 
 | ||||
| 	void updateNotify(ChatLobbyId id, unsigned int count) ; | ||||
| 
 | ||||
| 	void updateNotify(ChatLobbyId id, unsigned int count) ; | ||||
| 
 | ||||
| private: | ||||
| 	void autoSubscribeLobby(QTreeWidgetItem *item); | ||||
|     void subscribeChatLobby(ChatLobbyId id) ; | ||||
|  | @ -111,8 +112,8 @@ private: | |||
| 	QAction* showSubscribeAct; | ||||
| 	int getNumColVisible(); | ||||
| 
 | ||||
| 	ChatLobbyUserNotify* myChatLobbyUserNotify; | ||||
| 
 | ||||
| 	ChatLobbyUserNotify* myChatLobbyUserNotify; | ||||
| 
 | ||||
| 	/* UI - from Designer */ | ||||
| 	Ui::ChatLobbyWidget ui; | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 electron128
						electron128