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 <kcmdlineargs.h>
00026 #include <klocale.h>
00027 #include <kapplication.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 KCmdLineOptions 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 KCmdLineLastOption
00041 };
00042
00043 extern "C" KDE_EXPORT int kdemain(int argc, char *argv[])
00044 {
00045 KLocale::setMainCatalogue("kdelibs");
00046 KCmdLineArgs::init(argc, argv, "kcookiejar", I18N_NOOP("HTTP cookie daemon"),
00047 description, version);
00048
00049 KCmdLineArgs::addCmdLineOptions( options );
00050
00051 KInstance a("kcookiejar");
00052
00053 kapp->dcopClient()->attach();
00054
00055 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00056 QCString replyType;
00057 QByteArray replyData;
00058 if (args->isSet("remove-all"))
00059 {
00060 kapp->dcopClient()->call( "kded", "kcookiejar", "deleteAllCookies()", QByteArray(), replyType, replyData);
00061 }
00062 if (args->isSet("remove"))
00063 {
00064 QString domain = args->getOption("remove");
00065 QByteArray params;
00066 QDataStream stream(params, IO_WriteOnly);
00067 stream << domain;
00068 kapp->dcopClient()->call( "kded", "kcookiejar", "deleteCookiesFromDomain(QString)", params, replyType, replyData);
00069 }
00070 if (args->isSet("shutdown"))
00071 {
00072 QCString module = "kcookiejar";
00073 QByteArray params;
00074 QDataStream stream(params, IO_WriteOnly);
00075 stream << module;
00076 kapp->dcopClient()->call( "kded", "kded", "unloadModule(QCString)", params, replyType, replyData);
00077 }
00078 else if(args->isSet("reload-config"))
00079 {
00080 kapp->dcopClient()->call( "kded", "kcookiejar", "reloadPolicy()", QByteArray(), replyType, replyData);
00081 }
00082 else
00083 {
00084 QCString module = "kcookiejar";
00085 QByteArray params;
00086 QDataStream stream(params, IO_WriteOnly);
00087 stream << module;
00088 kapp->dcopClient()->call( "kded", "kded", "loadModule(QCString)", params, replyType, replyData);
00089 }
00090
00091 return 0;
00092 }