BaseMessage.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2012-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. #import <Foundation/Foundation.h>
  21. #import <CoreData/CoreData.h>
  22. typedef enum {
  23. MESSAGE_STATE_SENDING,
  24. MESSAGE_STATE_SENT,
  25. MESSAGE_STATE_DELIVERED,
  26. MESSAGE_STATE_READ,
  27. MESSAGE_STATE_USER_ACK,
  28. MESSAGE_STATE_USER_DECLINED,
  29. MESSAGE_STATE_FAILED
  30. } MessageState;
  31. typedef NS_OPTIONS(NSInteger, BaseMessageFlags) {
  32. BaseMessageFlagsPush = 1 << 0,
  33. BaseMessageFlagsImmediate = 1 << 1,
  34. BaseMessageFlagsNoAck = 1 << 2,
  35. BaseMessageFlagsAlreadyDelivered = 1 << 3,
  36. BaseMessageFlagsGroup = 1 << 4,
  37. BaseMessageFlagsVoip = 1 << 5,
  38. BaseMessageFlagsSilentPush = 1 << 6,
  39. BaseMessageFlagsNoDeliveryReceipt = 1 << 7
  40. };
  41. @class Conversation;
  42. @class Contact;
  43. @interface BaseMessage : NSManagedObject
  44. @property (nonatomic, retain) NSDate * date;
  45. @property (nonatomic, retain) NSData * id;
  46. @property (nonatomic, retain) NSNumber * delivered;
  47. @property (nonatomic, retain) NSNumber * isOwn;
  48. @property (nonatomic, retain) NSNumber * read;
  49. @property (nonatomic, retain) NSNumber * sent;
  50. @property (nonatomic, retain) NSNumber * userack;
  51. @property (nonatomic, retain) NSDate * deliveryDate;
  52. @property (nonatomic, retain) NSDate * readDate;
  53. @property (nonatomic, retain) NSDate * userackDate;
  54. @property (nonatomic, retain) NSNumber * sendFailed;
  55. @property (nonatomic, retain) NSDate * remoteSentDate;
  56. @property (nonatomic, retain) NSString * webRequestId;
  57. @property (nonatomic, retain) NSNumber * flags;
  58. @property (nonatomic, retain) Conversation *conversation;
  59. @property (nonatomic, retain) Contact *sender;
  60. @property (readonly) MessageState messageState;
  61. - (NSString*)logText;
  62. - (NSString*)previewText;
  63. - (NSString*)quotePreviewText;
  64. - (BOOL)wasDeleted;
  65. - (NSDate *)dateForCurrentState;
  66. - (BOOL)noDeliveryReceiptFlagSet;
  67. @end