TDE personal information management 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.
 
 
 
 
 
 

238 lines
5.9 KiB

  1. /*
  2. This file is part of tdepim.
  3. Copyright (c) 2003 - 2004 Tobias Koenig <tokoe@kde.org>
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef KCAL_RESOURCEXMLRPC_H
  18. #define KCAL_RESOURCEXMLRPC_H
  19. #include <tqdatetime.h>
  20. #include <tqptrlist.h>
  21. #include <tqstring.h>
  22. #include <tdeconfig.h>
  23. #include <kurl.h>
  24. #include <tdepimmacros.h>
  25. #include "libkcal/calendarlocal.h"
  26. #include "libkcal/incidence.h"
  27. #include "libkcal/resourcecached.h"
  28. #include "todostatemapper.h"
  29. namespace KXMLRPC {
  30. class Server;
  31. }
  32. class Synchronizer;
  33. class TQTimer;
  34. namespace KCal {
  35. class EGroupwarePrefs;
  36. /**
  37. This class provides access to php/eGroupware calendar via XML-RPC.
  38. */
  39. class KDE_EXPORT ResourceXMLRPC : public ResourceCached
  40. {
  41. Q_OBJECT
  42. public:
  43. ResourceXMLRPC( const TDEConfig* );
  44. ResourceXMLRPC();
  45. virtual ~ResourceXMLRPC();
  46. void readConfig( const TDEConfig* config );
  47. void writeConfig( TDEConfig* config );
  48. EGroupwarePrefs *prefs() const { return mPrefs; }
  49. bool isSaving();
  50. TDEABC::Lock *lock();
  51. /**
  52. Add Event to calendar.
  53. */
  54. bool addEvent( Event* event );
  55. /**
  56. Deletes an event from this calendar.
  57. */
  58. bool deleteEvent( Event* );
  59. /**
  60. Retrieves an event on the basis of the unique string ID.
  61. */
  62. Event *event( const TQString& uid );
  63. /**
  64. Return unfiltered list of all events in calendar.
  65. */
  66. Event::List rawEvents();
  67. /**
  68. Builds and then returns a list of all events that match for the
  69. date specified. useful for dayView, etc. etc.
  70. */
  71. Event::List rawEventsForDate(
  72. const TQDate& date,
  73. EventSortField sortField=EventSortUnsorted,
  74. SortDirection sortDirection=SortDirectionAscending );
  75. /**
  76. Get unfiltered events for date \a qdt.
  77. */
  78. Event::List rawEventsForDate( const TQDateTime& qdt );
  79. /**
  80. Get unfiltered events in a range of dates. If inclusive is set to true,
  81. only events are returned, which are completely included in the range.
  82. */
  83. Event::List rawEvents( const TQDate& start, const TQDate& end,
  84. bool inclusive = false );
  85. /**
  86. Add a todo to the todolist.
  87. */
  88. bool addTodo( Todo* todo );
  89. /**
  90. Remove a todo from the todolist.
  91. */
  92. bool deleteTodo( Todo* todo );
  93. /**
  94. Searches todolist for an event with this unique string identifier,
  95. returns a pointer or null.
  96. */
  97. Todo *todo( const TQString& uid );
  98. /**
  99. Return list of all todos.
  100. */
  101. Todo::List rawTodos();
  102. /**
  103. Returns list of todos due on the specified date.
  104. */
  105. Todo::List rawTodosForDate( const TQDate& date );
  106. /**
  107. Add a Journal entry to calendar
  108. */
  109. virtual bool addJournal( Journal* journal );
  110. /**
  111. Remove journal from the calendar.
  112. */
  113. bool deleteJournal( Journal* journal );
  114. /**
  115. Return Journals for given date
  116. */
  117. virtual Journal::List journals( const TQDate& );
  118. /**
  119. Return Journal with given UID
  120. */
  121. virtual Journal *journal( const TQString& uid );
  122. /**
  123. Return all alarms, which ocur in the given time interval.
  124. */
  125. Alarm::List alarms( const TQDateTime& from, const TQDateTime& to );
  126. /**
  127. Return all alarms, which ocur before given date.
  128. */
  129. Alarm::List alarmsTo( const TQDateTime& to );
  130. /**
  131. Public because needed in MultiCalendar::load()
  132. */
  133. bool doOpen();
  134. void doClose();
  135. void dump() const;
  136. void setTimeZoneId( const TQString& ) {}
  137. protected slots:
  138. void loginFinished( const TQValueList<TQVariant>&, const TQVariant& );
  139. void logoutFinished( const TQValueList<TQVariant>&, const TQVariant& );
  140. void listEventsFinished( const TQValueList<TQVariant>&, const TQVariant& );
  141. void addEventFinished( const TQValueList<TQVariant>&, const TQVariant& );
  142. void updateEventFinished( const TQValueList<TQVariant>&, const TQVariant& );
  143. void deleteEventFinished( const TQValueList<TQVariant>&, const TQVariant& );
  144. void loadEventCategoriesFinished( const TQValueList<TQVariant>&, const TQVariant& );
  145. void listTodosFinished( const TQValueList<TQVariant>&, const TQVariant& );
  146. void addTodoFinished( const TQValueList<TQVariant>&, const TQVariant& );
  147. void updateTodoFinished( const TQValueList<TQVariant>&, const TQVariant& );
  148. void deleteTodoFinished( const TQValueList<TQVariant>&, const TQVariant& );
  149. void loadTodoCategoriesFinished( const TQValueList<TQVariant>&, const TQVariant& );
  150. void fault( int, const TQString&, const TQVariant& );
  151. protected:
  152. bool doLoad();
  153. bool doSave();
  154. private slots:
  155. void reload();
  156. private:
  157. void init();
  158. void initEGroupware();
  159. void writeEvent( Event*, TQStringVariantMap& );
  160. void readEvent( const TQStringVariantMap&, Event*, TQString& );
  161. void writeTodo( Todo*, TQStringVariantMap& );
  162. void readTodo( const TQStringVariantMap&, Todo*, TQString& );
  163. void checkLoadingFinished();
  164. KXMLRPC::Server *mServer;
  165. EGroupwarePrefs *mPrefs;
  166. TQString mSessionID;
  167. TQString mKp3;
  168. TQMap<TQString, int> mEventCategoryMap;
  169. TQMap<TQString, int> mTodoCategoryMap;
  170. TodoStateMapper mTodoStateMapper;
  171. Synchronizer *mSynchronizer;
  172. TDEABC::Lock *mLock;
  173. int mLoaded;
  174. };
  175. }
  176. #endif