Changeset 375:96bb8d64e6ad
- Timestamp:
- 05/18/2009 09:54:18 PM (3 years ago)
- Branch:
- default
- Files:
-
- 3 added
- 7 modified
-
sql/update/pgsql/00374.sql (added)
-
src/plugins/muc/CMakeLists.txt (modified) (2 diffs)
-
src/plugins/muc/jid.cpp (modified) (1 diff)
-
src/plugins/muc/jid.h (modified) (1 diff)
-
src/plugins/muc/jidstat.cpp (added)
-
src/plugins/muc/jidstat.h (added)
-
src/plugins/muc/mucplugin.cpp (modified) (11 diffs)
-
src/plugins/muc/mucplugin.h (modified) (1 diff)
-
src/plugins/muc/nick.cpp (modified) (6 diffs)
-
src/plugins/muc/nick.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/plugins/muc/CMakeLists.txt
r298 r375 12 12 conferencelist.h 13 13 jid.h 14 jidstat.h 14 15 nick.h 15 16 nicklist.h … … 23 24 conferencelist.cpp 24 25 jid.cpp 26 jidstat.cpp 25 27 mucplugin.cpp 26 28 nick.cpp -
src/plugins/muc/jid.cpp
r373 r375 56 56 void Jid::loadJid() 57 57 { 58 myId == 0; 58 59 QSqlQuery query=DataStorage::instance() 59 60 ->prepareQuery("SELECT id,created FROM conference_jids WHERE conference_id = ? AND jid = ?"); -
src/plugins/muc/jid.h
r227 r375 23 23 void commit(); 24 24 void remove(); 25 bool isTemporary() const { return myTemporary; } 25 26 static void removeTemporary(Conference *conf=0); 26 27 private: -
src/plugins/muc/mucplugin.cpp
r367 r375 5 5 #include "alistitem.h" 6 6 #include "jid.h" 7 #include "jidstat.h" 7 8 #include "config/mucconfigurator.h" 8 9 #include "nickasyncrequest.h" … … 36 37 << "ATRACE" << "SEEN" << "CLIENTS" << "SETNICK" << "CHECKVCARD" << "ROLE" << "VERSION"; 37 38 commands << "HERE" << "STATUS" << "AGE" << "AGESTAT"; 38 39 39 40 commands << "POKE"; 40 41 pluginId=1; … … 258 259 n=0; 259 260 } 260 261 261 } 262 262 … … 272 272 conf->nicks()->append(n); 273 273 274 JidStat *stat = n->jidStat(); 275 if (stat) 276 { 277 // Just presence? 278 QString show = getPresence(s->presence()); 279 QString status = QString::fromStdString(s->status()); 280 if (!status.isEmpty()) 281 show += QString(" (%1)").arg(status); 282 stat->setLastAction(JidStat::ActionJoin, show); 283 } 284 274 285 if (nick==conf->nick()) 275 286 { … … 283 294 newNick=true; 284 295 } 296 285 297 if (role=="none" || type=="unavailable") 286 298 { … … 308 320 { 309 321 qDebug() << "!!!!!! Removing nick"; 322 JidStat *stat = n->jidStat(); 323 if (stat) 324 { 325 int statusCode = getStatus(s); 326 if (statusCode == 307 || statusCode == 301) 327 { 328 JidStat::ActionType actType = statusCode == 307 329 ? JidStat::ActionKick : JidStat::ActionBan; 330 QString reason = getReason(s); 331 stat->setLastAction(actType, reason); 332 } 333 else 334 { 335 // Just presence? 336 QString show = QString::fromStdString(s->status()); 337 stat->setLastAction(JidStat::ActionLeave, show); 338 } 339 } 310 340 conf->nicks()->remove(n); 311 341 conf->alistTraceList()->removeAll(QString::fromStdString(s->from().full())); … … 315 345 else 316 346 { 347 JidStat *stat = n->jidStat(); 348 if (stat && !newNick) 349 { 350 if (n->role() != role) 351 { 352 JidStat::ActionType actType = JidStat::ActionNone; 353 if (role == "moderator") 354 actType = JidStat::ActionModerator; 355 else if (role == "participant") 356 actType = JidStat::ActionParticipant; 357 else if (role == "visitor") 358 actType = JidStat::ActionVisitor; 359 QString reason = getReason(s); 360 stat->setLastAction(actType, reason); 361 } 362 else if (n->affiliation() != getItem(s, "affiliation")) 363 { 364 QString aff = getItem(s, "affiliation"); 365 JidStat::ActionType actType = JidStat::ActionNone; 366 if (aff == "none") 367 actType = JidStat::ActionNoAffiliation; 368 else if (aff == "member") 369 actType = JidStat::ActionMember; 370 else if (aff == "administrator") 371 actType = JidStat::ActionAdministrator; 372 else if (role == "owner") 373 actType = JidStat::ActionOwner; 374 QString reason = getReason(s); 375 stat->setLastAction(actType, reason); 376 } 377 else 378 { 379 // Just presence? 380 QString show = getPresence(s->presence()); 381 QString status = QString::fromStdString(s->status()); 382 if (!status.isEmpty()) 383 show += QString(" (%1)").arg(status); 384 stat->setLastAction(JidStat::ActionPresence, show); 385 } 386 } 387 317 388 n->setAffiliation(getItem(s, "affiliation")); 318 389 n->setJid(getItem(s, "jid")); … … 499 570 << "ÑÑеÑÑÑ %1 за плеÑО" 500 571 << "кОМÑл МПж в ÑÑПÑÐŸÐœÑ %1"; 501 572 502 573 srand ( time(NULL) ); 503 574 int r = rand() % replys.count(); 504 575 QString msg = replys[r]; 505 576 506 577 if( arg.isEmpty() ) 507 578 { … … 525 596 return true; 526 597 } 527 if ( arg.compare(nickName, Qt::CaseInsensitive) == 0 ) 598 if ( arg.compare(nickName, Qt::CaseInsensitive) == 0 ) 528 599 { 529 600 reply(s, "ÐŒÐ°Ð·ÐŸÑ … … 534 605 for (int i=0; i<cnt; i++) 535 606 { 536 if( arg.compare( conf->nicks()->at(i)->nick(), Qt::CaseInsensitive ) == 0 ) 607 if( arg.compare( conf->nicks()->at(i)->nick(), Qt::CaseInsensitive ) == 0 ) 537 608 { 538 609 reply(s, QString("/me " + msg) … … 1076 1147 } 1077 1148 return QString::fromStdString(res).toInt(); 1149 } 1150 1151 1152 QString MucPlugin::getReason(gloox::Stanza* s) 1153 { 1154 std::string res; 1155 if (s->hasChild("x", "xmlns", "http://jabber.org/protocol/muc#user")) 1156 { 1157 gloox::Tag *tg1=s->findChild("x", "xmlns", 1158 "http://jabber.org/protocol/muc#user"); 1159 if (!tg1) 1160 return ""; 1161 if (tg1->hasChild("item")) 1162 { 1163 gloox::Tag *tg2=tg1->findChild("item"); 1164 if (!tg2) 1165 return ""; 1166 tg2 = tg2->findChild("reason"); 1167 if (!tg2) 1168 return ""; 1169 res = tg2->cdata(); 1170 } 1171 } 1172 return QString::fromStdString(res); 1078 1173 } 1079 1174 -
src/plugins/muc/mucplugin.h
r334 r375 68 68 QString affiliationByCommand(const QString& cmd); 69 69 int getStatus(gloox::Stanza* s); 70 QString getReason(gloox::Stanza *s); 70 71 bool warnImOwner(gloox::Stanza* s); 71 72 int getRoleForNick(Conference* conf, Nick* nick); -
src/plugins/muc/nick.cpp
r335 r375 2 2 #include "conference.h" 3 3 #include "jid.h" 4 #include "jidstat.h" 4 5 #include "base/datastorage.h" 5 6 … … 15 16 myValidateRequired=false; 16 17 myParent=parent; 18 myJidStat = NULL; 17 19 myNick=nick; 18 20 myLazyLeave=false; … … 23 25 24 26 myJid=new Jid(this, jid); 27 28 if (myJid->id() >= 0 ) 29 myJidStat = new JidStat(myJid->id()); 25 30 26 31 QSqlQuery query=DataStorage::instance() … … 82 87 devoicedNoVCard_=false; 83 88 myParent=parent; 89 myJidStat = NULL; 84 90 myLazyLeave=false; 85 91 myId=id; … … 105 111 myJid=new Jid(this, query.value(1).toInt()); 106 112 myJidS=myJid->jid(); 113 114 if (myJid->id() >= 0 ) 115 myJidStat = new JidStat(myJid->id()); 116 107 117 myJoined=query.value(2).toDateTime(); 108 118 myLastActivity=query.value(3).toDateTime(); … … 124 134 delete myJid; 125 135 } 136 delete myJidStat; 126 137 } 127 138 -
src/plugins/muc/nick.h
r294 r375 7 7 class Conference; 8 8 class Jid; 9 class JidStat; 9 10 10 class Nick{ 11 class Nick 12 { 11 13 public: 12 14 Nick(Conference* parent, const QString& nick, const QString& jid=QString::null); … … 24 26 Conference* conference() const { return myParent; }; 25 27 Jid* jid() const { return myJid; }; 28 JidStat *jidStat() const { return myJidStat; } 26 29 bool validateRequired() const { return myValidateRequired; }; 27 30 bool isVersionStored() const { return versionStored_; } … … 57 60 Conference *myParent; 58 61 Jid *myJid; 62 JidStat *myJidStat; 59 63 QString myJidS; 60 64 QString myNick;
