forked from blue/squawk
muc joining leaving debug, notification debug, delayed delivery wannabe detection
This commit is contained in:
parent
a51907b810
commit
f5fa45d853
@ -572,7 +572,10 @@ bool Core::Account::handleGroupMessage(const QXmppMessage& msg, bool outgoing, b
|
||||
}
|
||||
cnt->appendMessageToArchive(sMsg);
|
||||
|
||||
emit message(sMsg);
|
||||
QDateTime fiveMinsAgo = QDateTime::currentDateTime().addSecs(-300);
|
||||
if (sMsg.getTime() > fiveMinsAgo) { //otherwise it's considered a delayed delivery, most probably MUC history receipt
|
||||
emit message(sMsg);
|
||||
}
|
||||
|
||||
if (!forwarded && !outgoing) {
|
||||
if (msg.isReceiptRequested() && id.size() > 0) {
|
||||
|
@ -64,7 +64,7 @@ bool Core::Conference::getJoined() const
|
||||
void Core::Conference::setJoined(bool p_joined)
|
||||
{
|
||||
if (joined != p_joined) {
|
||||
if (joined) {
|
||||
if (p_joined) {
|
||||
room->join();
|
||||
} else {
|
||||
room->leave();
|
||||
|
@ -424,7 +424,7 @@ void Core::Squawk::setRoomJoined(const QString& account, const QString& jid, boo
|
||||
{
|
||||
AccountsMap::const_iterator itr = amap.find(account);
|
||||
if (itr == amap.end()) {
|
||||
qDebug() << "An attempt to set autoJoin to the room" << jid << "of non existing account" << account << ", skipping";
|
||||
qDebug() << "An attempt to set jouned to the room" << jid << "of non existing account" << account << ", skipping";
|
||||
return;
|
||||
}
|
||||
itr->second->setRoomJoined(jid, joined);
|
||||
|
@ -219,11 +219,11 @@ void Models::Contact::setState(Shared::SubscriptionState p_state)
|
||||
QIcon Models::Contact::getStatusIcon(bool big) const
|
||||
{
|
||||
if (getMessagesCount() > 0) {
|
||||
return Shared::icon("mail-message");
|
||||
return Shared::icon("mail-message", big);
|
||||
} else if (state == Shared::both) {
|
||||
return Shared::availabilityIcon(availability, big);;
|
||||
} else {
|
||||
return Shared::subscriptionStateIcon(state);
|
||||
return Shared::subscriptionStateIcon(state, big);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ unsigned int Models::Room::getUnreadMessagesCount() const
|
||||
|
||||
int Models::Room::columnCount() const
|
||||
{
|
||||
return 5;
|
||||
return 6;
|
||||
}
|
||||
|
||||
QString Models::Room::getJid() const
|
||||
@ -99,6 +99,8 @@ QVariant Models::Room::data(int column) const
|
||||
return getAutoJoin();
|
||||
case 4:
|
||||
return getNick();
|
||||
case 5:
|
||||
return getMessagesCount();
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -153,17 +155,21 @@ void Models::Room::update(const QString& field, const QVariant& value)
|
||||
|
||||
QIcon Models::Room::getStatusIcon(bool big) const
|
||||
{
|
||||
if (autoJoin) {
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connected, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::disconnected, big);
|
||||
}
|
||||
if (messages.size() > 0) {
|
||||
return Shared::icon("mail-message", big);
|
||||
} else {
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connecting, big);
|
||||
if (autoJoin) {
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connected, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::disconnected, big);
|
||||
}
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::error, big);
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connecting, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::error, big);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -184,3 +190,30 @@ QString Models::Room::getStatusText() const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Models::Room::getMessagesCount() const
|
||||
{
|
||||
return messages.size();
|
||||
}
|
||||
|
||||
void Models::Room::addMessage(const Shared::Message& data)
|
||||
{
|
||||
messages.emplace_back(data);
|
||||
changed(5);
|
||||
}
|
||||
|
||||
void Models::Room::dropMessages()
|
||||
{
|
||||
if (messages.size() > 0) {
|
||||
messages.clear();
|
||||
changed(5);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Room::getMessages(Models::Room::Messages& container) const
|
||||
{
|
||||
for (Messages::const_iterator itr = messages.begin(), end = messages.end(); itr != end; ++itr) {
|
||||
const Shared::Message& msg = *itr;
|
||||
container.push_back(msg);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ class Room : public Models::Item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef std::deque<Shared::Message> Messages;
|
||||
Room(const QString& p_jid, const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
||||
~Room();
|
||||
|
||||
@ -53,6 +54,11 @@ public:
|
||||
void setNick(const QString& p_nick);
|
||||
|
||||
void update(const QString& field, const QVariant& value);
|
||||
|
||||
void addMessage(const Shared::Message& data);
|
||||
unsigned int getMessagesCount() const;
|
||||
void dropMessages();
|
||||
void getMessages(Messages& container) const;
|
||||
|
||||
protected:
|
||||
|
||||
@ -61,7 +67,7 @@ private:
|
||||
bool joined;
|
||||
QString jid;
|
||||
QString nick;
|
||||
std::deque<Shared::Message> messages;
|
||||
Messages messages;
|
||||
|
||||
};
|
||||
|
||||
|
@ -615,6 +615,11 @@ void Models::Roster::addMessage(const QString& account, const Shared::Message& d
|
||||
for (;cBeg != cEnd; ++cBeg) {
|
||||
cBeg->second->addMessage(data);
|
||||
}
|
||||
|
||||
std::map<ElId, Room*>::const_iterator rItr = rooms.find(id);
|
||||
if (rItr != rooms.end()) {
|
||||
rItr->second->addMessage(data);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Roster::dropMessages(const QString& account, const QString& jid)
|
||||
@ -623,6 +628,11 @@ void Models::Roster::dropMessages(const QString& account, const QString& jid)
|
||||
for (std::multimap<ElId, Contact*>::iterator cBeg = contacts.lower_bound(id), cEnd = contacts.upper_bound(id) ;cBeg != cEnd; ++cBeg) {
|
||||
cBeg->second->dropMessages();
|
||||
}
|
||||
|
||||
std::map<ElId, Room*>::const_iterator rItr = rooms.find(id);
|
||||
if (rItr != rooms.end()) {
|
||||
rItr->second->dropMessages();
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Roster::removeAccount(const QString& account)
|
||||
@ -677,12 +687,20 @@ void Models::Roster::removeAccount(const QString& account)
|
||||
|
||||
QString Models::Roster::getContactName(const QString& account, const QString& jid)
|
||||
{
|
||||
std::multimap<ElId, Contact*>::const_iterator cItr = contacts.find({account, jid});
|
||||
ElId id(account, jid);
|
||||
std::multimap<ElId, Contact*>::const_iterator cItr = contacts.find(id);
|
||||
QString name = "";
|
||||
if (cItr == contacts.end()) {
|
||||
qDebug() << "An attempt to get a name of non existing contact " << account << ":" << jid << ", skipping";
|
||||
return "";
|
||||
std::map<ElId, Room*>::const_iterator rItr = rooms.find(id);
|
||||
if (rItr == rooms.end()) {
|
||||
qDebug() << "An attempt to get a name of non existing contact/room " << account << ":" << jid << ", skipping";
|
||||
} else {
|
||||
name = rItr->second->getName();
|
||||
}
|
||||
} else {
|
||||
name = cItr->second->getContactName();
|
||||
}
|
||||
return cItr->second->getContactName();
|
||||
return name;
|
||||
}
|
||||
|
||||
void Models::Roster::addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data)
|
||||
|
@ -295,7 +295,7 @@ void Squawk::onConversationClosed(QObject* parent)
|
||||
}
|
||||
if (conv->isMuc) {
|
||||
Room* room = static_cast<Room*>(conv);
|
||||
if (room->autoJoined()) {
|
||||
if (!room->autoJoined()) {
|
||||
emit setRoomJoined(id.account, id.name, false);
|
||||
}
|
||||
}
|
||||
@ -327,11 +327,16 @@ void Squawk::accountMessage(const QString& account, const Shared::Message& data)
|
||||
|
||||
void Squawk::notify(const QString& account, const Shared::Message& msg)
|
||||
{
|
||||
QString name = QString(rosterModel.getContactName(account, msg.getPenPalJid()));;
|
||||
QVariantList args;
|
||||
args << QString(QCoreApplication::applicationName());
|
||||
args << QVariant(QVariant::UInt); //TODO some normal id
|
||||
args << QString("mail-message"); //TODO icon
|
||||
args << QString(rosterModel.getContactName(account, msg.getPenPalJid()));
|
||||
if (msg.getType() == Shared::Message::groupChat) {
|
||||
args << msg.getFromResource() + " from " + name;
|
||||
} else {
|
||||
args << name;
|
||||
}
|
||||
args << QString(msg.getBody());
|
||||
args << QStringList();
|
||||
args << QVariantMap();
|
||||
|
Loading…
Reference in New Issue
Block a user