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 <dcopclient.h>
00025 #include <tdecmdlineargs.h>
00026 #include <tdelocale.h>
00027 #include <tdeapplication.h>
00028
00029 static const char description[] =
00030 I18N_NOOP("HTTP Cookie Daemon");
00031
00032 static const char version[] = "1.0";
00033
00034 static const TDECmdLineOptions options[] =
00035 {
00036 { "shutdown", I18N_NOOP("Shut down cookie jar"), 0 },
00037 { "remove <domain>", I18N_NOOP("Remove cookies for domain"), 0 },
00038 { "remove-all", I18N_NOOP("Remove all cookies"), 0 },
00039 { "reload-config", I18N_NOOP("Reload configuration file"), 0 },
00040 TDECmdLineLastOption
00041 };
00042
00043 extern "C" KDE_EXPORT int kdemain(int argc, char *argv[])
00044 {
00045 TDELocale::setMainCatalogue("tdelibs");
00046 TDECmdLineArgs::init(argc, argv, "kcookiejar", I18N_NOOP("HTTP cookie daemon"),
00047 description, version);
00048
00049 TDECmdLineArgs::addCmdLineOptions( options );
00050
00051 TDEInstance a("kcookiejar");
00052
00053 kapp->dcopClient()->attach();
00054
00055 TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
00056 TQCString replyType;
00057 TQByteArray replyData;
00058 if (args->isSet("remove-all"))
00059 {
00060 kapp->dcopClient()->call( "kded", "kcookiejar", "deleteAllCookies()", TQByteArray(), replyType, replyData);
00061 }
00062 if (args->isSet("remove"))
00063 {
00064 TQString domain = args->getOption("remove");
00065 TQByteArray params;
00066 TQDataStream stream(params, IO_WriteOnly);
00067 stream << domain;
00068 kapp->dcopClient()->call( "kded", "kcookiejar", "deleteCookiesFromDomain(TQString)", params, replyType, replyData);
00069 }
00070 if (args->isSet("shutdown"))
00071 {
00072 TQCString module = "kcookiejar";
00073 TQByteArray params;
00074 TQDataStream stream(params, IO_WriteOnly);
00075 stream << module;
00076 kapp->dcopClient()->call( "kded", "kded", "unloadModule(TQCString)", params, replyType, replyData);
00077 }
00078 else if(args->isSet("reload-config"))
00079 {
00080 kapp->dcopClient()->call( "kded", "kcookiejar", "reloadPolicy()", TQByteArray(), replyType, replyData);
00081 }
00082 else
00083 {
00084 TQCString module = "kcookiejar";
00085 TQByteArray params;
00086 TQDataStream stream(params, IO_WriteOnly);
00087 stream << module;
00088 kapp->dcopClient()->call( "kded", "kded", "loadModule(TQCString)", params, replyType, replyData);
00089 }
00090
00091 return 0;
00092 }