revert Makefile.am
[kdenetwork.git] / dcoprss / client.cpp
blob998ec452739c7d0d3acb913ef975aebf7e67f38d
1 #include <kapplication.h>
2 #include <dcopclient.h>
3 #include <dcopref.h>
4 #include <qdatastream.h>
5 #include <qstring.h>
6 #include <qstringlist.h>
7 #include <q3cstring.h>
8 #include <kdebug.h>
9 #include <stdlib.h>
10 #include <kcmdlineargs.h>
11 #include <ktoolinvocation.h>
13 class rssIface : virtual public DCOPObject
15 K_DCOP
16 public:
18 rssIface( KApplication *app)
20 // get our DCOP client and attach so that we may use it
21 DCOPClient *client = app->dcopClient();
22 client->attach();
23 QString error;
24 QCString appID;
25 kdDebug() << "Looking for rss service..." << endl;
26 if (!client->isApplicationRegistered("rssservice"))
28 kdDebug() << "Could not find service so I am starting it..." << endl;
29 if(KToolInvocation::startServiceByName("rssservice",QStringList(), &error, &appID ))
31 kdDebug() << "Starting rssservice failed with message: " << error << endl;
32 exit(0);
35 kdDebug ()<< "Accessing rssservice..." << endl;
37 if (!connectDCOPSignal(0,0, "documentUpdated(DCOPRef)",
38 "refresh(DCOPRef)",false))
39 kdDebug() << "Could not attach signal..." << endl;
40 else
41 kdDebug() << "attached dcop signals..." << endl;
43 QString url("http://freshmeat.net/backend/fm.rdf");
44 DCOPRef m_rssservice("rssservice","RSSService");
45 m_rssservice.call("load(QString)", url);
46 QStringList returnList = m_rssservice.call("list()");
47 DCOPRef doc = m_rssservice.call("document(QString)", returnList[0]);
48 QString title = doc.call("title()");
49 QString link = doc.call("link()");
50 QString description = doc.call("description()");
51 kdDebug() << title << endl;
52 kdDebug() << link << endl;
53 kdDebug() << description << endl;
56 k_dcop:
57 virtual void refresh(DCOPRef doc)
59 QString title = doc.call("title()");
60 QString link = doc.call("link()");
61 QString description = doc.call("description()");
62 kdDebug() << title << endl;
63 kdDebug() << link << endl;
64 kdDebug() << description << endl;
67 private:
71 int main(int argc, char **argv)
73 KCmdLineArgs::init( argc, argv, "client", 0, 0, 0, 0 );
74 KApplication *app = new KApplication(false);
76 app->exec();