Changeset 419:cb5b57b7e390

Show
Ignore:
Timestamp:
06/23/2010 09:41:38 PM (20 months ago)
Author:
Dmitry Nezhevenko <dion@…>
Branch:
default
Parents:
416:919e547ea0c9 (diff), 417:b139596e0b24 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/plugins/muc/mucplugin.cpp

    r415 r419  
    2626 
    2727#include <iostream> 
     28#include <memory> 
    2829 
    2930#include <gloox/stanza.h> 
     
    26502651 
    26512652        bool validJID = false; 
    2652         gloox::Tag *m = new gloox::Tag( "message" ); 
     2653        std::auto_ptr<gloox::Tag> m (new gloox::Tag( "message" )); 
    26532654        m->addAttribute( "to", conf->name().toStdString() ); 
    2654         gloox::Tag *x = new gloox::Tag( m, "x" ); 
     2655        gloox::Tag *x = new gloox::Tag( m.get(), "x" ); 
    26552656        x->addAttribute( "xmlns", "http://jabber.org/protocol/muc#user" ); 
    26562657 
     
    26722673                new gloox::Tag( x, "password", pass.toStdString() ); 
    26732674 
    2674         return (new gloox::Stanza(m)); 
    2675 } 
     2675        return (new gloox::Stanza(m.get())); 
     2676} 
  • src/plugins/muc/mucplugin.cpp

    r417 r419  
    3535{ 
    3636        commands << "WHEREAMI" << "NICK" << "IDLE" << "KNOWN" << "JOIN" << "LEAVE" 
    37                         << "KICK" << "VISITOR" << "PARTICIPANT" << "MODERATOR" << "BAN" 
    38                         << "BANJID" << "UNBAN" << "NONE" << "MEMBER" << "ADMIN" << "OWNER"; 
     37                 << "KICK" << "VISITOR" << "PARTICIPANT" << "MODERATOR" << "BAN" 
     38                 << "BANJID" << "UNBAN" << "NONE" << "MEMBER" << "ADMIN" << "OWNER"; 
    3939        commands << "ABAN" << "AKICK" << "AVISITOR" << "ACMD" << "AMODERATOR" << "APARTICIPANT" << "AFIND" 
    40                         << "ATRACE"  << "SEEN" << "SEENEX" << "CLIENTS" << "SETNICK" << "CHECKVCARD" << "ROLE" << "VERSION"; 
     40                 << "ATRACE"  << "SEEN" << "SEENEX" << "SEENJID" << "CLIENTS" << "SETNICK" << "CHECKVCARD" << "ROLE" << "VERSION"; 
    4141        commands << "HERE" << "STATUS" << "AGE" << "AGESTAT"; 
    4242 
    4343        commands << "REPORT" << "MISSING" << "STAT"; 
    4444 
    45         commands << "POKE" << "REALJID" << "INVITE" << "CLEAN" << "TOPIC"; 
     45        commands << "POKE" << "REALJID" << "INVITE" << "CLEAN" << "TOPIC" << "VISITS"; 
    4646        pluginId=1; 
    4747 
     
    634634        } 
    635635 
    636         if (cmd=="TOPIC") 
     636        if (cmd=="VISITS" || cmd=="VISITSEX") 
    637637        { 
    638638                Conference* conf = getConf(s); 
     
    641641                        return true; 
    642642                } 
     643                QString arg2 = parser.nextToken(); 
     644                QStringList list; 
     645                QDateTime from = QDateTime::fromString(arg, Qt::ISODate); 
     646                QDateTime to   = QDateTime::fromString(arg2, Qt::ISODate); 
     647                if (!to.isValid()) 
     648                        to = QDateTime::currentDateTime(); 
     649                if (!from.isValid()) 
     650                        from = QDateTime(to.date()); 
     651 
     652                if (from > to) 
     653                { 
     654                        QDateTime tmp = from; 
     655                        from = to; 
     656                        to   = tmp; 
     657                } 
     658                list = conf->visits(from, to, cmd.endsWith("EX")); 
     659                reply(s, QString("over the past %1 there was %2 user%3: %4") 
     660                      .arg(secsToString(from.secsTo(to))) 
     661                      .arg( list.count() ) 
     662                      .arg( list.count() > 1 ?"s":"" ) 
     663                      .arg( list.join(", ")) ); 
     664                return true; 
     665        } 
     666 
     667        if (cmd=="TOPIC") 
     668        { 
     669                Conference* conf = getConf(s); 
     670                if (!conf) { 
     671                        reply(s, "You are not in conference!"); 
     672                        return true; 
     673                } 
    643674                if (arg.isEmpty()) { 
    644675                        reply(s, "!muc topic <subject>"); 
     676                        return true; 
     677                } 
     678                if (!isFromConfModerator(s)) { 
     679                        reply(s,"You should be moderator to do this"); 
    645680                        return true; 
    646681                } 
     
    652687                m->addChild(new gloox::Tag("subject", arg.toStdString())); 
    653688                bot()->client()->send(m); 
    654                 return true; 
    655         } 
    656          
     689                reply(s, "OK"); 
     690                return true; 
     691        } 
     692 
    657693        if (cmd=="CLEAN") 
    658694        { 
     
    662698                return true; 
    663699        } 
    664          
     700 
    665701        if (cmd=="INVITE") 
    666702        { 
     
    876912        } 
    877913 
    878         if (cmd=="SEEN" || cmd=="SEENEX") 
    879         { 
    880           if( arg.isEmpty() ) { 
    881             Nick *n = getNick(s); 
    882             if(!n) return true; 
    883             reply(s, conf->seen(n->nick(), "SEENEX" == cmd)); 
    884             return true; 
    885           } 
    886                 reply(s, conf->seen(arg, "SEENEX" == cmd)); 
     914        if (cmd=="SEEN" || cmd=="SEENEX" || cmd=="SEENJID" || cmd=="SEENJIDEX") 
     915        { 
     916                if (arg.isEmpty()) 
     917                { 
     918                        if (cmd.startsWith("SEENJID")) 
     919                        { 
     920                                reply(s, "!muc seenjid[ex] <jid>"); 
     921                                return true; 
     922                        } 
     923                        Nick *n = getNick(s); 
     924                        if (!n) 
     925                                return true; 
     926                        reply(s, conf->seen(n->nick(), cmd.endsWith("EX"), false)); 
     927                        return true; 
     928                } 
     929                reply(s, conf->seen(arg, cmd.endsWith("EX"), cmd.startsWith("SEENJID"))); 
    887930                return true; 
    888931        }