TDE network applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

service.h 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /* $Id$ */
  2. #ifndef _RSS_SERVICE
  3. #define _RSS_SERVICE
  4. /***************************************************************************
  5. service.h - A DCOP Service to provide RSS data
  6. -------------------
  7. begin : Saturday 15 February 2003
  8. copyright : (C) 2003 by Ian Reinhart Geiser
  9. email : geiseri@kde.org
  10. ***************************************************************************/
  11. /***************************************************************************
  12. * *
  13. * This program is free software; you can redistribute it and/or modify *
  14. * it under the terms of the GNU General Public License as published by *
  15. * the Free Software Foundation; either version 2 of the License, or *
  16. * (at your option) any later version. *
  17. * *
  18. ***************************************************************************/
  19. #include <dcopobject.h>
  20. #include <dcopref.h>
  21. #include <tqdict.h>
  22. #include <tqptrlist.h>
  23. #include <tqstringlist.h>
  24. #include <tqstring.h>
  25. #include <tqdatetime.h>
  26. #include <tqpixmap.h>
  27. #include <librss/global.h>
  28. #include <librss/loader.h>
  29. #include <librss/document.h>
  30. #include <librss/article.h>
  31. #include <librss/image.h>
  32. /**
  33. * This is a DCOP Service do not include this header in anything
  34. *
  35. **/
  36. using namespace RSS;
  37. class RSSDocument;
  38. class RSSArticle;
  39. class RSSService : public DCOPObject
  40. {
  41. K_DCOP
  42. private:
  43. TQDict<RSSDocument> m_list;
  44. public:
  45. RSSService();
  46. ~RSSService();
  47. void saveLinks();
  48. void loadLinks();
  49. k_dcop_signals:
  50. /**
  51. * Emmitted when a new document has been added. You can then
  52. * use document(TQString) to get the dcop ref for the object.
  53. * Note: this document may or may not be valid at this
  54. * point so you should connect your dcop signals and then
  55. * do a documentValid() on the dcop ref to make sure of its
  56. * state.
  57. **/
  58. void added(TQString);
  59. /**
  60. * Emmitted when the document has been removed.
  61. * note at this point the DCOPRef for this object is
  62. * invalid and you will cannot access it any longer.
  63. * When in doubt call a refresh on it, since if its in the
  64. * process of loading the document call will be safely ignored
  65. * and you will be notified of the updates.
  66. **/
  67. void removed(TQString);
  68. k_dcop:
  69. /**
  70. * Add a new rdf file resource. This will return a dcop reference to the resource. If its a new
  71. * one it will be added otherwise an existing resource reference will be returned.
  72. * once this reference has been returned you may connect dcop signals and then call
  73. * refresh on the RSSDocument. The document will not be updated until refresh is called.
  74. **/
  75. DCOPRef add(TQString url);
  76. /**
  77. * Return a list of current rss documents
  78. **/
  79. TQStringList list();
  80. /**
  81. * Remove an rss document resource. NOTE: Be aware that others may be using this
  82. * resource and if you remove it they may break. Likewise be aware that someone may
  83. * decide to remove your resource on you so you should always check to see if the resource
  84. * is valid before you access it.
  85. **/
  86. void remove(TQString url);
  87. /**
  88. * Return the reference to a requested resource. If this resource is not present a null dcopref is
  89. * returned.
  90. **/
  91. DCOPRef document(TQString url);
  92. /**
  93. * Exit the RSSService. This will clean everything up and exit.
  94. **/
  95. void exit();
  96. };
  97. class RSSDocument : public TQObject, public DCOPObject
  98. {
  99. Q_OBJECT
  100. //
  101. K_DCOP
  102. private:
  103. bool m_isLoading;
  104. TQString m_Url;
  105. Document *m_Doc;
  106. TQPixmap m_pix;
  107. TQPtrList<RSSArticle> m_list;
  108. TQMap<TQString,int> m_state;
  109. TQDateTime m_Timeout;
  110. int m_maxAge;
  111. private slots:
  112. void pixmapLoaded(const TQPixmap&);
  113. void loadingComplete(Loader *, Document, Status);
  114. public:
  115. RSSDocument(const TQString& url);
  116. ~RSSDocument();
  117. k_dcop_signals:
  118. /**
  119. * The pixmap is currently loading
  120. **/
  121. void pixmapUpdating(DCOPRef);
  122. /**
  123. * The pixmap is ready for viewing
  124. * you can then use dcopref->call("pixmap()"); to return it.
  125. *
  126. **/
  127. void pixmapUpdated(DCOPRef);
  128. /**
  129. * The document is currently updating
  130. **/
  131. void documentUpdating(DCOPRef);
  132. /**
  133. * The document is ready for viewing
  134. * you can then use dcopref->call() to access its data
  135. **/
  136. void documentUpdated(DCOPRef);
  137. /**
  138. * The document failed to update, with and error...
  139. * 1 - RSS Parse Error
  140. * 2 - Could not access file
  141. * 3 - Unknown error.
  142. **/
  143. void documentUpdateError(DCOPRef, int);
  144. k_dcop:
  145. /**
  146. * Return the webmaster information from the RSS::Document
  147. **/
  148. TQString webMaster();
  149. /**
  150. * Return the manageing editor from the RSS::Document
  151. **/
  152. TQString managingEditor();
  153. /**
  154. * Returns the rating of the RSS::Document
  155. **/
  156. TQString rating();
  157. /**
  158. * Returns the last build date from the RSS::Document
  159. **/
  160. TQDateTime lastBuildDate();
  161. /**
  162. * Returns the publication date from the RSS::Document
  163. **/
  164. TQDateTime pubDate();
  165. /**
  166. * Returns the copyright information from the RSS::Document
  167. **/
  168. TQString copyright();
  169. /**
  170. * Returns a list of article titles
  171. **/
  172. TQStringList articles();
  173. /**
  174. * Returns the number of articles
  175. **/
  176. int count();
  177. /**
  178. * Returns a dcop reference to the article from the index
  179. **/
  180. DCOPRef article(int idx);
  181. /**
  182. * Returns the link from the RSS::Document
  183. **/
  184. TQString link();
  185. /**
  186. * Returns the description from the RSS::Document
  187. **/
  188. TQString description();
  189. /**
  190. * Returns the title from the RSS::Document
  191. **/
  192. TQString title();
  193. /**
  194. * Returns the text version from the RSS::Document
  195. **/
  196. TQString verbVersion();
  197. /**
  198. * Returns the url for the pixmap from the RSS::Document
  199. **/
  200. TQString pixmapURL();
  201. /**
  202. * Returns the actual pixmap from the RSS::Document's RSS::Image
  203. **/
  204. TQPixmap pixmap();
  205. /**
  206. * Returns if the RSSDocument contains a valid RSS::Document yet.
  207. **/
  208. bool documentValid();
  209. /**
  210. * Returns if the RSSDocument contains a valid RSS::Image
  211. **/
  212. bool pixmapValid();
  213. /**
  214. * Refresh the current RSS::Document.
  215. * This must be called before the document is valid.
  216. **/
  217. void refresh();
  218. /**
  219. * Return the maximum age of the RSS document (Default is 60 minutes)
  220. **/
  221. int maxAge();
  222. /**
  223. * Set the maximum age of the RSS document.
  224. **/
  225. void setMaxAge(int minutes);
  226. /**
  227. * Returns the state of the article
  228. * 0 - not present (deleted from the rss service)
  229. * 1 - new
  230. * 2 - unread
  231. * 3 - read
  232. */
  233. int state( const TQString &title) const;
  234. /**
  235. * Set the article state
  236. */
  237. void setState( const TQString &title, int s );
  238. /**
  239. * Convience method that will set a title to read.
  240. */
  241. void read( const TQString &title);
  242. };
  243. class RSSArticle : public DCOPObject
  244. {
  245. K_DCOP
  246. private:
  247. Article *m_Art;
  248. public:
  249. RSSArticle(Article *art);
  250. ~RSSArticle();
  251. k_dcop:
  252. /**
  253. * Return the articles title
  254. **/
  255. TQString title();
  256. /**
  257. * Return the articles description
  258. **/
  259. TQString description();
  260. /**
  261. * Return the link to the article
  262. **/
  263. TQString link();
  264. };
  265. #endif