Now the systrayicon change it's color when a download is in progress. I simply change...
[kdenetwork.git] / ksirc / ksirc.cpp
blobeddb450a6d36fd2e2a2d440c1c0dd47f34a13523
1 /*************************************************************************
3 Main KSirc start
5 $$Id$$
7 Main start file that defines 3 global vars, etc
9 *************************************************************************/
12 * Needed items
13 * 4. Send a /quit and/or kill dsirc on exit
14 * */
16 #include <stdlib.h>
18 #include <qsessionmanager.h>
20 #include <kuniqueapplication.h>
21 #include <kaboutdata.h>
22 #include <kcmdlineargs.h>
23 #include <klocale.h>
24 #include <kconfig.h>
25 #include <kdebug.h>
27 //#include "cdate.h"
28 #include "ksopts.h"
29 #include "servercontroller.h"
30 #include "version.h"
32 static const char description[] =
33 I18N_NOOP("KDE IRC client");
35 //QDict<KSircTopLevel> TopList;
36 //QDict<KSircMessageReceiver> TopList;
38 class KCmdLineOptions options[] =
40 { "nick <nickname>", I18N_NOOP( "Nickname to use" ), 0 } ,
41 { "server <server>", I18N_NOOP( "Server to connect to on startup" ), 0 },
42 { "channel <#channel>", I18N_NOOP( "Channel to connect to on startup" ), 0 },
43 { "o", 0, 0 },
44 { "noautoconnect", I18N_NOOP( "Do not autoconnect on startup" ), 0 },
45 KCmdLineLastOption
48 class KSircSessionManaged : public KSessionManaged
50 public:
51 KSircSessionManaged() {}
53 virtual bool commitData( QSessionManager &sm )
55 servercontroller *controller = servercontroller::self();
56 if ( !controller || !sm.allowsInteraction() ) return true;
58 // if the controller is hidden KMWSessionManaged won't send the fake close event.
59 // we want it in any way however.
60 if ( controller->isHidden() ) {
61 QCloseEvent e;
62 QApplication::sendEvent( controller, &e );
65 return true;
69 extern "C" KDE_EXPORT int kdemain( int argc, char ** argv )
71 KAboutData aboutData( "ksirc", I18N_NOOP("KSirc"),
72 KSIRC_VERSION, description, KAboutData::License_Artistic,
73 I18N_NOOP("(c) 1997-2002, The KSirc Developers"));
74 aboutData.addAuthor("Andrew Stanley-Jones",I18N_NOOP("Original Author"), "asj-ksirc@cban.com");
75 aboutData.addAuthor("Waldo Bastian",0, "bastian@kde.org");
76 aboutData.addAuthor("Carsten Pfeiffer",0, "pfeiffer@kde.org");
77 aboutData.addAuthor("Malte Starostik",0, "malte@kde.org");
78 aboutData.addAuthor("Daniel Molkentin",0, "molkentin@kde.org");
79 aboutData.addAuthor("Simon Hausmann",0, "hausmann@kde.org");
80 aboutData.addAuthor("Alyssa Mejawohld", I18N_NOOP("Icons Author"), "amejawohld@bellsouth.net");
81 KCmdLineArgs::init( argc, argv, &aboutData );
82 KCmdLineArgs::addCmdLineOptions( options );
83 KUniqueApplication::addCmdLineOptions();
85 if (!KUniqueApplication::start()) {
86 exit(0);
89 // Start the KDE application
90 KUniqueApplication app;
92 KSircSessionManaged sm;
94 // Options
95 KSOptions opts;
96 opts.load();
98 servercontroller *sc = new servercontroller(0, "servercontroller");
99 app.setMainWidget(sc);
101 if (KMainWindow::canBeRestored(1))
103 sc->restore(1, false );
105 else
106 { // no Session management -> care about docking, geometry, etc.
108 if( !opts.geometry.isEmpty() )
109 sc->setGeometry( opts.geometry );
111 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
113 QCString nickName = args->getOption( "nick" );
114 QCString server = args->getOption( "server" );
115 QCString channel = args->getOption( "channel" );
117 if ( !nickName.isEmpty() )
118 ksopts->server["global"].nick = nickName;
120 if ( !server.isEmpty() ) {
121 QString ser = QString::fromLocal8Bit( server );
122 QString port = "6667";
123 if(ser.contains(":")){
124 port = ser.section(":", 1, 1);
125 ser = ser.section(":", 0, 0);
127 KSircServer kss(ser, port, "", "", false);
128 sc->new_ksircprocess( kss );
129 if ( !channel.isEmpty() ) {
130 QStringList channels = QStringList::split( ',', QString::fromLocal8Bit( channel ) );
131 QStringList::ConstIterator it = channels.begin();
132 QStringList::ConstIterator end = channels.end();
133 for ( ; it != end; ++it ) {
134 sc->new_toplevel( KSircChannel(ser, *it), true );
138 else {
139 if(args->isSet("autoconnect") == TRUE){
140 sc->start_autoconnect();
144 args->clear();
147 return app.exec();
150 /* vim: et sw=4