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 if (!app.authorize("shell_access"))
00045 return 3;
00046
00047 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00048
00049 if (args->count() != 1)
00050 return 1;
00051
00052 KURL url(args->arg(0));
00053 QStringList cmd;
00054 cmd << "--noclose";
00055
00056 cmd << "-e";
00057 if ( url.protocol() == "telnet" )
00058 cmd << "telnet";
00059 else if ( url.protocol() == "rlogin" )
00060 cmd << "rlogin";
00061 else {
00062 kdError() << "Invalid protocol " << url.protocol() << endl;
00063 return 2;
00064 }
00065 if (!url.user().isEmpty())
00066 {
00067 cmd << "-l";
00068 cmd << url.user();
00069 }
00070
00071 if (!url.host().isEmpty())
00072 cmd << url.host();
00073 else if (!url.path().isEmpty())
00074 cmd << url.path();
00075
00076 if (url.port())
00077 cmd << QString::number(url.port());
00078
00079 app.kdeinitExec("konsole", cmd);
00080
00081 return 0;
00082 }
00083
00084
This file is part of the documentation for kdelibs Version 3.1.5.