TDE core libraries
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.

provider.h 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. This file is part of KOrganizer.
  3. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
  4. Copyright (c) 2014 Timothy Pearson <kb9vqf@pearsoncomputing.net>
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public License
  14. along with this library; see the file COPYING.LIB. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef KNEWSTUFF_PROVIDER_H
  19. #define KNEWSTUFF_PROVIDER_H
  20. #include <tqcstring.h>
  21. #include <tqdom.h>
  22. #include <tqobject.h>
  23. #include <tqptrlist.h>
  24. #include <tqstring.h>
  25. #include <kurl.h>
  26. namespace TDEIO { class Job; }
  27. namespace KNS {
  28. /**
  29. * @short TDENewStuff provider container.
  30. *
  31. * This class provides accessors for the provider object.
  32. * as used by TDENewStuff.
  33. * It should probably not be used directly by the application.
  34. *
  35. * @author Cornelius Schumacher (schumacher@kde.org)
  36. * \par Maintainer:
  37. * Timothy Pearson (kb9vqf@pearsoncomputing.net)
  38. */
  39. class KDE_EXPORT Provider : public TQObject
  40. {
  41. Q_OBJECT
  42. public:
  43. typedef TQPtrList<Provider> List;
  44. /**
  45. * Constructor.
  46. */
  47. Provider( TQString type = TQString::null, TQWidget* parent = 0 );
  48. /**
  49. * Constructor with XML feed.
  50. */
  51. Provider( const TQDomElement &, TQString type = TQString::null, TQWidget* parent = 0 );
  52. /**
  53. * Destructor.
  54. */
  55. virtual ~Provider();
  56. /**
  57. * @return provider load status
  58. */
  59. bool loaded();
  60. /**
  61. * Sets the common name of the provider.
  62. */
  63. void setName( const TQString & );
  64. /**
  65. * Retrieves the common name of the provider.
  66. *
  67. * @return provider name
  68. */
  69. TQString name() const;
  70. /**
  71. * Sets the download URL.
  72. */
  73. void setDownloadUrl( const KURL & );
  74. /**
  75. * Retrieves the download URL.
  76. *
  77. * @return download URL
  78. */
  79. KURL downloadUrl() const;
  80. /**
  81. * Variant to retrieve 'tagged' download URLs.
  82. * Variant can be one of 'score', 'downloads', 'latest'.
  83. *
  84. * @return download specific URL
  85. */
  86. KURL downloadUrlVariant( TQString variant ) const;
  87. /**
  88. * Sets the upload URL.
  89. */
  90. void setUploadUrl( const KURL & );
  91. /**
  92. * Retrieves the upload URL.
  93. *
  94. * @return upload URL
  95. */
  96. KURL uploadUrl() const;
  97. /**
  98. * Sets the URL where a user is led if the provider does not support
  99. * uploads.
  100. *
  101. * @see setNoUpload
  102. */
  103. void setNoUploadUrl( const KURL & );
  104. /**
  105. * Retrieves the URL where a user is led if the provider does not
  106. * support uploads.
  107. *
  108. * @return website URL
  109. */
  110. KURL noUploadUrl() const;
  111. /**
  112. * Indicate whether provider supports uploads.
  113. */
  114. void setNoUpload( bool );
  115. /**
  116. * Query whether provider supports uploads.
  117. *
  118. * @return upload support status
  119. */
  120. bool noUpload() const;
  121. /**
  122. * Sets the URL for an icon for this provider.
  123. * The icon should be in 32x32 format. If not set, the default icon
  124. * of KDialogBase is used.
  125. */
  126. void setIcon( const KURL & );
  127. /**
  128. * Retrieves the icon URL for this provider.
  129. *
  130. * @return icon URL
  131. */
  132. KURL icon() const;
  133. protected:
  134. void parseDomElement( const TQDomElement & );
  135. TQDomElement createDomElement( TQDomDocument &, TQDomElement &parent );
  136. protected slots:
  137. void slotJobData( TDEIO::Job *, const TQByteArray & );
  138. void slotJobResult( TDEIO::Job * );
  139. signals:
  140. void providerLoaded();
  141. private:
  142. TQString mName;
  143. KURL mDownloadUrl;
  144. KURL mUploadUrl;
  145. KURL mNoUploadUrl;
  146. KURL mIcon;
  147. bool mNoUpload;
  148. TQString mJobData;
  149. TQString mBaseURL;
  150. TQWidget* mParent;
  151. bool mLoaded;
  152. TQString mContentType;
  153. };
  154. /**
  155. * TDENewStuff provider loader.
  156. * This class sets up a list of all possible providers by querying
  157. * the main provider database for this specific application.
  158. * It should probably not be used directly by the application.
  159. */
  160. class KDE_EXPORT ProviderLoader : public TQObject
  161. {
  162. Q_OBJECT
  163. public:
  164. /**
  165. * Constructor.
  166. *
  167. * @param parentWidget the parent widget
  168. */
  169. ProviderLoader( TQWidget *parentWidget );
  170. /**
  171. * Starts asynchronously loading the list of providers of the
  172. * specified type.
  173. *
  174. * @param type data type such as 'kdesktop/wallpaper'.
  175. * @param providerList the URl to the list of providers; if empty
  176. * we first try the ProvidersUrl from TDEGlobal::config, then we
  177. * fall back to a hardcoded value.
  178. */
  179. void load( const TQString &type, const TQString &providerList = TQString::null );
  180. signals:
  181. /**
  182. * Indicates that the list of providers has been successfully loaded.
  183. */
  184. void providersLoaded( Provider::List * );
  185. void percent(TDEIO::Job *job, unsigned long percent);
  186. void error();
  187. protected slots:
  188. void slotJobData( TDEIO::Job *, const TQByteArray & );
  189. void slotJobResult( TDEIO::Job * );
  190. void providerLoaded();
  191. private:
  192. TQWidget *mParentWidget;
  193. TQString mJobData;
  194. TQString mContentType;
  195. Provider::List mProviders;
  196. };
  197. }
  198. #endif