Version: CVS (using KDE KDE 3.3.2) Installed from: Unspecified OS: Linux It would be nice to be able to start konvi from the cli and be able to specify the server/network, channel and nick, so konvi can be started from a script. I really would like to have this for the amarok livecd, so I can include an icon on the desktop to bring users to #amarok. As a littel incentive, I offered beer money for success, and the necessity to use ksirc for failure. :)
SVN commit 413713 by cartman: Provide complete command line argument system FEATURE:99054 M +24 -4 trunk/extragear/network/konversation/src/konversationapplication.cpp M +17 -0 trunk/extragear/network/konversation/src/konversationapplication.h M +18 -1 trunk/extragear/network/konversation/src/main.cpp --- trunk/extragear/network/konversation/src/konversationapplication.cpp #413712:413713 @@ -51,10 +51,12 @@ quickConnectDialog = 0; colorOffSet = 0; m_demoteInProgress = false; + m_connectDelayed=false; demoteTimer = new QTimer(this); connect(demoteTimer,SIGNAL(timeout()),this,SLOT(autoDemoteAllNicks()) ); demoteTimer->start(5*60*1000,false); + } KonversationApplication::~KonversationApplication() @@ -67,6 +69,19 @@ delete identDCOP; } +void KonversationApplication::delayedConnectToServer(const QString& hostname, const QString& port, const QString& channel, + const QString& nick, const QString& password, + const bool& useSSL) +{ + m_hostName=hostname; + m_port=port; + m_channel=channel; + m_nick=nick; + m_password=password; + m_useSSL=useSSL; + m_connectDelayed=true; +} + int KonversationApplication::newInstance() { if(!mainWindow) { @@ -135,11 +150,16 @@ // handle autoconnect on startup Konversation::ServerGroupList serverGroups = preferences.serverGroupList(); - for(Konversation::ServerGroupList::iterator it = serverGroups.begin(); it != serverGroups.end(); ++it) { - if((*it)->autoConnectEnabled()) { - connectToServer((*it)->id()); + if(!m_connectDelayed) + { + for(Konversation::ServerGroupList::iterator it = serverGroups.begin(); it != serverGroups.end(); ++it) { + if((*it)->autoConnectEnabled()) { + connectToServer((*it)->id()); + } + } } - } + else + quickConnectToServer(m_hostName, m_port, m_channel, m_nick, m_password, m_useSSL); // prepare dcop interface dcopObject = new KonvDCOP; --- trunk/extragear/network/konversation/src/konversationapplication.h #413712:413713 @@ -128,6 +128,14 @@ int newInstance(); + void delayedConnectToServer(const QString& hostName, + const QString& port = "6667", + const QString& channel="", + const QString& nick = KonversationApplication::preferences.getNickname(0), + const QString& password="", + const bool& useSSL=FALSE + ); + signals: void catchUrl(const QString& who,const QString& url); void prefsChanged(); @@ -193,6 +201,15 @@ bool m_demoteInProgress; QTimer* demoteTimer; QMap<QString,uint> karmaMap; + + // For command line arguments + QString m_hostName; + QString m_port; + QString m_channel; + QString m_nick; + QString m_password; + bool m_useSSL; + bool m_connectDelayed; }; #endif --- trunk/extragear/network/konversation/src/main.cpp #413712:413713 @@ -34,6 +34,17 @@ static const char* shortDescription=I18N_NOOP("A user friendly IRC client"); +static const KCmdLineOptions options[] = + { + { "server <server>", I18N_NOOP("Server to connect"), 0 }, + { "port <port>", I18N_NOOP("Port to use, default is 6667"), "6667"}, + { "channel <channel>", I18N_NOOP("Channel to join after connection"), ""}, + { "nick <nickname>", I18N_NOOP("Nickname to use"),""}, + { "password <password>", I18N_NOOP("Password for connection"),""}, + { "ssl", I18N_NOOP("Use SSL for connection"),"false"}, + KCmdLineLastOption + }; + int main(int argc, char* argv[]) { KAboutData aboutData("konversation", @@ -73,14 +84,20 @@ aboutData.addCredit("Ruud Nabben",I18N_NOOP("Option to enable IRC color filtering"),"r.nabben@gawab.com"); KCmdLineArgs::init(argc,argv,&aboutData); - KonversationApplication::addCmdLineOptions(); + KCmdLineArgs::addCmdLineOptions(options); KApplication::addCmdLineOptions(); if(!KUniqueApplication::start()) { return 0; } + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KonversationApplication app; + if(args->isSet("server")) + app.delayedConnectToServer(args->getOption("server"), args->getOption("port"), + args->getOption("channel"), args->getOption("nick"), + args->getOption("password"), args->isSet("ssl")); + return app.exec(); }