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.

158 lines
5.8KB

  1. /*
  2. * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program 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
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef MK_TDEIO_PROTO_H
  19. #define MK_TDEIO_PROTO_H
  20. /*
  21. * TDEIO can handle multiple protocols. But some protocols have their own
  22. * manipulations of KURL or MetaData , and some protocols could do more then other
  23. * protocols. So, this class is the generic class of a class specified
  24. * by a protocol.
  25. */
  26. class TQString;
  27. #include <tdeio/global.h>
  28. #include <tdelocale.h>
  29. #include <tqstringlist.h>
  30. #include "protocol.h"
  31. #include "tdeio.h"
  32. class TDEIO_Protocol : public Protocol
  33. {
  34. public:
  35. /*
  36. * Constuctor; empty
  37. */
  38. TDEIO_Protocol() {}
  39. /*
  40. * Destructor; empty too
  41. */
  42. virtual ~TDEIO_Protocol() {}
  43. /*
  44. * Public enumeration
  45. */
  46. enum DeleteTypeEnum { get, del };
  47. /**
  48. * This are the implementation of the Protocol-functions
  49. */
  50. virtual const Protocol* getProtocol( TDEConfigGroup* ) const { return this; }
  51. virtual KMailDrop* createMaildrop( TDEConfigGroup* config ) const { return new KKioDrop( config ); }
  52. virtual TQMap< TQString, TQString >* createConfig( TDEConfigGroup *group, const TQString& password ) const;
  53. /*
  54. * @return: the name of the tdeio_slave
  55. */
  56. virtual TQString protocol( bool ) const { return "file"; }
  57. /*
  58. * @return: the name of the protocol used by the configuration
  59. */
  60. virtual TQString configName() const { return "not specified"; }
  61. virtual bool connectionBased() const { return false; }
  62. /*
  63. * The next four functions return the [capebilities] of a protocol.
  64. * fullMessage means that by downloaden, the whole message is downloaded.
  65. * if it is false, only the headers should be downloaded.
  66. */
  67. virtual bool canReadSubjects() const { return false; }
  68. virtual bool canDeleteMail() const { return false; }
  69. virtual bool canReadMail() const { return false; }
  70. virtual bool fullMessage() const { return false; }
  71. /*
  72. * The following lines are the options in the configuration;
  73. * true means that an option is enabled;
  74. * false means that the option is disabled.
  75. */
  76. //virtual int fields() const { return server | port | username | password | mailbox; }
  77. //virtual int urlFields() const { return no_fields; }
  78. virtual unsigned short defaultPort( bool ) const { return 0; }
  79. /*
  80. * This sets the string of such fields in Configuration
  81. */
  82. virtual TQString serverName() const { return i18n( "Server:" ); }
  83. virtual TQString portName() const { return i18n( "Port:" ); }
  84. virtual TQString usernameName() const { return i18n( "Username:" ); }
  85. virtual TQString mailboxName() const { return i18n( "Mailbox:" ); }
  86. virtual TQString passwordName() const { return i18n( "Password:" ); }
  87. virtual TQString savePasswordName() const { return i18n( "Save password" ); }
  88. virtual TQString authName() const { return i18n( "Authentication:" ); }
  89. /*
  90. * The next function returns the method of deleting: some protoocols
  91. * like to delete files with TDEIO::get; other with TDEIO::del
  92. */
  93. virtual DeleteTypeEnum deleteFunction() const { return del; }
  94. /*
  95. * The next options are the input for the Authentication Combo, seperated by '|'.
  96. * The name should be the same as the auth-metadata.
  97. */
  98. virtual TQStringList authList() const { return TQStringList::split( '|', "Plain", false ); }
  99. /*
  100. * The next functions are manipulations of an KURL.
  101. * At some points in the code, a KURL is used. But sometimes,
  102. * these have to had a little retouch. That is possible with these function.
  103. *
  104. * For example, by imap, by default, the whole message is downloaded and marked as reed.
  105. * By changing an option to the KURL path, this can be prevented.
  106. *
  107. * The most functions are recognized by name.
  108. * commitDelete return true if a protocol has to confirm a deletion.
  109. * It will be called after marking the messages for deletion.
  110. * deleteCommitKURL is the KURL manipulator; the KURL is as in the settings.
  111. * That KURL isn't retouch by deleteMailKURL.
  112. */
  113. virtual void recheckConnectKURL( KURL &, TDEIO::MetaData & ) const { }
  114. virtual void recheckKURL ( KURL &, TDEIO::MetaData & ) const { };
  115. virtual void readSubjectConnectKURL ( KURL & kurl, TDEIO::MetaData & ) const { kurl.setPath( "" ); }
  116. virtual void readSubjectKURL ( KURL &, TDEIO::MetaData & ) const { } //For editing a kurl (adding extra options)
  117. virtual void deleteMailConnectKURL( KURL & kurl, TDEIO::MetaData & ) const { kurl.setPath( "" ); }
  118. virtual void deleteMailKURL ( KURL &, TDEIO::MetaData & ) const { }
  119. virtual bool commitDelete() const { return false; }
  120. virtual void deleteCommitKURL( KURL &, TDEIO::MetaData & ) const { }
  121. virtual void readMailKURL ( KURL &, TDEIO::MetaData & ) const { }
  122. virtual const TDEIO_Protocol* getKIOProtocol() const { return this; }
  123. virtual void readEntries( TQMap< TQString, TQString >* ) const;
  124. virtual void readEntries( TQMap< TQString, TQString >*, TQMap< TQString, TQString >* ) const = 0;
  125. protected:
  126. /*
  127. * This enumeration is used when returning the capebilitys of a protocol
  128. */
  129. enum Fields { no_fields = 0, server = 1, port = 2, username = 4, password = 8,
  130. mailbox = 16, save_password = 32, metadata = 64 };
  131. void clearFields( TQMap< TQString, TQString > *map, const Fields fields ) const;
  132. };
  133. #endif //MK_TDEIO_PROTO_H