Changeset 284:02a62328b524
- Timestamp:
- 06/20/2008 08:44:31 PM (4 years ago)
- Branch:
- default
- Files:
-
- 7 modified
-
sql/config.sql (modified) (1 diff)
-
src/base/gluxibot.cpp (modified) (1 diff)
-
src/plugins/muc/config/mucconfigurator.cpp (modified) (1 diff)
-
src/plugins/muc/config/mucconfigurator.h (modified) (2 diffs)
-
src/plugins/muc/mucplugin.cpp (modified) (8 diffs)
-
src/plugins/muc/mucplugin.h (modified) (1 diff)
-
src/plugins/muc/nick.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sql/config.sql
r271 r284 1 insert into configuration_fields (plugin, name, field_type, description, default_value) VALUES (1, 'alists_every_presence', 2, 'Apply ALists to every presence', true);2 insert into configuration_fields (plugin, name, field_type, description, default_value) VALUES (1, 'alists_members', 2, 'Apply ALists to members', false);3 insert into configuration_fields (plugin, name, priority, field_type, description, default_value) values (1, 'devoice_no_vcard', 1, 2, 'Devoice participants without VCard', ' false');1 insert into configuration_fields (plugin, name, field_type, description, default_value) VALUES (1, 'alists_every_presence', 2, 'Apply ALists to every presence', '1'); 2 insert into configuration_fields (plugin, name, field_type, description, default_value) VALUES (1, 'alists_members', 2, 'Apply ALists to members', '0'); 3 insert into configuration_fields (plugin, name, priority, field_type, description, default_value) values (1, 'devoice_no_vcard', 1, 2, 'Devoice participants without VCard', '0'); 4 4 insert into configuration_fields (plugin, name, priority, field_type, description, default_value) values (1, 'devoice_no_vcard_reason', 2, 1, 'No VCard devoice reason', 'Please fill your VCard and then say me !muc checkvcard'); 5 insert into configuration_fields (plugin, name, priority, field_type, description, default_value) values (1, 'query_version_on_join', 3, 2, 'Query version on join', '0'); -
src/base/gluxibot.cpp
r268 r284 193 193 if (plugin) 194 194 { 195 plugin->onIq(s);196 return;195 if (plugin->onIq(s)) 196 return; 197 197 } 198 198 -
src/plugins/muc/config/mucconfigurator.cpp
r271 r284 50 50 if (field.name()=="devoice_no_vcard_reason") 51 51 devoiceNoVCardReason_=field.value(); 52 if (field.name()=="query_version_on_join") 53 queryVersionOnJoin_=field.boolValue(); 52 54 } 53 55 } -
src/plugins/muc/config/mucconfigurator.h
r271 r284 34 34 bool isDevoiceNoVCard() const { return devoiceNoVCard_; } 35 35 QString devoiceNoVCardReason() const { return devoiceNoVCardReason_; } 36 bool isQueryVersionOnJoin() const { return queryVersionOnJoin_; } 36 37 private: 37 38 bool applyAlistsToMembers_; … … 39 40 bool devoiceNoVCard_; 40 41 QString devoiceNoVCardReason_; 42 bool queryVersionOnJoin_; 41 43 void parse(); 42 44 -
src/plugins/muc/mucplugin.cpp
r283 r284 33 33 << "BANJID" << "UNBAN" << "NONE" << "MEMBER" << "ADMIN" << "OWNER"; 34 34 commands << "ABAN" << "AKICK" << "AVISITOR" << "ACMD" << "AMODERATOR" << "AFIND" 35 << "SEEN" << "CLIENTS" << "SETNICK" << "CHECKVCARD" ;35 << "SEEN" << "CLIENTS" << "SETNICK" << "CHECKVCARD" << "ROLE" << "VERSION"; 36 36 commands << "HERE"; 37 37 pluginId=1; … … 253 253 254 254 } 255 } 256 else 257 { 258 if (n->validateRequired()) 259 newNick=true; 255 260 } 256 261 if (role=="none" || type=="unavailable") … … 306 311 checkMember(s, conf, n); 307 312 308 if (newNick && conf->configurator()->isDevoiceNoVCard()) 309 requestVCard(s, conf, n); 313 if (newNick) 314 { 315 if (conf->configurator()->isDevoiceNoVCard()) 316 requestVCard(s, conf, n); 317 if (conf->configurator()->isQueryVersionOnJoin()) 318 { 319 requestVersion(s, conf, n); 320 } 321 } 310 322 } 311 323 } … … 461 473 QString 462 474 nickInfo= 463 QString("Nick \"%1\": Affiliation: %2; Role: %3; Registered: %4; Joined: %5; Idle: %6; Status: %7 (%8)")475 QString("Nick \"%1\": Affiliation: %2; Role: %3; Registered: %4; Joined: %5; Idle: %6; Role: %7; Status: %8 (%9)") 464 476 .arg(n->nick()) 465 477 .arg(n->affiliation()) … … 468 480 .arg(n->joined().toString(Qt::LocaleDate)) 469 481 .arg(secsToString(n->lastActivity().secsTo(QDateTime::currentDateTime()))) 482 .arg(getRoleForNick(conf, n)) 470 483 .arg(n->show()) 471 484 .arg(n->status()); … … 483 496 } 484 497 498 if (cmd=="ROLE") 499 { 500 Nick *n=getNickVerbose(s, arg); 501 if (!n) 502 return true; 503 reply(s,QString("Role for \"%1\" is %2").arg(n->nick()).arg(getRoleForNick(conf, n))); 504 return true; 505 } 506 507 if (cmd=="VERSION") 508 { 509 Nick *n=getNickVerbose(s, arg); 510 if (!n) 511 return true; 512 QString res=n->versionName(); 513 if (!n->versionClient().isEmpty()) 514 res+=QString(" %1").arg(n->versionClient()); 515 if (!n->versionOs().isEmpty()) 516 res+=QString(" // %1").arg(n->versionOs()); 517 if (res.isEmpty()) 518 reply(s, QString("No version stored for \"%1\"").arg(n->nick())); 519 else 520 reply(s, QString("%1 uses %2").arg(n->nick()).arg(res)); 521 return true; 522 } 523 485 524 if (cmd=="CHECKVCARD") 486 525 { … … 914 953 if (!conf) 915 954 return false; 916 QString reason=getIqError(s); 917 955 Nick *nick=getNick(s); 956 if (!nick) 957 return false; 958 959 AsyncRequest* req=bot()->asyncRequests()->byStanza(s); 960 if (!req) 961 return false; 962 963 QString xmlns=QString::fromStdString(s->xmlns()); 964 if (s->subtype()!=gloox::StanzaIqResult || xmlns!="jabber:iq:version") 965 return false; 966 967 gloox::Tag* query=s->findChild("query", "xmlns", xmlns.toStdString()); 968 nick->setVersionName(QString::null); 969 nick->setVersionClient(QString::null); 970 nick->setVersionOs(QString::null); 971 if (query) 972 { 973 gloox::Tag* t; 974 t=query->findChild("name"); 975 if (t) 976 nick->setVersionName(QString::fromStdString(t->cdata())); 977 t=query->findChild("version"); 978 if (t) 979 nick->setVersionClient(QString::fromStdString(t->cdata())); 980 t=query->findChild("os"); 981 if (t) 982 nick->setVersionOs(QString::fromStdString(t->cdata())); 983 } 984 delete req; 985 bot()->asyncRequests()->removeAll(req); 918 986 return true; 919 987 } … … 1585 1653 bot()->client()->send(outgoing); 1586 1654 } 1655 1656 void MucPlugin::requestVersion(gloox::Stanza* s, Conference* conf, Nick* nick) 1657 { 1658 QString jid=conf->name()+"/"+nick->nick(); 1659 std::string id=bot()->client()->getID(); 1660 1661 gloox::Stanza *st=gloox::Stanza::createIqStanza( 1662 gloox::JID(jid.toStdString()), id, gloox::StanzaIqGet, 1663 "jabber:iq:version"); 1664 1665 gloox::Stanza *sf=new gloox::Stanza(s); 1666 sf->addAttribute("id", id); 1667 1668 AsyncRequest *req=new AsyncRequest(-1, this, sf, 3600); 1669 req->setName("muc::version"); 1670 bot()->asyncRequests()->append(req); 1671 bot()->client()->send(st); 1672 return; 1673 } 1674 1675 int MucPlugin::getRoleForNick(Conference* conf, Nick* nick) 1676 { 1677 if (!conf || !nick) 1678 return 0; 1679 QString jid1=nick->jidStr(); 1680 QString jid2=conf->name()+"/"+nick->nick(); 1681 int role1=bot()->roles()->get(jid1); 1682 int role2=bot()->roles()->get(jid2); 1683 return (role1>role2) ? role1: role2; 1684 } -
src/plugins/muc/mucplugin.h
r275 r284 64 64 int getStatus(gloox::Stanza* s); 65 65 bool warnImOwner(gloox::Stanza* s); 66 int getRoleForNick(Conference* conf, Nick* nick); 66 67 QString expandMacro(gloox::Stanza* s, Conference*c, Nick* n, const QString& str, const AListItem* item=0); 67 68 void requestVCard(gloox::Stanza* s, Conference* conf, Nick* nick); 69 void requestVersion(gloox::Stanza* s, Conference* conf, Nick* nick); 68 70 private slots: 69 71 void sltAutoLeaveTimerTimeout(); -
src/plugins/muc/nick.h
r271 r284 25 25 Jid* jid() const { return myJid; }; 26 26 bool validateRequired() const { return myValidateRequired; }; 27 QString versionName() const { return versionName_; } 28 QString versionOs() const { return versionOs_; } 29 QString versionClient() const { return versionClient_; } 27 30 28 31 QStringList similarNicks(); … … 40 43 static void setAllOffline (Conference* conf); 41 44 bool isDevoicedNoVCard() const {return devoicedNoVCard_; } 42 void setDevoicedNoVCard(bool v) { devoicedNoVCard_ = v; } 45 void setDevoicedNoVCard(bool v) { devoicedNoVCard_ = v; } 46 void setVersionName(const QString& name) { versionName_=name; }; 47 void setVersionOs(const QString& os) { versionOs_=os; }; 48 void setVersionClient(const QString& client) { versionClient_=client; }; 49 43 50 private: 44 51 int myId; … … 56 63 QString myStatus; 57 64 bool devoicedNoVCard_; 65 QString versionName_; 66 QString versionOs_; 67 QString versionClient_; 58 68 }; 59 69
