ktelnetservice.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <kapplication.h>
00025 #include <kcmdlineargs.h>
00026 #include <kdebug.h>
00027 #include <klocale.h>
00028 #include <kprocess.h>
00029
00030 static const KCmdLineOptions options[] =
00031 {
00032 {"+url", 0, 0},
00033 {0, 0, 0}
00034 };
00035
00036 int main(int argc, char **argv)
00037 {
00038 KLocale::setMainCatalogue("kdelibs");
00039 KCmdLineArgs::init(argc, argv, "ktelnetservice", I18N_NOOP("telnet service"), I18N_NOOP("telnet protocol handler"));
00040 KCmdLineArgs::addCmdLineOptions(options);
00041
00042 KApplication app;
00043
00044 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00045
00046 if (args->count() != 1)
00047 return 1;
00048
00049 KURL url(args->arg(0));
00050 QStringList cmd;
00051
00052 cmd << "-e";
00053 if ( url.protocol() == "telnet" )
00054 cmd << "telnet";
00055 else if ( url.protocol() == "rlogin" )
00056 cmd << "rlogin";
00057 else {
00058 kdError() << "Invalid protocol " << url.protocol() << endl;
00059 return 2;
00060 }
00061 if (!url.user().isEmpty())
00062 {
00063 cmd << "-l";
00064 cmd << url.user();
00065 }
00066 cmd << url.host();
00067 if (url.port())
00068 cmd << QString::number(url.port());
00069
00070 app.kdeinitExec("konsole", cmd);
00071
00072 return 0;
00073 }
00074
00075
This file is part of the documentation for kdelibs Version 3.1.0.