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 <kmessagebox.h>
00026 #include <kcmdlineargs.h>
00027 #include <kdebug.h>
00028 #include <klocale.h>
00029 #include <kprocess.h>
00030
00031 static const KCmdLineOptions options[] =
00032 {
00033 {"+url", 0, 0},
00034 KCmdLineLastOption
00035 };
00036
00037 int main(int argc, char **argv)
00038 {
00039 KLocale::setMainCatalogue("kdelibs");
00040 KCmdLineArgs::init(argc, argv, "ktelnetservice", I18N_NOOP("telnet service"),
00041 I18N_NOOP("telnet protocol handler"), "unknown");
00042 KCmdLineArgs::addCmdLineOptions(options);
00043
00044 KApplication app;
00045
00046 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00047
00048 if (args->count() != 1)
00049 return 1;
00050
00051 KURL url(args->arg(0));
00052 QStringList cmd;
00053 cmd << "--noclose";
00054
00055 cmd << "-e";
00056 if ( url.protocol() == "telnet" )
00057 cmd << "telnet";
00058 else if ( url.protocol() == "rlogin" )
00059 cmd << "rlogin";
00060 else {
00061 kdError() << "Invalid protocol " << url.protocol() << endl;
00062 return 2;
00063 }
00064
00065 if (!app.authorize("shell_access"))
00066 {
00067 KMessageBox::sorry(0,
00068 i18n("You do not have permission to access the %1 protocol.").arg(url.protocol()));
00069 return 3;
00070 }
00071
00072 if (!url.user().isEmpty())
00073 {
00074 cmd << "-l";
00075 cmd << url.user();
00076 }
00077
00078 if (!url.host().isEmpty())
00079 cmd << url.host();
00080 else if (!url.path().isEmpty())
00081 cmd << url.path();
00082
00083 if (url.port())
00084 cmd << QString::number(url.port());
00085
00086 app.kdeinitExec("konsole", cmd);
00087
00088 return 0;
00089 }
00090
00091
This file is part of the documentation for kio Library Version 3.2.0.