Reworked the start of a chat with a gpg id (doubleclick in friends tree).

Removed the question to send a message when a chat with an offline friend is started.

Start the chat when
- only one ssl id exist (online or offline)
- only one ssl id is online
Show a messagebox when more than one ssl ids are online or all are offline.

Fixed german language.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4981 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-02-23 00:09:41 +00:00
parent e8f93f1569
commit 56b9fe49ea
3 changed files with 217 additions and 163 deletions

View file

@ -29,7 +29,6 @@
#include "ChatLobbyDialog.h"
#include "PopupChatWindow.h"
#include "gui/settings/rsharesettings.h"
#include "gui/msgs/MessageComposer.h"
#include "gui/SoundManager.h"
#include <retroshare/rsiface.h>
@ -206,42 +205,38 @@ void ChatDialog::init(const std::string &peerId, const QString &title)
if (!rsPeers->getPeerDetails(peerId, detail))
return;
std::string firstId;
if (detail.isOnlyGPGdetail) {
//let's get the ssl child details, and open all the chat boxes
std::list<std::string> onlineIds;
//let's get the ssl child details
std::list<std::string> sslIds;
rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds);
for (std::list<std::string>::iterator it = sslIds.begin(); it != sslIds.end(); it++) {
if (firstId.empty()) {
firstId = *it;
}
RsPeerDetails sslDetails;
if (rsPeers->getPeerDetails(*it, sslDetails)) {
if (sslDetails.state & RS_PEER_STATE_CONNECTED) {
getChat(*it, RS_CHAT_OPEN | RS_CHAT_FOCUS);
return;
}
}
}
} else {
if (detail.state & RS_PEER_STATE_CONNECTED) {
getChat(peerId, RS_CHAT_OPEN | RS_CHAT_FOCUS);
if (sslIds.size() == 1) {
// chat with the one ssl id (online or offline)
getChat(sslIds.front(), RS_CHAT_OPEN | RS_CHAT_FOCUS);
return;
}
firstId = peerId;
}
/* info dialog */
QMessageBox mb(QMessageBox::Question, tr("Friend not Online"), tr("Your Friend is offline \nDo you want to send them a Message instead"), QMessageBox::Yes | QMessageBox::No);
mb.setWindowIcon(QIcon(":/images/rstray3.png"));
if (mb.exec() == QMessageBox::Yes) {
MessageComposer::msgFriend(peerId, false);
} else {
if (firstId.empty() == false) {
getChat(firstId, RS_CHAT_OPEN | RS_CHAT_FOCUS);
// more than one ssl ids available, check for online
for (std::list<std::string>::iterator it = sslIds.begin(); it != sslIds.end(); ++it) {
if (rsPeers->isOnline(*it)) {
onlineIds.push_back(*it);
}
}
if (onlineIds.size() == 1) {
// chat with the online ssl id
getChat(onlineIds.front(), RS_CHAT_OPEN | RS_CHAT_FOCUS);
return;
}
// more than one ssl ids online or all offline
QMessageBox mb(QMessageBox::Warning, "RetroShare", tr("Your friend has more than one locations.\nPlease choose one of it to chat with."), QMessageBox::Ok);
mb.setWindowIcon(QIcon(":/images/rstray3.png"));
mb.exec();
} else {
getChat(peerId, RS_CHAT_OPEN | RS_CHAT_FOCUS);
}
}